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

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -