skip to Main Content

Update one-to-many relationship in Laravel

I have a model Product which contains a list of Specification how can I easily update all the specifications in one-to-many relationship in Laravel 10? class Product extends Model { //... public function specifications() { return $this->hasMany(Specification:class); } } class…

VIEW QUESTION

laravel search in other table on json column by relation

i try make code for search and this is my code: $services = Service::query()->with('plans')->latest(); if ($request->service_name) { $services = $services->whereRaw("CONVERT(JSON_EXTRACT(name, '$.ar') using 'utf8') LIKE '%$request->service_name%' ") ->orWhereRaw("CONVERT(JSON_EXTRACT(name, '$.en') using 'utf8') LIKE '%$request->service_name%' ") ->orWhereRaw("CONVERT(JSON_EXTRACT(name, '$.he') using 'utf8') LIKE '%$request->service_name%' ");…

VIEW QUESTION

Laravel : Reaching nested relationship

Knowing the structure below, can I add a function to the Container class to get records directly with Container::with('records')->get() instead of Container::with('boxes.letter.records')->get() ? containers hasMany boxes hasOne letter hasMany records class Container extends Model { public function boxes(): hasMany {…

VIEW QUESTION
Back To Top
Search