#### Category : sql

I have a column start_time of type date and a column duration_temp of type Integer and I made a new column duration of type timestamp I want to fill duration column with those values: only the date without hours, minutes and seconds from start_time and add the value of "duration_temp" as minutes to this date. ..

I am trying to insert data to a pivot table order_serrvice using arrays I follow this code: https://blog.quickadminpanel.com/master-detail-form-in-laravel-jquery-create-order-with-products/ OrderController: $order= Order::create($data); $services =$request->input(‘services’, []); $quantities =$request->input(‘quantities’, []); for ($service=0;$service < count($services);$service++) { if ($services[$service] != ”) { $order->services()->attach($services[$service], [‘quantity’ =>$quantities[$service]]); } } the Blade Page: <tbody> <tr id=’addr0′> <td>1</td> <td> .. Read more I have a model Survey which is related to hasOne another model Installation which is related to hasMany another model Assignment. So i defined a hasManyThrough relationship like this public function assignments() { return$this->hasManyThrough(Assignment::class,Installation::class); } I want to write a query to fetch any Survey where the Assignments associated with the survey does not ..

Hi respected community members, I am trying a query to fetch records from two tables and order by the latest record but still no luck. Basically, I have two tables. one is donations and second one is recurring_donation_invoices.donations table have a field type which can be onetime or recurring.if the donation is of type onetime ..

Good Day, I do have 2 tables loan_account_installment and loan_account_installment_repayment related to each other. If repayment was made row will be created at loan_account_installment_repayment. What I want to happen is to deduct the payment made on loan_account_installment_repayment on loan_account_installment table. Unfortunately Im having an error. Call to undefined method stdClass::update(). By the way this is ..

ErrorException Undefined index: service_id I Creat an application that has an order the order_services table is a pivot table of orders and services I dont know from whare I take the index service ID and how can I fix this issue?? here is the code: Order Controller $order= Order::create($data); $services[] =$request->serviceOrders; if ($request->serviceOrders) { .. Read more I have a categories table where categories have a parent mentioned within same table as in below screenshot I want to implement self join in Laravel using Eloquent where parent category is mentioned in a saperate col: Raw Sql Query: DB::select("SELECT c.id, c.name, parents.name AS Parent Category Name FROM product_categories AS c LEFT JOIN product_categories .. Read more Inside a Laravel SQL migration that is run for several databases, I would like to do a filter to have the migration only be executed in case the database name is containing a keyword. Here is what I have tried but I am getting some syntax errors when running it. (I have never used PHP .. Read more I’m a front-end dev who ended up having to work on backend. I know Node but this is Laravel 5.5. Anyways, I’m making a query to retrieve runs, looking like this return$runs = DB::table(‘runs’) ->join(‘users’, ‘runs.user_id’, ‘=’, ‘users.id’) ->join(‘statuts’, ‘runs.statut_id’, ‘=’, ‘statuts.id’) ->join(‘machines’, ‘runs.machine_id’, ‘=’, ‘machines.id’) ->join(‘projet_run’, ‘runs.id’, ‘=’, ‘projet_run.run_id’) ->join(‘projets’, ‘projet_run.projet_id’, ‘=’, ‘projets.id’) ..

I have a bit of an architecture problem with my website. My website has submissions, and submissions have comments. Comments have upvotes and downvotes. You can also cancel your upvote or downvote. Exactly like reddit.com The way I register votes right now, the user votes, and then on the front end that vote is cached ..

I can’t wrap my head around this. I have three tables (abbreviated): *images* id | label | … *keywords* id | label | … *image_keyword* image_id | keyword_id And I have their many to many relations defined in the models: *Image.php* public function keywords() { return $this->belongsToMany(Keyword::Class); } *Keyword.php* public function images() { return$this->belongsToMany(Image::Class); } At one point I ..

I have multiple tables, which all hold different transaction data, here is an example: $q1 = DB::connection(‘mysql_live’)->table(‘transactions_vk’)->where(‘user_id’,$userid)->where(‘amount’, ‘!=’, ‘0’)->where(‘payed’, ‘Yes’) ->select(‘type’, ‘id’, ‘package’, ‘payed’, ‘amount’, ‘date_modified as date_added’, ‘payed as chargeid’)->get(); $q2 = DB::connection(‘mysql_live’)->table(‘transactions_stripe’)->where(‘user_id’,$userid)->where(‘amount’, ‘!=’, ‘0’)->where(‘payed’, ‘Yes’) ->select(‘type’, ‘id’, ‘package’, ‘payed’, ‘amount’, ‘date_added’, ‘charge_id as chargeid’)->get(); $total1 =$q1->merge($q2); I query them all .. Read more I have been trying to install a system to my local MAC via MAMP, I just recently updated the Database connection not configured error but not upon making the changes to the right configuration I got another error SQLSTATE[HY000] [2002] Connection refused. Error goes as follows : SQLSTATE[HY000] [2002] Connection refused (SQL: select active_template from .. Read more the request array has many user id i want to select all the emails related with these ids but the result show me the email of first id an request array public function ActionUserPush(Request$request) { $data =$request->user_id; $value = DB::table(‘users’)->where(‘id’,$data)->pluck(’email’); dd($value); } Sourc.. Read more I need to validate that a booking doesn’t overlap in date and time with an existing booking and return and error if a booking is overlapping an existing booking. This is the code I have right now but it isn’t working, and when I make another booking that overlaps an existing booking, it is still .. Read more Currently working on getting my head around the ordering of things, not even with laravel at first, but sql. Though the end goal is to use eloquent. There are 2 conditions for the rows that need to be excluded. If I’m fetching the rows from TableA.. 1) TableA with the column status_id (or TableC.id) has .. Read more Basically I am trying to find a way to update the vehicle’s booking status associated with the client_drivers_license_number after its matched to a variable I will input on my laravel project (123456789 below). I am not sure how I can make an update with values matching from mulitple tables so my best attempt is below .. Read more the product will be added into the cart but cart due to image error the card will not be shown. Here is my cart.blade.php file. @foreach(Cart::instance(‘cart’)->content() as$item) <li class="pr-cart-item"> <div class="product-image"> <figure><img src="{{asset(‘assets/images/products’)}}/{{$item->model->image}}" alt="{{$item->model->name}}"></figure> </div> <div class="product-name"> <a class="link-to-product" href="{{route(‘product.details’,[‘slug’=>$item->model->slug])}}">{{$item->model->name}}</a> </div> <div class="price-field produtc-price"><p class="price">${{$item->model->regular_price}}</p></div> <div class="quantity"> <div class="quantity-input"> <input type="text" name="product-quatity" value="{{$item->qty}}" data-max="120" .. Read more Here is my mysql query select (SELECT count(distinct(userID)) from user where role_id = ‘1’) as user, (SELECT count(distinct(member)) from members where role_id = 1 as member, Sourc.. Read more When I foreach all$data in my blade like @foreach($data as$d), when I use $d->text is returning the ‘text’ from the topics.text not from table replies.text public function ShowReplies($userid) { $data = DB::table(‘replies’)->join(‘topics’, ‘topics.id’, ‘=’, ‘replies.topic’)->where(‘topics.type’, ‘=’, 3)->where(‘replies.isPostDeleted’, ‘=’, 0)->where(‘replies.player’, ‘=’,$userid)->orderBy(‘replies.id’, ‘desc’)->get(); return view(‘replies’)->with(‘data’, $data); } Sourc.. Read more Is there anyone knows the easiest way to create multiple authentication for Laravel. Like I have 3 users for my own project now admin, renter and rentee. Anyone can give me idea. Thanks, Sourc.. Read more I have a table with two date fields: reservation_begin booking_end I want to know the reservations that occupy me from August 25th to August 31st. In the select query I have: Booking::select (‘id’, ”name’, reservation_begin’, ‘reservation_end’) ->whereDate(‘reservation_begin’, ‘>=’,$startDate) ->whereDate(‘reservation_end’, ‘<=’, $endDate) ->get(); I will NOT find the record in the database if:$startDate = ..

I’m new to Eloquent and Laravel. I tried multiple syntaxes but I can’t find a way to make it work. Here is the query I would like to convert : SELECT category, SUM(amount) AS total_cat FROM expenses GROUP BY category ORDER BY total_cat DESC And here’s my Model for the "expenses" table : class Expense ..