123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace App\Http\Controllers\Admin;
- use App\Models\Setting;
- use Illuminate\Http\Request;
- class SettingController extends Controller
- {
- protected $redirect_index = '/admin/Setting/index';
- protected $view_path = 'admin.settings.';
- protected $pre_uri = '/admin/Setting/';
- protected $model_name = '系统配置';
- protected $model;
- public function __construct()
- {
- parent::__construct();
- $this->model = new Setting();
- }
- public function share()
- {
- $share_image = $this->model->firstOrCreate(['key' => 'share_image'], ['key_show' => '图片']);
- $share_text = $this->model->firstOrCreate(['key' => 'share_text'], ['key_show' => '文本标签']);
- $share_text_pos = $this->model->firstOrCreate(['key' => 'share_text_pos'], ['key_show' => '文本位置']);
- list($pre_uri, $model, $model_name) = array($this->pre_uri, $this->model, $this->model_name);
- return view($this->view_path . 'share', compact('pre_uri', 'model', 'model_name', 'share_image', 'share_text', 'share_text_pos'));
- }
- public function updateShare(Request $request)
- {
- if(!$request->isMethod('POST')) {
- return $this->showWarning('访问错误');
- }
- if(!empty($request->input('share_image'))) {
- $this->model->where('key', 'share_image')->update(['value' => $request->input('share_image')]);
- }
- if(!empty($request->input('share_text'))) {
- $this->model->where('key', 'share_text')->update(['value' => $request->input('share_text')]);
- }
- if(!empty($request->input('share_text_pos'))) {
- $this->model->where('key', 'share_text_pos')->update(['value' => $request->input('share_text_pos')]);
- }
- return $this->showMessage('操作成功');
- }
- public function system(Request $request)
- {
- $check_card_location = $this->model->firstOrCreate(['key' => 'check_card_location'], ['key_show' => '39.916527,116.397128']);
- $check_card_radius = $this->model->firstOrCreate(['key' => 'check_card_radius'], ['key_show' => '1000']);
- list($pre_uri, $model, $model_name) = array($this->pre_uri, $this->model, $this->model_name);
- return view($this->view_path . 'system', compact('pre_uri', 'model', 'model_name', 'check_card_location', 'check_card_radius'));
- }
- }
|