%PDF- %GIF98; %PNG;
Server : ApacheSystem : Linux host.digitalbabaji.in 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64 User : addictionfreeind ( 1003) PHP Version : 7.2.34 Disable Function : exec,passthru,shell_exec,system Directory : /home/addictionfreeind/www/admin1/app/DataTables/ |
Upload File : |
<?php
namespace App\DataTables;
use App\Models\HomeListing;
use Yajra\DataTables\Html\Button;
use Yajra\DataTables\Html\Column;
class HomeListingsDataTable extends BaseDataTable
{
public function __construct()
{
parent::__construct();
}
/**
* Build DataTable class.
*
* @param mixed $query Results from query() method.
* @return \Yajra\DataTables\DataTableAbstract
*/
public function dataTable($query)
{
$datatables = datatables()->eloquent($query);
$datatables->addIndexColumn();
$datatables->addColumn('action', function ($row) {
$action = '<div class="task_view">
<div class="dropdown">
<a class="task_view_more d-flex align-items-center justify-content-center dropdown-toggle" type="link"
id="dropdownMenuLink-' . $row->id . '" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="icon-options-vertical icons"></i>
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuLink-' . $row->id . '" tabindex="0">';
$action .= '<a class="dropdown-item openRightModal" href="' . route('centers.edit', [$row->id]) . '">
<i class="fa fa-edit mr-2"></i>
' . trans('app.edit') . '
</a>';
$action .= '<a class="dropdown-item delete-table-row" href="javascript:;" data-center-id="' . $row->id . '">
<i class="fa fa-trash mr-2"></i>
' . trans('app.delete') . '
</a>';
$action .= '</div>
</div>
</div>';
return $action;
});
$datatables->editColumn('treatment', function ($row) {
return json_decode($row->treatment);
});
$datatables->editColumn('city', function ($row) {
return $row->city;
});
$datatables->editColumn('picture', function ($row) {
$Url = $row->picture ? $row->picture_url : '';
return '<img src="'.$Url.'" style="max-height: 50px;">';
});
$datatables->rawColumns(['picture', 'action']);
return $datatables;
}
/**
* @return \Illuminate\Database\Eloquent\Builder
*/
public function query()
{
$request = $this->request();
$model = HomeListing::select('*');
if ($request->searchText != '') {
$model->where('home_listings.name', 'like', '%' . request('searchText') . '%');
}
return $model;
}
/**
* Optional method if you want to use html builder.
*
* @return \Yajra\DataTables\Html\Builder
*/
public function html()
{
return $this->setBuilder('invoices-table')
->parameters([
'initComplete' => 'function () {
window.LaravelDataTables["invoices-table"].buttons().container()
.appendTo( "#table-actions")
}',
'fnDrawCallback' => 'function( oSettings ) {
$("body").tooltip({
selector: \'[data-toggle="tooltip"]\'
})
}',
])
->buttons(Button::make(['extend' => 'excel', 'text' => '<i class="fa fa-file-export"></i> ' . trans('app.exportExcel')]));
}
/**
* Get columns.
*
* @return array
*/
protected function getColumns()
{
$data = [
'#' => ['data' => 'DT_RowIndex', 'orderable' => false, 'searchable' => false, 'visible' => true, 'title' => '#'],
__('app.id') => ['data' => 'id', 'name' => 'id', 'title' => __('app.id'), 'visible' => false],
__('app.picture') . '#' => ['data' => 'picture', 'name' => 'picture', 'title' => __('app.picture')],
__('app.treatment') . '#' => ['data' => 'treatment', 'name' => 'treatment', 'title' => __('app.treatment')],
__('app.city') . '#' => ['data' => 'city', 'name' => 'city', 'title' => __('app.city')],
__('app.name') . '#' => ['data' => 'name', 'name' => 'name', 'title' => __('app.name')],
__('app.phone') . '#' => ['data' => 'whatsapp', 'name' => 'whatsapp', 'title' => __('app.phone')],
__('app.address') . '#' => ['data' => 'address', 'name' => 'address', 'title' => __('app.address')],
];
$action = [
Column::computed('action', __('app.action'))
->exportable(false)
->printable(false)
->orderable(false)
->searchable(false)
->addClass('text-right pr-20')
];
return array_merge($data, $action);
}
}