Answer the question
In order to leave comments, you need to log in
How to correctly display an empty object in laravel?
Hello. I'm starting to learn OOP and Laravel.
I want to select an object from the database:
$worker_info = DB::table('workers')->select( DB::raw(' workers.id as wid, workers.first_name, organizations.name as org_name' ) )
->leftJoin('organizations', 'workers.organization_id', '=', 'organizations.id')
->where('workers.id', $worker_id)
->first();
dump($worker_info);
{#194 ▼
+"wid": 1
+"first_name": "Петр"
+ "org_name": "Рога и копыта"
}
{{ $worker_info->wid}}
{{ $worker_info->first_name}}
{{ $worker_info->org_name}}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question