My problem is not difficult :) i use Laravel 4, and i just want to get the first element of my list, my code is :
public function index()
{
$userid = User::lists('id'); // here i want to get the first element of my list
$services = User::find($userid)->service;
$username = User::lists('username');
return View::make('services.index',array('services'=> $services,'username'=>$username));
}
so if someone has any idea i will be very appreciative :)
Within Laravel, the 'lists' method returns an array. So, you may simply access the first object in the array by using something like:
$userid[0] = $firstUserId;
If you don't need the list but just the first item:
$user = User::first();
$userid = $user->id
$services = $user->service;
$username = $user->username;