app/Http/Controllers/TaskController.php
/**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
Show the form for creating a new resource.
@return \Illuminate\Http\Response
Show the form for creating a new resource . @return \ Illuminate \ Http \ Response
public function create()
    {
        $user = \Auth::user();
        if ($user->role_id == 3) {
            $analystsArray[$user->id] = $user->first_name." ".$user->last_name;
            $clients = $user->clients;
        } else {
            $analysts = User::wherein('role_id', [2,3])->get();
            $analystsArray = array();
            $analystsArray[''] = '';
            foreach ($analysts as $a_analyst) {
                $analystsArray[$a_analyst->id] = $a_analyst->first_name." ".$a_analyst->last_name;
            }
            $clients = User::where('role_id', 4)->get();
        }
        $clientsArray = [];
        $clientsArray[''] = ''; 
        foreach ($clients as $a_client) {
            $clientsArray[$a_client->id] = $a_client->first_name.' '.$a_client->last_name;
        }
        return view('tasks.create', [
            'analysts'  => $analystsArray,
            'clients'   => $clientsArray
            ]);
    }
public function create ( ) { $ user = \ Auth :: user ( ) ; if ( $ user -> role_id == 3 ) { $ analystsArray [ $ user -> id ] = $ user -> first_name . " " . $ user -> last_name ; $ clients = $ user -> clients ; } else { $ analysts = User :: wherein ( 'role_id' , [ 2 , 3 ] ) -> get ( ) ; $ analystsArray = array ( ) ; $ analystsArray [ '' ] = '' ; foreach ( $ analysts as $ a_analyst ) { $ analystsArray [ $ a_analyst -> id ] = $ a_analyst -> first_name . " " . $ a_analyst -> last_name ; } $ clients = User :: where ( 'role_id' , 4 ) -> get ( ) ; } $ clientsArray = [ ] ; $ clientsArray [ '' ] = '' ; foreach ( $ clients as $ a_client ) { $ clientsArray [ $ a_client -> id ] = $ a_client -> first_name . ' ' . $ a_client -> last_name ; } return view ( 'tasks.create' , [ 'analysts' => $ analystsArray , 'clients' => $ clientsArray ] ) ; }
Show the form for creating a new resource.
Show the form for creating a new resource .