skip to Main Content

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 – How to add attribute to Eloquent collection?

In Message.php model: public function getAudioUrlAttribute() { return Storage::disk('public')->url('audio/' . $this->audio); } in MessageController.php $messages = Message::select('id', 'role', 'content', 'audio')->get(); $messages = $messages->map(function($message) { return $message->only('id', 'role', 'content', 'audio_url'); }); return ['messages' => $messages]; how to add audio_url to the…

VIEW QUESTION

Laravel join in HasMany relationship

I have three models: EmailTemplate EmailSend Attendee An EmailSend references both an Attendee and an EmailTemplate: class EmailSend extends MyBaseModel { ... public function attendee() { return $this->belongsTo(AppModalsAttendee::class); } public function template() { return $this->belongsTo(AppModalsEmailTemplate::class); } ... } and associated…

VIEW QUESTION

Laravel – Attempt to read property "id" on bool (View: D:websiteImageresourcesviewslayout.blade.php), variable not transfering to view

I keep encountering this error on Laravel 8 with PHP 8. Im grabbing the id from the view like so: <li><a href="category/{{$catego->id}}">{{$catego->categories}}</a></li> This then goes to web.php like so: Route::get('category/{id}', [UserController::class, 'categories']); It then goes to the categories function like…

VIEW QUESTION
Back To Top
Search