У меня проблема с выборкой модели с использованием инъецированного Eloquent в метод контроллеров - он не находит модель, использующую id в URL. я помню, что я изменил в другой контроллерEloquent model injection in method возвращает null
DB::setFetchMode(PDO::FETCH_ASSOC);
дд ($ инфраструктура) возвращает только метаданные о модели:
Infrastructure {#257 ▼
#table: "infrastructures"
#fillable: array:10 [▶]
#connection: null
#primaryKey: "id"
....
}
Мой контролеры метод:
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'));
}
Мои маршруты:
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]');
});
нет, все тот же –