Multiple Joins with Where's

I have a query that I can't get to work. It works if I take out the second join with instructors $SemesterCourse = DB::table('coursesemester')...

Query a many to many relationship table

Good afternoon, Basically I have 2 models related with many to many. Species that might or might not be present on differents zones of different maps. Table e...

attach needs to be followed by load?

For this example, consider models User and Comment with a many-to-many relationship. In the user model: class User extends Model { public function...

Undefined Builder::links() when paginating many to many relation

Good evening, while this bit on my controller works perfect: public function info($coleccao_tematica) { $coleccaoTematica = ColeccaoTemat...

Pagination of data from a relation

$galeriaInfo = Galeria::where('slug', 'LIKE', $slug) ->with(['multimedia']) ->withCount('multimedia')...

Select Query Posts with Likes

Hello , I have a question , I am developing a website like a facebook . It will have POSTS and a User can LIKE those posts , So a user can search all those posts , i...

Model Alias - 'Members' Vs. 'Users'

I've a users table that contains to all the registered users of the site. There's a User model to represent them. Now I'm build a 'Groups...

How to get high count columns from table

i have a hashtag table now i want to get 5 highest used hashtags $table->increments('id'); $table->string('tag', 200);...

Best way to dynamically edit a model

Let's say you have a pretty large model and in various places you might update different parts of that model... I feel like your options are to create a controller f...

ResourceCollection throwing an 'Undefined Property ($map) Error'

I'm pretty new to the Resources stuff... I'm getting an Undefined property: Illuminate\Database\Query\Builder::$map error thrown when I try to implement this c...

eloquent (using model relations)

Inside my models I use for example often this way: public function notitications() { return $this->hasMany('App\UserNotification'); } public function...

select only some columns from a nested query

I have a nested query where in addition to what I have now ( and works) I also want to get only some columns from user $users = User::whereHas('contacts'...

What's the threshold for database queries to start worrying about performance?

The new functionality I'm developing for a site is already crossing 15 queries per page - after deploying eager loading. If I add another functionality - it's likely to cro...

Has Many Through Parent scope

I can do a HasManyThrough and add on a query scope like this: $user->hasManyThrough('Comments', 'Post', 'owner_id')->approved() The approved() scope get...

Many to many ordeal

I am familiar with a many to many relationship and know its fundamentals. But I am struggling with something. I have a list of categories in a form where a user can tick/un...

ELOQUENT AND FOREIGN KEYS

Please i need help on how to execute foreign key and make reference back to the parent table from the child tables .. i really would appreciate your help....

Can I sort the groupBy Collection keys?

Hi, I have a collection I wanted to group by a category, like so: $my_objects->groupBy(function ($item, $key) { if ($item->cate...

Unable to update record with composite Primary Key

Anyone know how to update a DB record that uses a composite Primary Key? I'm not having any issues creating and finding. I'm happy to share code if it would be helpful...bu...

data_set() a model - error Indirect modification of overloaded

I really have trouble to update nested json inside the database. $epreuve = App\Epreuve::where('live', true)->first(); data_...

Relationships between 3 tables

Hello, i have the following tables messages - id - user_id - message user - id likes - id - message_id - user_id User Model...
Create a New Discussion Button
Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels