skip to Main Content

How to add object in laravel relationships

How to add extra object in laravel relationship when fatch data. Here is my code: $list = new self; $list = $list->where('uuid', $uuid); $list = $list->where('user_id', $user->id)->orWhere('to_user_id', $user->id); $list = $list->with(['touser' => function($q1) { $q1 = $q1->select('id', 'name', 'email', 'user_image',…

VIEW QUESTION

How to get data from Laravel relation

I have 2 models: publictxt and Pulicetxtrecive publictxt model: class Publictxt extends Model { protected $fillable=['sender','reciver','description','useridseen']; public function Publictxtrecives() { return $this->hasMany(Pulicetxtrecive::class,'publictxt_id', 'id'); } } Pulicetxtrecive model: protected $fillable=['publictxt_id','user_id','seen']; public function publictxts() { return $this->belongsTo(Publictxt::class); } I want to get…

VIEW QUESTION
Back To Top
Search