php - how to get the first element of a list in laravel? -
my problem not difficult :) use laravel 4, , want first element of list, code :
public function index() { $userid = user::lists('id'); // here want first element of list $services = user::find($userid)->service; $username = user::lists('username'); return view::make('services.index',array('services'=> $services,'username'=>$username)); }
so if someone has idea appreciative :)
within laravel, 'lists' method returns array. so, may access first object in array using like:
$userid[0] = $firstuserid;
Comments
Post a Comment