Top "Eloquent" questions

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

How to set a default attribute value for a Laravel / Eloquent model?

If I try declaring a property, like this: public $quantity = 9; ...it doesn't work, because it is not considered an "attribute", …

php model laravel laravel-4 eloquent
Laravel Eloquent Select CASE?

Is there anyone with experience in PHP & Laravel Eloquent who can help me resolve this statement? I'm trying to …

sql select laravel case eloquent
How to get all rows (soft deleted too) from a table in Laravel?

To get all rows from a table, I have to use Model::all() but (from good reason) this doesn't gives …

php laravel laravel-4 eloquent
Laravel: How to get last N entries from DB

I have table of dogs in my DB and I want to retrieve N latest added dogs. Only way that …

php database laravel laravel-4 eloquent
Laravel Model with Two Primary Keys update

I'm trying to update Model which has two primary keys. Model namespace App; use Illuminate\Database\Eloquent\Model; class Inventory …

php laravel laravel-5 eloquent composite-primary-key
How to filter a pivot table using Eloquent?

I'm using a pivot table on the project I'm working with to get works of users. E.g: User::find(1)…

laravel laravel-4 filtering eloquent pivot-table
Laravel join queries AS

Any way of defining an AS for a query?? I have tried the following: $data = News::order_by('news.id', …

php mysql pagination laravel eloquent
Laravel Custom Model Methods

Whenever I add additional logic to Eloquent models, I end up having to make it a static method (i.e. …

php laravel laravel-4 eloquent facade
Saving related records in laravel

I have users, and users belong to a dealership. Upon user registration, I'm trying to save a new user, and …

laravel laravel-4 one-to-many eloquent
Laravel attach pivot to table with multiple values

Background I'm creating a database revolving around food allergies and I have a many to many relationship between foods and …

laravel laravel-4 eloquent pivot-table