在laravel中定义路线

时间:2017-12-12 10:54:29

标签: php laravel-5

我有这样的问题

Route::resource('essayanswers', 'EssayAnswerController');

EssayAnswer {#541 ▼
  #fillable: array:4 [▼
    0 => "user_id"
    1 => "essay_id"
    2 => "essay"
    3 => "content"
  ]
  #connection: null
  #table: null
  #primaryKey: "id"
  #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 [▶]
}

我已经在web.php中为此定义了路由,就像这样。

{{1}}

但是当我在EssayAnswerController中使用dd命令时,我得到了这样的输入。我无法访问essayAnswer的属性

如何在laravel中的web.php文件中为此定义路由?

1 个答案:

答案 0 :(得分:0)

根据文档

尝试this之类的内容
Route::resource('essayanswers', 'EssayAnswerController', ['parameters' => [
    'show' => 'essayAnswer'
]]);