File: //var/www/admin.javaapp.co.uk/app/Services/UserModuleService.php
<?php
namespace App\Services;
use Yajra\DataTables\Facades\DataTables;
class userModuleService
{
private $model;
public function __construct($model)
{
$this->model = new $model();
}
public function data()
{
$data = $this->model->query()->select('*')->where('type',1);
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('profile_picture', function ($row) {
if (!empty($row->profile_picture)) {
// return '-';
// } else {
// if (strlen($row->profile_picture) > 50) {
// return substr($row->profile_picture, 0, 50) . '...';
// } else {
return $row->profile_picture;
//}
}
})
->editColumn('address', function ($row) {
if (empty($row->address)) {
return 'Not Available!';
} else {
if (strlen($row->address) > 50) {
return substr($row->address, 0, 50) . '...';
} else {
return $row->address;
}
}
})
->editColumn('is_active', function ($row) {
if (empty($row->is_active)) {
return 'Not Available!';
} else {
return $row->is_active;
}
})
// ->addColumn('action', function ($row) {
// return view(
// "partials.action",
// [
// 'currentRoute' => 'admin.user-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['userModuleUrl'] = route('admin.user-module.index');
$data['user'] = $id;
return view('admin.order-history.index', $data);
}
}