48 lines
1.1 KiB
PHP
48 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Http\Controllers\Admin\OptionsController;
|
|
use Illuminate\Support\ServiceProvider;
|
|
use Route;
|
|
|
|
/**
|
|
* 建立後台設定頁面的route
|
|
*
|
|
* Class OptionRouteServiceProvider
|
|
* @package App\Providers
|
|
*/
|
|
class OptionRouteServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Register services.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function register()
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Bootstrap services.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function boot()
|
|
{
|
|
Route::group(['prefix' => config('admin.route'), 'middleware' => ['web', 'admin.area'], 'as' => config('admin.route_name_prefix')], function(){
|
|
$config = config('admin.options');
|
|
if(empty($config)) return;
|
|
$options = array_keys(config('admin.options'));
|
|
|
|
foreach ($options as $page) {
|
|
$action = OptionsController::class;
|
|
$action .= '@update' . ucfirst($page);
|
|
Route::match(['put', 'patch'], "/options/{$page}/update", $action)
|
|
->name("options.{$page}.update");
|
|
}
|
|
});
|
|
}
|
|
}
|