1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Devpri\Tinre; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\Facades\Route; |
6
|
|
|
|
7
|
|
|
class RouteRegistration |
8
|
|
|
{ |
9
|
|
|
protected $registered = false; |
10
|
|
|
|
11
|
167 |
|
public function register(): void |
12
|
|
|
{ |
13
|
167 |
|
$this->registered = true; |
14
|
|
|
|
15
|
167 |
|
Route::middleware('web') |
16
|
167 |
|
->namespace('Devpri\Tinre\Http\Controllers\Web') |
17
|
167 |
|
->prefix('/web') |
18
|
167 |
|
->group(__DIR__.'/../routes/web.php'); |
19
|
|
|
|
20
|
167 |
|
Route::middleware('api') |
21
|
167 |
|
->namespace('Devpri\Tinre\Http\Controllers\Api\V1') |
22
|
167 |
|
->prefix('/api/v1') |
23
|
167 |
|
->group(__DIR__.'/../routes/api/v1.php'); |
24
|
|
|
|
25
|
167 |
|
Route::middleware(['web', 'auth']) |
26
|
167 |
|
->prefix(Tinre::dashboardPath()) |
27
|
167 |
|
->get('{view?}', 'Devpri\Tinre\Http\Controllers\DashboardController@show') |
28
|
167 |
|
->where('view', '.*') |
29
|
167 |
|
->name('dashboard'); |
30
|
|
|
|
31
|
167 |
|
if (config('tinre.url_preview', true)) { |
32
|
166 |
|
Route::get('{path}'.config('tinre.url_preview_suffix', '+'), 'Devpri\Tinre\Http\Controllers\PreviewController@show') |
33
|
166 |
|
->middleware(['web']) |
34
|
166 |
|
->name('preview'); |
35
|
|
|
} |
36
|
|
|
|
37
|
167 |
|
Route::get('{path}', 'Devpri\Tinre\Http\Controllers\RedirectController@redirect')->name('url'); |
38
|
167 |
|
} |
39
|
|
|
|
40
|
167 |
|
public function withHomeRoute($middleware = ['web']): RouteRegistration |
41
|
|
|
{ |
42
|
167 |
|
Route::get('/', 'Devpri\Tinre\Http\Controllers\HomeController@show')->middleware($middleware); |
43
|
|
|
|
44
|
167 |
|
return $this; |
45
|
|
|
} |
46
|
|
|
|
47
|
167 |
|
public function withAuthenticationRoutes($middleware = ['web']): RouteRegistration |
48
|
|
|
{ |
49
|
167 |
|
Route::group([ |
50
|
167 |
|
'namespace' => 'Devpri\Tinre\Http\Controllers', |
51
|
167 |
|
'prefix' => Tinre::dashboardPath(), |
52
|
167 |
|
'middleware' => $middleware, |
53
|
167 |
|
], function () { |
54
|
167 |
|
Route::get('login', 'Auth\LoginController@showLoginForm')->name('login'); |
55
|
167 |
|
Route::post('login', 'Auth\LoginController@login'); |
56
|
167 |
|
Route::post('logout', 'Auth\LoginController@logout')->name('logout'); |
57
|
167 |
|
}); |
58
|
|
|
|
59
|
167 |
|
return $this; |
60
|
|
|
} |
61
|
|
|
|
62
|
167 |
|
public function withPasswordResetRoutes($middleware = ['web']): RouteRegistration |
63
|
|
|
{ |
64
|
167 |
|
Route::group([ |
65
|
167 |
|
'namespace' => 'Devpri\Tinre\Http\Controllers', |
66
|
167 |
|
'prefix' => Tinre::dashboardPath(), |
67
|
167 |
|
'middleware' => $middleware, |
68
|
167 |
|
], function () { |
69
|
167 |
|
Route::get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request'); |
70
|
167 |
|
Route::post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email'); |
71
|
167 |
|
Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset'); |
72
|
167 |
|
Route::post('password/reset', 'Auth\ResetPasswordController@reset')->name('password.update'); |
73
|
167 |
|
}); |
74
|
|
|
|
75
|
167 |
|
return $this; |
76
|
|
|
} |
77
|
|
|
|
78
|
167 |
|
public function withRegisterRoutes($middleware = ['web']): RouteRegistration |
79
|
|
|
{ |
80
|
167 |
|
Route::group([ |
81
|
167 |
|
'namespace' => 'Devpri\Tinre\Http\Controllers', |
82
|
167 |
|
'prefix' => Tinre::dashboardPath(), |
83
|
167 |
|
'middleware' => $middleware, |
84
|
167 |
|
], function () { |
85
|
167 |
|
Route::get('register', 'Auth\RegisterController@showRegistrationForm')->name('register'); |
86
|
167 |
|
Route::post('register', 'Auth\RegisterController@register'); |
87
|
167 |
|
}); |
88
|
|
|
|
89
|
167 |
|
return $this; |
90
|
|
|
} |
91
|
|
|
|
92
|
167 |
|
public function withVerificationRoutes($middleware = ['web']): RouteRegistration |
93
|
|
|
{ |
94
|
167 |
|
Route::group([ |
95
|
167 |
|
'namespace' => 'Devpri\Tinre\Http\Controllers', |
96
|
167 |
|
'prefix' => Tinre::dashboardPath(), |
97
|
167 |
|
'middleware' => $middleware, |
98
|
167 |
|
], function () { |
99
|
167 |
|
Route::get('email/verify', 'Auth\VerificationController@show')->name('verification.notice'); |
100
|
167 |
|
Route::get('email/verify/{id}/{hash}', 'Auth\VerificationController@verify')->name('verification.verify'); |
101
|
167 |
|
Route::post('email/resend', 'Auth\VerificationController@resend')->name('verification.resend'); |
102
|
167 |
|
}); |
103
|
|
|
|
104
|
167 |
|
return $this; |
105
|
|
|
} |
106
|
|
|
|
107
|
167 |
|
public function withEmailChangeRoutes($middleware = ['web']): RouteRegistration |
108
|
|
|
{ |
109
|
167 |
|
Route::group([ |
110
|
167 |
|
'namespace' => 'Devpri\Tinre\Http\Controllers', |
111
|
167 |
|
'prefix' => Tinre::dashboardPath(), |
112
|
167 |
|
'middleware' => $middleware, |
113
|
167 |
|
], function () { |
114
|
167 |
|
Route::get('email/change/{token}', 'Auth\ChangeEmailController@change')->name('email.change'); |
115
|
167 |
|
Route::post('email/change', 'Auth\ChangeEmailController@create')->name('email.request'); |
116
|
167 |
|
}); |
117
|
|
|
|
118
|
167 |
|
return $this; |
119
|
|
|
} |
120
|
|
|
|
121
|
167 |
|
public function __destruct() |
122
|
|
|
{ |
123
|
167 |
|
if (! $this->registered) { |
124
|
167 |
|
$this->register(); |
125
|
|
|
} |
126
|
167 |
|
} |
127
|
|
|
} |
128
|
|
|
|