98 lines
2.5 KiB
PHP
98 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Services\DateServices;
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Controllers\Controller;
|
|
use Log;
|
|
use Illuminate\Support\Facades\Hash;
|
|
use App\Models\SystemUpdateLog;
|
|
|
|
class HomeController extends BaseController
|
|
{
|
|
public function index(){
|
|
$this->setTitle('网站后台');
|
|
if(is_mobile_client())
|
|
{
|
|
//$this->setViewPath('','mobile');
|
|
return redirect()->action('Admin\HomeController@console');
|
|
}
|
|
return $this->display();
|
|
}
|
|
public function console(){
|
|
$data=[];
|
|
$data['day_before_7']=DateServices::decrDay('',6);
|
|
$data['update_log']=SystemUpdateLog::where('type','system')->limit(10)->orderBy('id','desc')->get();
|
|
|
|
//DateServices::diffDay('2019-01-02','2019-01-05');
|
|
|
|
return $this->display($data);
|
|
}
|
|
public function online($id){
|
|
$this->setViewPath('','online');
|
|
|
|
$data=[
|
|
|
|
];
|
|
return $this->display($data);
|
|
}
|
|
public function showNotice($id,$request){
|
|
$this->setViewPath('','notice');
|
|
$notice=NoticeArticle::find($id);
|
|
$data=[
|
|
'show'=>$notice
|
|
];
|
|
return $this->display($data);
|
|
}
|
|
public function show($type,$id,Request $request){
|
|
return $this->$type($id,$request);
|
|
}
|
|
|
|
public function password($id){
|
|
$this->setViewPath('','password');
|
|
|
|
$data=[
|
|
|
|
];
|
|
return $this->display($data);
|
|
}
|
|
public function update($method,Request $request){
|
|
|
|
return $this->$method($request);
|
|
}
|
|
public function passwordUpdate($request){
|
|
$error=$this->validatorForm($request,'password');
|
|
if(count($error)>0){
|
|
return $this->formError($error);
|
|
};
|
|
$user=admin();
|
|
$password=$request->input('password');
|
|
$old_password=$request->input('old_password');
|
|
if (!Hash::check($old_password, $user->password)) {
|
|
return $this->alertError('旧密码不对');
|
|
}
|
|
$user->password=$password;
|
|
if($user->save())
|
|
{
|
|
return $this->alertError('修改密码成功',0);
|
|
}
|
|
return $this->alertError('修改密码失败',1);
|
|
|
|
}
|
|
|
|
public function checkRule($id = '')
|
|
{
|
|
return [
|
|
'password' => 'required|confirmed',
|
|
'old_password' => 'required'
|
|
];
|
|
}
|
|
public function setErrorMsg()
|
|
{
|
|
return [
|
|
'old_password'=>'旧密码'
|
|
];
|
|
}
|
|
}
|