File: /var/www/javago-portal-updates/app/Services/CustomerModuleService.php
<?php
namespace App\Services;
use Yajra\DataTables\Facades\DataTables;
class CustomerModuleService
{
private $model;
public function __construct($model)
{
$this->model = new $model();
}
public function data()
{
$data = $this->model->query()->join('orders', 'orders.user_id', '=', 'users.id')->select('users.id', 'users.name', 'users.email', 'users.address')->groupBy('users.id');
return DataTables::eloquent($data)
->addIndexColumn()
->editColumn('name', function ($row) {
if (empty($row->name)) {
return '-';
} else {
if (strlen($row->name) > 30) {
return substr($row->name, 0, 50) . '...';
} else {
return $row->name;
}
}
})
->editColumn('email', function ($row) {
if (empty($row->email)) {
return '-';
} else {
if (strlen($row->email) > 50) {
return substr($row->email, 0, 50) . '...';
} else {
return $row->email;
}
}
})
->editColumn('address', function ($row) {
if (empty($row->address)) {
return '-';
} else {
if (strlen($row->address) > 50) {
return substr($row->address, 0, 50) . '...';
} else {
return $row->address;
}
}
})
->addColumn('action', function ($row) {
return view(
"partials.action",
[
'currentRoute' => 'admin.customer-module',
'row' => $row,
'isApproved' => 0,
'isDelete' => 0,
'isView' => 1,
]
)->render();
})
->rawColumns(['action', 'status'])
->toJson();
}
public function show($id)
{
abort_if(!$id, 404);
$model = $this->model->find(decrypt($id));
abort_if(!$model, 404);
$data = [];
$data['dataUrl'] = route('admin.order-history.data');
$data['customerModuleUrl'] = route('admin.customer-module.index');
$data['user'] = $id;
return view('admin.order-history.index', $data);
}
}