Laravel路线问题

时间:2017-10-25 11:20:32

标签: php laravel

web.php

Route:resource('person','PersonController');
// In Actually => Person Data Edit  route:get('person/{id}/edit','PersonController@edit');

PersonController.php

public $adressInformation = '';

  public function edit($id)
  {
      $persons = Person::find($id);
      //TODO...
      $this->adressInformation = $person->ADDRESS;

  }

  public adressInformation(){

       // TO DO vs 

       return $information;
  }

我想通过route =>写adressInformation;首先   那时route:get('person/{id}/edit','PersonController@edit')工作了   route:get('person/{id}/edit/adressinformation'写数据

我找到了问题的解决方案,但不能这样

public adressInformation($id){

       // TO DO vs 

       return $information;
}

1 个答案:

答案 0 :(得分:1)

您总是应该在资源路由之前定义自定义路由:

Route:get('person/{id}/edit/adressinformation','PersonController@adressInformation');

Route:resource('person','PersonController');