Top "Eloquent" questions

The Eloquent ORM included with Laravel provides a beautiful, simple ActiveRecord implementation for working with your database.

Is there any Laravel way to execute a .SQL file to load data

I have historical data that I want to load in new DB. I could do it by running MySQL command …

mysql eloquent laravel-5.1 laravel-artisan
Laravel: Where selection for Eloquent Eager Loading relationship

I got two DB tables: Posts $table->increments('id'); $table->integer('country_id')->unsigned(); $table->…

php laravel laravel-5 eloquent eager-loading
Why is my Laravel Eloquent accessor not showing up in the response?

I have a Model Review that has a unix timestamp as 1 of it's attributes (table columns). I use 2 accessors inside …

laravel laravel-5 eloquent laravel-5.5 accessor
Laravel Fluent add select()s in separate places?

//Earlier in the code, in each Model: query = ModelName::select('table_name.*') //Later in the code in a function …

mysql select laravel fluent eloquent
Laravel Datatables order by relationship column does not work

I have one User who can be assigned to many Company. I'm trying to render a table using Laravel Datatables &…

php laravel-5 datatables eloquent yajra-datatable
Laravel 4 - Eloquent. Infinite children into usable array?

I've got a categories table. Each category can have an optional parent (Defaults to 0 if no parent). What I want …

php parent-child laravel laravel-4 eloquent
Laravel upsert operations with Query Builder

In one of the my worker scripts to store aggregate counts based on some metrics, I am not using Eloquent …

laravel laravel-5 eloquent query-builder laravel-query-builder
Get Laravel Eloquent Collection from raw query

I'm using Laravel 5 and I have a table of users, and two tables 'clients' and 'employes' which contain relations between …

php mysql laravel-5 eloquent query-builder
Switch db connection dynamically

For several console commands, I have the need to change databases so all my eloquent commands and queries run on …

laravel eloquent codeception
How to setup conditional relationship on Eloquent

I have this (simplified) table structure: users - id - type (institutions or agents) institutions_profile - id - user_…

laravel eloquent relationships