Skip to content

Tag: laravel

Laravel cut amount from rows before sum

I have column in my table where it stores prices and I need to sum those prices, the issue is I need to cut specific amount from each row before sum them. Example I don’t want to just sum this numbers, what I need is cut 5000 from each row value and then sum the rest. So my total after

Change Primary ID in laravel Migration

I’m creating a table where I want to use the ID from this table “menu_items” to be added in another table Table one: menu_items Table 2 products My aim of doing this is that I can then create a relationship between the 2 tables as they have the same key? Is there a different approach I can t…

Laravel Auth:api will not persisting

I’m realizing platform web and app that work with Laravel 6 in back-end. I set auth web for platform web and auth api (with Laravel JWT) for the app. When I signin with app, Auth doesn’t persist and with subsequent calls I can’t to refresh the token nor to get user info. The code is below: r…

Laravel Route Link – Error Route not Defined

In my web.php containing my routes, I have the following Route: Which links to my Profile Controller I am linking to this controller with However, when I navigate to the page with this route set, I get this error However, the following code works fine with navigation when I switch from route to URL Why does U…

Laravel – How to query Eloquent relationship?

I have this models in Laravel-5.8: Then I have this Query in Employee controller function: How do I include where is_active = 1 from employee_types into the query in Employee: Answer You are looking for the whereHas method, querying for the existence of a relationship: Laravel 5.8 Docs – Eloquent &#8211…