Can’t get a list of streets to create a card [closed]

public function create() { $streets = street::get(); return view(‘dashboard.house.created’); } public function store(Request $request) { $this->validate($request, [ …

How to use print all comments for respective posts using relationship in Laravel 8

I am trying to print all comments per post using the relationship, Error: Property [comments] does not exist on the Eloquent builder instance. Post Model class WorkTravel extends Model { use …

How to get all the people in table 1 without getting the people who have me as parent_id in table 2?

I’m writing this post because I have a problem with my relationships on Laravel. Here is the structure I currently have: 1st table: – id – name – … 2nd table : – parent_id – child_id knowing that …

Eloquent Laravel multiple like where and where clause

I have the below Mysql query that works. mysql: select * from operatories op left join locations al on op.location = al.location where op.opname like ‘%NP%’ or op.opname like ‘%OPEN%’ and al….

How to get sum and separate the total per Id in laravel

This is my query in my controller public function show($id) { $Days = DB::table(‘payroll_monthly_attn_project’)->where(‘payroll_monthly_id’,$id)->where(‘assign’,’PAINTING’) …

Eloquent complex relationship for a chat message system in laravel

I am writing a chat system and I have the following tables: chat_conversations: id, name chat_messages: id, chat_conversation_id, message, deleted_at chat_message_user: id, chat_message_id, user_id, …

Laravel – Filtering a Model by Condition between “a Field and Its Relationship Model Field”

I have these two models with one to one relationship. “products” id name minimum_required “product_data” id product_id price oh_hand I want to get the count of product_data …

Get the id of the stored items after using Laravel insert eloquent

I stored an array in the database using the Laravel insert Eloquent method as below: $newTags = [ [ ‘name’ => ‘tag1’ ], [ ‘name’ => ‘tag2’ ], ]; if (sizeof($…

Mysql where clause on multiple fields which one might be null

In my products table, I have 2 columns: price and discounted_price in which discounted_price is null most of the time unless there is a promotion for that product: +—-+——————–+——-+–…

Laravel: prevent updated_at from filling on record creation

In recent versions of Laravel >=5.8 I’ve noticed when you create a new model record, the column updated_at from table is filled automatically with the same value as created_at. While it makes sense …