I'm having an issue in a Laravel Zero project I'm working on. I'm working on a command that handles direct file transfers between 2 disks—1 SFTP and anoth
I need to get all the rows on my database that meet some criteria. One those criteria is to not be older than 24 hours. I've been trying different solutions pos
I'm trying to print {{$day->date}} in a view. Instead of full date YYYY-MM-DD the property only returns year YYYY. Can anyone explain me why it is working li
I'm new to laravel and I want to submit a form which have three attachments plus some arrays but when I click submit button laravel says "The POST method
I've an enum field in my migration. The code is here: Schema::create('clients', function (Blueprint $table) { $table->increments('id'); $ta
I'm struggling to sort an Eloquent collection using the sortBy() method. The issue is that the sorting is case sensitive and it first retrieves the uppercase re
I am working on a Laravel 5.7 based project in which Eloquent is used as an ORM. I need to execute a raw SQL statement on my database. Howev
I've a fetch a Laravel Eloquent collection by: $product = Product::query()->with(['merchant', 'picture'])->where('id', $id)->first(); and get the du
I often find it very useful to index my results by the primary key id. Example: $out = []; $users = User::where('created_at', '>=', '2015-01-01')->get(
I am working with Laravel 5 and I am having issue getting ->wherePivot() to work on a Many-to-Many relationship. When I dd() the SQL it looks like Eloquent i
I want to make query in Laravel Eloquent like here its raw MySQL query SELECT * from exampleTbl where id in(1,2,3,4) I have tried this in Laravel Eloquent
I have some query that I need to pass to another query using query builder $query = DB::table('table')->whereIn('some_field', [1,2,30])->toSql(); Model::
I am trying to learn whether or not there is a simple way to pass a variable number of parameters to a query in Eloquent, hopefully using an array. From what I
I have a lot of data. I want to bring the data from the database as a monthly wise. I have already used group by method but when I want to view the data all the
Background I'm creating a database revolving around food allergies and I have a many to many relationship between foods and allergies. There is also a pivot va
My app requires data to be gathered from an external API. I am using Guzzle. My API methods are written into a separate class stored in a library folder. I ha
I did some performance tests between Laravel's DB facade query builder and Laravel's Eloquent ORM. The DB facade was much faster than Eloquent
I want to join on a result of other select like this : SELECT * FROM TABLE1 JOIN ( SELECT cat_id FROM TABLE2 where brand_id = 2 GROUP BY TABLE2.cat_id) A
How can i get 'natural order' in 'Eloquent ORM'? In table I have column 'text' (string). Normal order: Model::orderBy('text') 'value 1' 'value 12' 'value 23'
Is it possible to use eloquent to retrieve just the first match in a one to many relationship? What do I mean, well, let me explain. Most of us are familiar wit