BelongsToMany filter considering only the latest record

Hello, I have the following tables: Contents, Statuses and Content_Statuses where this is a pivot table for the other two. I need to...
02

How does the 'associate' method work behind the scenes?

I am using the spatie/laravel-permission in my project. I am hiding some routes behind their middleware to avoid unauthorized users to...
01

FirstOrCreate does not update properly

I have this use case : Class AdPrices with protected $fillable = ['group_id','country_code']; $ad_price_record = \AdPrices::firstOrC...
07

how to get the second one?

hi i know to use ->first() method be i whant to get the second and do a comper with the first in the results how i can do that witout to...
05

Not getting distinct result.

The distinct should be only on email $invitelist = Invitelist::select('email', 'companylist_id')->where('unsubscribe', 0)->dis...
03

Query with relation

Heyyo, I have the User public function buildings() { return $this->hasMany('MyApp\Building'); }...
01

Fetching and Displaying Customer Orders on Page

There are 3 tables. First one is orders: After example order:...
07

Remove ManyToMany relation by additional column value

How remove row from pivot table by additional column value? My tables: iiko_products id name...
02

DB Schema - Conditional Many To Many?

Hey! I need to store the venues of a given team for a sports league statistics project. A...
03

filter many to many relation result by column in pivot table

I have Employee: id name and Company: id name and company_employee :...
13

Cant understand Eloquent distinct

Hi i have a function that filter my users and now i want to show me unique users by first name but when i use this code show me only the first name...
08

Unable to Update Record

Hi, I have the following code in Edit Form, <form action="/products/{{$product->id}}/update" me...
12

One to Many and Inverse 'Class not found.'

Hi, I'm trying to create and query a One to Many relationship in Eloquent and I keep getting an error stating 'Class [Realm] not found.'...
04

Query to Eloquent model

I have this query: SELECT authors.name, COUNT(books.id) books_count FROM books LEFT JOIN authors on authors.id = books.author_id GRO...
06

Union with pagination - Laravel 5.6

Hi Guys, How can I add pagination on a union. I got an error Cardinality Violationwhen using union with ->paginate()...
11

Accessing and updating pivot table fields with Laravel 5.5

I have 2 distinct tables and a pivot table : sectors id admin_id created_at updated_at deleted_at langs id...
02

Trailing data error in Carbon data from postgresql

Hi, outputing data from created_at field laravel 5.4/postgresql 9.4 I got error: InvalidArgumentException in Carbon.php line 582: Trailing d...
03

Is it possible override the delete method?

Here's what I'm trying to do: I have a class called by controller that delete a item: public function destroy($id) { $s...
05

Ordering from 2017 - 2018 months

$qualityClaims = QualityClaim::select( DB::raw('count(MONTHNAME(created_on)) as `count`'), DB::raw('MONTHNAME(created_on) month'))...
02

Load Model Maps on Demand

Context: My current Laravel Project has some legacy Views ingrained in reports. The original developer used a lot of static coded Models (open ch...
02