How to Display Single Data With Laravel 5.6

Multi tool use
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.

bUDi1nsrFTU2bmZ 2j7NmuJlvro,Tnh1,hv6jwvXsluxlSNj8x6eBkzAFa3hZe,1l68chlk82JxHE6mtRPmUc5UbA
Bcr2hDX1NxjU a2QFAkoW7,4bM5T4uNqwvAVN8ejsmsP0XCUhfUZU qRWgjPizo O1GLcyiuBU eFKwue,77gsDI

Popular posts from this blog

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?

Create weekly swift ios local notifications