Issues with Laravel groupBy
I am using Laravel 10. This is crm_details table: I need to count each status,. Also I need to consider parent_token with the same value as a single row. That means 2 rows have same `parent_token' then It will consider…
I am using Laravel 10. This is crm_details table: I need to count each status,. Also I need to consider parent_token with the same value as a single row. That means 2 rows have same `parent_token' then It will consider…
I have create a laravel object as per the documentation. Though when i am trying to get the value from it, it is throwing the error. Here is a sample code $user = USER::findOrFail(2990); print_r($user); This is throwing error. Please…
I have tried everything to get the data total of Jumlah Hadir, Jumlah Sakit, and Jumlah Izin there for every user. as a beginner I am very confused. For a clear view I want, you can see the image below:…
In my Setting model. I have a local scope that accepts $data array argument. The $data contains two keys group and property and any of them can be null as you can see in my query. public function scopeSettingFilters($query, array…
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%' ");…
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…
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…
I'm trying to write a query scope in Laravel Eloquent to get records only where the sum of a records relationship values is more than a value stored in a parent column. So for example I have: Table A id…
I am writing a Trait for Laravel eloquent models that enables "promotion" of input elements during create and update. The base trait looks like this: <?php namespace AppTraits; use IlluminateDatabaseEloquentBuilder; trait PromotesInputsDuringCreation { public static function doPromotion($attrs) { if (isset(static::$promotions)…
hello i want to upload image via laravel. but i got this Error message: Call to a member function getClientOriginalExtension() on string i put my code below and will appreciate you for solve this problem. i searched the problem and…