I am struggling to insert "permissions" to my Gantt's chart (aka DHTMLX Gantt) The problem is is that I want an if statement in my function like so:
public function getOne($id){
if(Auth::user()->hasRole('manufacturing')) {
$tasks = Task::where('relation_id', $id)->where('parent', 0)->orwhere('permission', 2)->get();
$links = Link::query();
} else {
$tasks = Task::get();
$links = Link::query();
}
return response()->json([
"data" => $tasks,
"links" => $links->get()
]);
Here I am using Laratrust as my role manager. Now the thing is that this function throws me a console error 500 and I cannot back track it in the API. If I do a simple IF like: if(1 === 1)
It works fine. So I am thinking this is a problem with API not reaching the downloaded package. My Gantt's routes are in the api.php and written like so:
use Illuminate\Http\Request;
Route::get('/data', 'GanttController@getAll');
Route::get('/data/{id}', 'GanttController@getOne');
My goal is to make that depending on what Laratrust says (which role or permission user has) I define the IF statement and change the Query. I know it's not dynamic but it has to do.