i have problem with one to many relation ship! So im try to sum product prices so here is what i mean: Model: Product.php Model: Orders.php So i want make smth like this: $var->product->price->sum(); My database if it needed: Orders: id product_id|user_id| |-|———-|——-| |…
Tag: laravel
Laravel how to pass data from controller to modal dialogue using ajax
I have items and for every item there are related items, so when I open the homepage it shows all item, when I want to click on any item, ajax will pass this item id to controller to get the related …
Laravel eloquent mutators not work on update data
I have in my model accessors and mutators for hash/rehash data in database table fields. For example: public function setFullNameAttribute($value) { $this->attributes[‘full_name’] = Helper::…
In Macroable.php line 96: Method body does not exist
I’m fairy new to Laravel. I have created a migration file named: create_notes_table and when running command php artisan migrate this error message pops up. my create_notes_table file content Answer As the error message states there is no body() method in migrations. https://laravel.com/docs/8.x/migrati…
How to use on Laravel guard for the main domain and another for the subdomains
I’m building a multi-tenant application where the idea is the admins access through the main domain (http://myapp.app) to the dashboard and the regular users access to another dashboard on their …
how to load different .env file for multiple domain in single laravel app?
I would like to access single laravel application by multiple domain. For routing i have used laravel route pattern for eg. Now .env for each domain i have replaced config variable value inside AppServiceProvider.php register method: but still i am not getting correct domain url using url(config(‘app.ur…
laravel 5.5 schedule:run cron job not working in cpanel
I’m have a laravel5.5 project up on shared hosting and trying to run cron job to execute the command “schedule:run” but it just won’t execute I think I’m writing the command wrong: where prototype in the name of my laravel project. the command works in this directory using ssh. p…
Laravel 5.6 aws cloudwatch log
Upgraded laravel from 5.4 to 5.6. Laravel removed $app->configureMonologUsing since version 5.6 the tutorial from aws not applicable anymore. https://aws.amazon.com/tw/blogs/developer/php-application-logging-with-amazon-cloudwatch-logs-and-monolog/ anyone can advise me where to migrate the logic inside $ap…
Laravel storage link won’t work on production
I’m using storage_path to save my images and I symbolic my storage folder to public_html On the local everything works fine, when I upload an image it will upload in storage folder and link of it will appear in public folder but since I moved to live host and production mode my images will upload in sto…
Accessor for relation objects in Laravel
this is my Category model: and when i call it in route for get all object like this: it seems accessor not work and i can’t get ‘Foo’ in category’s media object Answer You can use withDefault(): When there is no result, it returns a Media instance with the given attributes.