¨4.0.1¨
This commit is contained in:
@@ -2,6 +2,12 @@
|
||||
|
||||
namespace Modules\Admin\Ui;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Yajra\DataTables\DataTables;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Yajra\DataTables\Exceptions\Exception;
|
||||
use Illuminate\Contracts\Support\Responsable;
|
||||
|
||||
class AdminTable implements Responsable
|
||||
@@ -11,28 +17,30 @@ class AdminTable implements Responsable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $rawColumns = [];
|
||||
protected array $rawColumns = [];
|
||||
|
||||
/**
|
||||
* Raw columns that will not be escaped.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultRawColumns = [
|
||||
'checkbox', 'thumbnail', 'status', 'created',
|
||||
protected array $defaultRawColumns = [
|
||||
'checkbox', 'thumbnail', 'status', 'created', 'updated',
|
||||
];
|
||||
|
||||
/**
|
||||
* Source of the table.
|
||||
*
|
||||
* @var \Illuminate\Database\Eloquent\Builder
|
||||
* @var Builder
|
||||
*/
|
||||
protected $source;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new table instance.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $source
|
||||
* @param Builder $source
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($source = null)
|
||||
@@ -40,22 +48,38 @@ class AdminTable implements Responsable
|
||||
$this->source = $source;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create an HTTP response that represents the object.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function toResponse($request)
|
||||
{
|
||||
return $this->make()->toJson();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Make table response for the resource.
|
||||
*
|
||||
* @param mixed $source
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function make()
|
||||
{
|
||||
return $this->newTable();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new datatable instance;
|
||||
*
|
||||
* @param mixed $source
|
||||
* @return \Yajra\DataTables\DataTables
|
||||
* @return DataTables
|
||||
* @throws Exception
|
||||
*/
|
||||
public function newTable()
|
||||
{
|
||||
@@ -71,18 +95,10 @@ class AdminTable implements Responsable
|
||||
->editColumn('created', function ($entity) {
|
||||
return view('admin::partials.table.date')->with('date', $entity->created_at);
|
||||
})
|
||||
->editColumn('updated', function ($entity) {
|
||||
return view('admin::partials.table.date')->with('date', $entity->updated_at);
|
||||
})
|
||||
->rawColumns(array_merge($this->defaultRawColumns, $this->rawColumns))
|
||||
->removeColumn('translations');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an HTTP response that represents the object.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function toResponse($request)
|
||||
{
|
||||
return $this->make()->toJson();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user