app/Http/Controllers/TaskController.php
/**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
Display a listing of the resource.
@return \Illuminate\Http\Response
Display a listing of the resource . @return \ Illuminate \ Http \ Response
public function index()
    {
        $user = \Auth::user();
        if ($user->hasRole('supervisor') || $user->hasRole('super administrador')) {
            $tasks = Task::all();
        } elseif ($user->hasRole('analista')) {
            $tasks = $user->tasks;
        } elseif ($user->hasRole('usuario')){
            $tasks = Task::where('client_id', $user->id)->get();
        }
        $total_tasks = $tasks->count();
        return view('tasks.show', [
            'user'                    => $user,
            'tasks'                   => $tasks,
            'total_tasks'             => $total_tasks
            ]
            );
    }
public function index ( ) { $ user = \ Auth :: user ( ) ; if ( $ user -> hasRole ( 'supervisor' ) || $ user -> hasRole ( 'super administrador' ) ) { $ tasks = Task :: all ( ) ; } elseif ( $ user -> hasRole ( 'analista' ) ) { $ tasks = $ user -> tasks ; } elseif ( $ user -> hasRole ( 'usuario' ) ) { $ tasks = Task :: where ( 'client_id' , $ user -> id ) -> get ( ) ; } $ total_tasks = $ tasks -> count ( ) ; return view ( 'tasks.show' , [ 'user' => $ user , 'tasks' => $ tasks , 'total_tasks' => $ total_tasks ] ) ; }
Display a listing of the resource.
Display a listing of the resource .