php - How to get the Last data from Database using Laravel -
i trying column of last data in database far, getting data in database in array.
this code;
public function newid(){ $adminid=auth::user()->admin_id;//cooperative id $newid = member::select('member_id')->where('admin_id', '=',$adminid)->get(); return view::make('admin.member.addmember') ->with('newid', $newid); }
i have updated code base on suggestions;
public function newid(){ $adminid=auth::user()->admin_id;//cooperative id $newid = member::select('member_id')->where('admin_id', '=',$adminid)->orderby('id', 'desc')->first(); return view::make('admin.member.addmember') ->with('newid', $newid); }
and using for loop
display data on view
@foreach ($newid $newids) {{$newids->member_id}} @endforeach
my error errorexception:trying property of non-object
answer
i got work
i used instead
public function newid(){ $adminid=auth::user()->admin_id;//cooperative id $newid = member::select('member_id')->where('admin_id', '=',$adminid)->orderby('id', 'desc')->take(1)->get(); return view::make('admin.member.addmember') ->with('newid', $newid); }
i got work
i used instead
public function newid(){ $adminid=auth::user()->admin_id;// id $newid = member::select('member_id')->where('admin_id', '=',$adminid)->orderby('id', 'desc')->take(1)->get(); return view::make('admin.member.addmember') ->with('newid', $newid); }
Comments
Post a Comment