Laravel route questions

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;
  }

I want to write adressInformation via route => firstly route:get('person/{id}/edit','PersonController@edit') worked then route:get('person/{id}/edit/adressinformation' write data


I found a solution to the problem but can not it be this way

public adressInformation($id){

       // TO DO vs 

       return $information;
}

Upvotes: 1

Views: 52

Answers (1)

Dmitriy Doronin
Dmitriy Doronin

Reputation: 778

You always should defining your custom route before resource route:

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

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

Upvotes: 1

Related Questions