I have this query: public static function totalByAgent(int $agentId) { return PropertyListing::select( DB::raw(‘SUM(property_listing.rental) as rental’), DB::raw(‘SUM(…
Tag: laravel
SQL request with GROUP BY and SUM in Eloquent
I just want make a simple sql request in my laravel application. I’m not very comfortable with Eloquent aha. This is the SQL request I want to make with eloquent : select user_id, project_id, sum(…
Laravel collection how to return where no records and not by auth user
public function tasks(Request $request) { $user = auth::user(); $query = Task::query(); $query->with(‘User’)->with(‘task_type’); $q = $query->paginate($tasksPerPage); …
Is there effective way in laravel to select records from database and set them user_id?
I have to make laravel application that use database 100k+ records. I have table with columns: numer, date, segment, user_id. I am selecting records that I need with: $datetime = new DateTime(); $…
Convert Raw SQL ‘NOT’ IN (too slow) to Laravel Eloquent
I have a running script using Raw SQL in Laravel 5.3 controller which I found it slow and not secure ( as Raw ). If there any way to make it more effecient and convert it to eloquent or Query Builder …
Sum in Laravel Eloquent and Return on Page
I’m trying to get the location’s inventory value with the following eloquent query. It properly pulls up everything (location name, address, # of users, etc) except the inventory value which returns …
Laravel 5.8 / Mysql: Cannot delete or update a parent row a foreign key constraint fails
I am trying to setup my tables in my MySQL database and and I am currently creating migration files using Laravel 5.8. When I run a fresh migration with php artisan migrate all the migrations run …
Trouble deploying Laravel Passport with Google App Engine (GAE)
I have successfully deployed and maintained a Google App Engine + Laravel Project using Google Cloud SQL as a database. I’m using Cloud Build to deploy, however on manual deployment my problem occurs just the same. I’m trying to get the locally working Laravel Passport installation to work on Google App Engine. Laravel Passport needs to run php artisan passport:install
Mysql query for comparing price one to each other based on type
example table name | source_data | price_a | ——————————— name A | site_a | 40.00 | name A | site_b | 50.00 | name B | site_a | 30.00 | name B | site_b …
Model not returning value when one field used in select
I have a question with my if statement. I want to get check what is bigger than another price value. one value is saved in my database table and another one is getting with input value. but I wrote …