How to delete all the rows in a table using Eloquent?
My guess was to use the following syntax: MyModel::all()->delete(); But that did not work. I’m sure it’s super simple, but I’ve searched for … Read more
My guess was to use the following syntax: MyModel::all()->delete(); But that did not work. I’m sure it’s super simple, but I’ve searched for … Read more
I have the following query: $query = UserSubject::where(‘user_id’, Auth::id())->select(‘subject_id’)->get(); and as expected I get the following result: [{“user_id”:8,”subject_id”:9},{“user_id”:8,”subject_id”:2}] Is there a way of … Read more
I’m having trouble to write query in laravel eloquent ORM. my query is SELECT book_name,dt_of_pub,pub_lang,no_page,book_price FROM book_mast WHERE book_price NOT IN (100,200); Now … Read more
When I went through Laravel Document about Eloquent ORM topic part, I got a new term “Mass Assignment”. Document show How to do … Read more
When I delete a row using this syntax: $user->delete(); Is there a way to attach a callback of sorts, so that it would … Read more
How can we perform bulk database insertions in Laravel using Eloquent ORM? I am working with an XML document, looping through its elements. … Read more
I would like to retrieve the last file inserted into my table. I know that the method first() exists and provides you with … Read more
lets say I have 7 columns in table, and I want to select only two of them, something like this SELECT `name`,`surname` FROM … Read more
I’m trying to create foreign keys in Laravel however when I migrate my table using artisan i am thrown the following error: [Illuminate\Database\QueryException] … Read more
This question already has answers here: Laravel Eloquent: Ordering results of all() (12 answers) Closed 6 years ago. Simple question – how do … Read more