thai6070
thai6070

Reputation: 31

How to use route in Laravel 5.2 with suffix

I try

 $suffix = '.test';
 Route::get('article/edit/{name?}'.$suffix, ['uses' => 'ArticleController@edit', 'as' => 'Edit']);

and it works well. Then I add in auth group, $name always returns with $suffix (for example: $name = 'abc.test')

 Route::group(['middleware' => 'auth'], function () {
 global $suffix;
       Route::get('article/edit/{name?}'.$suffix, ['uses' => 'ArticleController@edit', 'as' => 'Edit']);
});

But I want it returns $name = 'abc'; Where am I wrong?

Upvotes: 1

Views: 2787

Answers (1)

Jordan Plamondon
Jordan Plamondon

Reputation: 345

What if you do?

Route::group(['middleware' => 'auth'], function () {
   global $suffix = '.test';
   Route::get('article/edit/{name?}'.$suffix, [
      'uses' => 'ArticleController@edit',
      'as' => 'Edit'
   ])->where('name', '/[^a-zA-Z0-9_\.-]/');
});

Upvotes: -1

Related Questions