Ich habe ein Problem beim Abrufen von Modell mit injizierten Eloquent in Controller-Methode - es findet kein Modell mit ID in URL. Ich erinnere, dass ich in einem anderen ControllerEloquent Modellinjektion in die Methode gibt null zurück
geändertDB::setFetchMode(PDO::FETCH_ASSOC);
dd ($ Infrastruktur) liefert nur Metadaten über Modell:
Infrastructure {#257 ▼
#table: "infrastructures"
#fillable: array:10 [▶]
#connection: null
#primaryKey: "id"
....
}
Meine Controller-Methode:
public function show(Infrastructure $infrastructure)
{
$card = [];
$card['name'] = $infrastructure->name;
$card['id'] = $infrastructure->id;
$card['type'] = "infrastructure";
$card['items']['manufacturer'] = $infrastructure->manufacturer;
$card['items']['type'] = $infrastructure->infrastructuretype()->first()- >name;
$card['items']['kind'] = $infrastructure->kind()->first()->name;
$card['items']['serial'] = $infrastructure->serial;
$card['items']['more info'] = Crypt::decrypt($infrastructure->long_desc);
$title = 'Infrastructure details ';
$warranty_left = $infrastructure->warranty_date > $infrastructure->purchase_date ? (new Carbon($infrastructure->warranty_date))->diffInDays(new Carbon($infrastructure->purchase_date)) : 0;
return view('infrastructure.show', compact('infrastructure', 'card', 'title'));
}
Meine Routen:
Route::model('infrastructure', 'App\Infrastructure');
Route::group(['middleware' => 'auth'], function() {
Route::resource('infrastructure', 'InfrastructureController');
get('infrastructure/{infrastructure}/logs', [
'uses' => '[email protected]'
]);
resource('infrastructuretype', 'InfrastructureTypeController');
Route::get('auth/logout', 'Auth\[email protected]');
});
nein, immer noch das gleiche –