Top "Eloquent" questions

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

How is a pivot table created by Laravel?

In Laravel 4, when working with many-to-many relationships as described in the 4.2 docs, how can I actually get Laravel to create …

laravel pivot-table laravel-4 eloquent
How to reload/refresh model from database in Laravel?

In some of my tests, I have a user model I have created and I run some methods that need …

php laravel unit-testing laravel-4 eloquent
Laravel Eloquent ORM - Many to Many Delete Pivot Table Values left over

Using Laravel, I have the following code $review = Review::find(1); $review->delete(); Review has a many to many relationship …

laravel orm many-to-many eloquent
hasMany vs belongsToMany in laravel 5.x

I'm curious why the Eloquent relationship for hasMany has a different signature than for belongsToMany. Specifically the custom join table …

php laravel eloquent
Laravel firstOrNew how to check if it's first or new?

I'm using Laravel's function firstOrNew() to create a new user or find and update an existing one. How can I …

php laravel laravel-5 eloquent
Why soft deleted entities appear in query results?

I am trying to implement soft deleting concept. Here is my object: class Post extends Eloquent { /** * The database table used …

laravel laravel-4 eloquent soft-delete
Laravel Eloquent OR WHERE IS NOT NULL

I am using the Laravel Administrator package from frozennode. Long story short, I'm running into issues when displaying results that …

php sql laravel eloquent administrator
Laravel timestamps() doesn't create CURRENT_TIMESTAMP

I have a migration that has the timestamps() method, and then I have a seed to seed this table. Schema::…

php laravel eloquent laravel-migrations laravel-seeding
Laravel Eloquent: Return Array key as the fields ID

When I execute a query via Laravel's Eloquent ORM, I want to get the row ID as the Array result …

php laravel eloquent
How to define and use JSON data type in Eloquent?

How can I define JSON data type that is provided in pgsql 9.4 in Laravel 5? I need to define data type, …

laravel-5 eloquent postgresql-9.1 laravel-5.1