Problem with method "show" in my controller

Posted 1 year ago by vasiliy_v

Hello! I began to study laravel and 3 days can not understand what the problem is.

The situation is:

I created the model, migration and controller by command: "php artisan make:model autotradecatalogs -a"

migration: public function up() { Schema::create('autotradecatalogs', function (Blueprint $table) { $table->increments('id_autotradecatalogs'); $table->integer('id'); $table->string('name'); $table->timestamps(); }); }

I created primitive templates: -resources/views/autotradecatalogs -create.blade.php -index.blade.php -show.blade.php

model: class autotradecatalogs extends Model { protected $table = "autotradecatalogs"; protected $primaryKey = 'id_autotradecatalogs'; protected $fillable = ['id', 'name']; }

routes: Route::resource('autotradecatalogs', 'AutotradecatalogsController');

Method show in AutotradecatalogsController:

/**

  • Display the specified resource.
  • @param \App\autotradecatalogs $autotradecatalogs
  • @return \Illuminate\Http\Response */ public function show(autotradecatalogs $autotradecatalogs) { dd($autotradecatalogs); // return view('autotradecatalogs.show', ['catalog' => $autotradecatalogs]); }

Get url in browser http://test.ru/public/autotradecatalogs/1 Result of the dd function from the show method

autotradecatalogs {#189 ▼ #table: "autotradecatalogs" #primaryKey: "id_autotradecatalogs" #fillable: array:2 [▶] #connection: null #keyType: "int" +incrementing: true #with: [] #withCount: [] #perPage: 15 +exists: false +wasRecentlyCreated: false #attributes: [] #original: [] #changes: [] #casts: [] #dates: [] #dateFormat: null #appends: [] #dispatchesEvents: [] #observables: [] #relations: [] #touches: [] +timestamps: true #hidden: [] #visible: [] #guarded: array:1 [▶] }

The problem is that the show function does not receive an element

What am I doing wrong?

Please help, I really want to understand this framework.

Please sign in or create an account to participate in this conversation.