Laravel SQL Query. Help me

I have a table name “Offers” with 3 (public, request, private ) types of data. Now I want to show directly to the user end public and request offers. and private offers not be shown but when admin …

Laravel skip results if they are found in previous query

I’m querying my DB twice to get some items into the header of the page and some bellow the header. I want to avoid duplicates in these two queries, currently I do this by adding a skip method to …

How to make this type of query in Laravel?

This is the sql query but how can I do it in laravel? SELECT id FROM clientes where email is null and phone is null and id in(SELECT DISTINCT(cliente_id) FROM reservas WHERE dia < now()) This is …

ELOQUENT – Calculating difference of datetimes in where-clause

I am trying to check if the difference of two columns in my database is under a given amount of years – meaning DATETIME – BIRTHDATE where(date_diff((strtotime(‘…

Why is this not saving to the database?

I’m trying to save a new product into the database, this product has exportation factors which i’m also trying to save, why is this not working? if ($request->has(‘export_factors’)) { $…

Laravel save a input with extra value data

i am trying to save a input value from a time data: On mi example i am saving the data 3:30 for a calendar form, but to use on the calendar i need save …

Posting Coordinates to Database from Google Maps API

Edit: I solved the problem. Leaving it up in case someone needs something similar in the future. I am trying to use google map api to get coordinates and save the information in a database. If the …

Laravel Query. Obtain in Eloquent only totals > 0

I have this query: public static function totalByAgent(int $agentId) { return PropertyListing::select( DB::raw(‘SUM(property_listing.rental) as rental’), DB::raw(‘SUM(…

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); …