Can someone explain the difference between a ResourceCollection and JsonResource? In Laravel 6 docs you can generate 2 different types of resources… ResourceCollection and JsonResource. https://…
Tag: eloquent
laravel BelongsToMany pagination
i have 2 model 1 – category with parent and child class Category extends Model { protected $primaryKey = ‘id’; public $fillable = [‘slug’,’title’,’icon’,’parent_id’]; /** * Get the index name …
How to join two tables with a pivot table using Laravel?
I have these three tables: tbl_lista_contactabilidad tbl_equipo_postventaatc users ————————- ———————– —– id id id …
values are not inserting in profile table
use AppUserProfile; use AppPost; class User extends Authenticatable { use Notifiable; // protected $table = ‘user’; protected $primaryKey = ‘username’; protected $keyType = ‘…
Laravel 5.5 How to get eloquent relationship count?
I have three tables as define below User id name Post id text user_id Comments id text post_id This is User model User.php class User { public function post() { return $this-&…
How to build this Laravel Eloquent Query
I want to build a nested array from a simple table with Laravel Eloquent, but i couldn’t. So basically below is a snap shot of my table and this is the array I want to build
Access nested related objects with where clause in Laravel using Eloquent
I’m trying to get a list of tasks that are associated with a specific client, but there is no direct relation between a task and a client. I also need to filter those tasks based on task status and …
Laravel 6.11: Shopping cart HasMany::fisrt() in Accessor not working
EDIT: typos corrected (made while translating some of the code) I’m building a shopping cart with Laravel 6.11 (MAMP). I am getting a couple of errors that are driving me nuts. Please help! First I’…
Laravel group by change keys
Hi I have reservations and their start times. Now I need to raport it. $monthlyAmounts = Reservation::all() ->groupBy(function ($proj) { return cdate($proj->…
Call to a member function addEagerConstraints() on string
I want to calculate the average of the column of nested morph relation. Model Function public function trader_ratings() { return $this->morphMany(TraderRatings::class, ‘rateable’) ->…