Hallo Leute, ich bin neu in PhP und Laravel. Ich möchte eine Join-Abfrage in Laravel verwenden und habe den folgenden Code geschrieben, aber es gibt mir einen Fehler.Laravel Join Abfrage
$data = DB::table('employees')
->join('contact_details', 'employees.id', '=','contact_details.employee_id')
->join('education', 'employees.id', '=', 'education.employee_id')
->join('addresses', 'employees.id', '=', 'addresses.employee_id')
->select('employees.first_name','employees.id','employees.gender','education.id','education.school','education.subject','addresses.village')
->where('employees.id', '=',$id)
->get();
return "$data";
und der Fehler ist
ErrorException in ProfileController.php line 66:
Array to string conversion
in ProfileController.php line 66
at HandleExceptions->handleError('8', 'Array to string conversion', 'E:\xampp\htdocs\djiafg\app\Http\Controllers\ProfileController.php', '66', array('id' => '72', 'data' => array())) in ProfileController.php line 66
at ProfileController->view('72')
at call_user_func_array(array(object(ProfileController), 'view'), array('id' => '72')) in Controller.php line 80
at Controller->callAction('view', array('id' => '72')) in ControllerDispatcher.php line 146
at ControllerDispatcher->call(object(ProfileController), object(Route), 'view') in ControllerDispatcher.php line 94
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
Veröffentlichen Sie Ihre Fehler zu in Frage, und entfernen Sie das zusätzliche geklam- mert von '($ id)' dh '-> where ('employees.id', '=', $ id)' –
@Nazir Noori: Es scheint, $ ID wäre mit Klammern, aber Ihr Fehlerbericht kann gut die tatsächliche Situation klären. – naf4me
Buchen Sie den Fehler nicht. Das wäre zu einfach. – Strawberry