Browse Source

Merge remote-tracking branch 'origin/master'

master
李可松 4 years ago
parent
commit
a10ef8e61d
  1. 17
      app/Admin/Controllers/ServicePersonsSettingController.php
  2. 56
      app/Admin/Forms/ServicePersonsSetting.php
  3. 1
      app/Admin/routes.php

17
app/Admin/Controllers/ServicePersonsSettingController.php

@ -0,0 +1,17 @@
<?php
namespace App\Admin\Controllers;
use App\Admin\Forms\ServicePersonsSetting;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Widgets\Card;
class ServicePersonsSettingController extends AdminController
{
public function index(Content $content)
{
return $content
->title('交易设置')
->body(new Card(new ServicePersonsSetting()));
}
}

56
app/Admin/Forms/ServicePersonsSetting.php

@ -0,0 +1,56 @@
<?php
namespace App\Admin\Forms;
use App\Traits\WithdrawalTraits;
use Dcat\Admin\Widgets\Form;
class ServicePersonsSetting extends Form
{
/**
* Handle the form request.
*
* @param array $input
*
* @return mixed
*/
public function handle(array $input)
{
$system = \App\Models\SystemSetting::query()->firstOrCreate([
'key' => 'single'
]);
$arr = [
'price' => $input['price'],
];
$system->value = $arr;
$system->save();
return $this
->response()
->success('设置成功')
->refresh();
}
/**
* Build a form here.
*/
public function form()
{
$this->decimal('price','单人头交易费')->rules('required|numeric|min:0|not_in:0',[
'*' => '金额为必填字段且必须大于0',
]);
}
/**
* The data of the form.
*
* @return array
*/
public function default()
{
$system = \App\Models\SystemSetting::query()->where('key','single')->value('value');
return [
'price' => $system['price'] ?? 0,
];
}
}

1
app/Admin/routes.php

@ -46,4 +46,5 @@ Route::group([
$router->resource('withdrawal', 'WithdrawalController'); $router->resource('withdrawal', 'WithdrawalController');
$router->resource('system', 'SystemSettingController'); $router->resource('system', 'SystemSettingController');
$router->resource('deposit', 'DepositController'); $router->resource('deposit', 'DepositController');
$router->resource('setting_single', 'ServicePersonsSettingController');
}); });
Loading…
Cancel
Save