Skip to content

Tag: laravel

how join laravel tables to get non intersected data

in my Laravel app I have 3 tables : users, documents and type_documents, the user have multiple documents and document have one type_document I want select the types that are not used in documents table for the current user with eloquent I try with this, but it give me the used type_documents : I use Laravel version 8 Answer Have

Laravel 9 – implode() and whereIn

Hello i’m using query builder in my laravel app. I’m trying to use the implode() method from query builder. So for example i expect a string composed from : ‘ 2,3,4… ‘ I have to use this string in next query where i use the raw query IN (‘value’, ‘value’) I’m trying to wrap those IDs in to single quotes

retrieve rows based on parent relationship

This is the query: I am trying to get all the checklist items that have the same item_stock_id from the checklists that have the same ambulance_id. However, the query from above is not working, showing me this error: Below is the ChecklistItem model: And this is the Checklist model: Answer To constrain the eager load you need to specify the

SQLSTATE[22007]: Invalid datetime forma

I try to save some data that it brings me from my view, which is a table, but I don’t know why it throws me that error with the insert. result of insert this is my view: table of view this is my controller: Answer id_tipo_venta seems to be an empty string which is apparently not valid. You can try

How to use this laravel query builder for this SQL Query

I have this query: SELECT `topic_posts`.*, `users`.`id` AS `adminID`, `users`.`name` as `adminName` FROM `topic_posts` INNER JOIN `topics` ON `topics`.`id` = `topic_posts`.`topic` INNER JOIN `users` ON `users`.`id` = `topic_posts`.`player` WHERE `users`.`playerAdminLevel` > 0 AND `topics`.`type` = 0 GROUP BY (`topic_posts`.`id`) And I want to use in Laravel, something like: $result = DB::table(‘topic_posts`)->join..etc And also, to use ->paginate(20) How can I do

Laravel onDelete(‘cascade’) does not work

My Tables: I am getting following errors when I try to delete support_categories Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails Answer You just write foreign key in wrong order. Instead of: Write: or you can use casadeOnDelete():