How to Display Single Data With Laravel 5.6

Multi tool use
How to Display Single Data With Laravel 5.6
Hello everybody,
Here i want to ask about how to display single row from database in view, usually we use @foreach for looping data. but here i just want to display one row.
Note : Display single row but use this eloquent ItemName::latest()
help me please, thank you :)
1 Answer
1
In model ItemName.php file, you could create a function. This function would return only one row by your filter.
Ex:
public static latest($itemId) {
return self::where(['item_id' => $itemId])->orderBy('id', 'desc')->first();
}
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.