1 | <?php |
||
10 | class RouteServiceProvider extends ServiceProvider |
||
11 | { |
||
12 | /** |
||
13 | * This namespace is applied to your controller routes. |
||
14 | * |
||
15 | * In addition, it is set as the URL generator's root namespace. |
||
16 | * |
||
17 | * @var string |
||
18 | */ |
||
19 | protected $namespace = 'App\Http\Controllers'; |
||
20 | |||
21 | /** |
||
22 | * Define your route model bindings, pattern filters, etc. |
||
23 | * |
||
24 | * @return void |
||
25 | */ |
||
26 | public function boot() |
||
27 | { |
||
28 | 12 | // |
|
29 | Route::bind('linkHash', function ($hash) { |
||
30 | 12 | try { |
|
31 | return Link::where('hash', $hash)->firstOrFail(); |
||
32 | 12 | } catch (ModelNotFoundException $e) { |
|
33 | 12 | redirect('/')->send(); |
|
34 | } |
||
35 | }); |
||
36 | |||
37 | parent::boot(); |
||
38 | } |
||
39 | |||
40 | 12 | /** |
|
41 | * Define the routes for the application. |
||
42 | 12 | * |
|
43 | * @return void |
||
44 | 12 | */ |
|
45 | public function map() |
||
53 | |||
54 | /** |
||
55 | * Define the "web" routes for the application. |
||
56 | 12 | * |
|
57 | * These routes all receive session state, CSRF protection, etc. |
||
58 | 12 | * |
|
59 | 12 | * @return void |
|
60 | 12 | */ |
|
61 | 12 | protected function mapWebRoutes() |
|
67 | |||
68 | /** |
||
69 | * Define the "api" routes for the application. |
||
70 | 12 | * |
|
71 | * These routes are typically stateless. |
||
72 | 12 | * |
|
73 | 12 | * @return void |
|
74 | 12 | */ |
|
75 | 12 | protected function mapApiRoutes() |
|
82 | } |
||
83 |