海南旅游SAAS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

46 lines
1.2 KiB

<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Cache;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
protected $user_id = 0;
protected $agent_id = 0; //代理商ID
public function __construct()
{
// TODO 登录部分待优化
$auth = request()->header('Authentication');
$appid = request()->header('appid');
$this->user_id = Cache::get($auth);
$this->agent_id = Cache::get($appid);
}
protected function success($data = [], $msg = 'success', $code = 1, $status = 200): array
{
return [
'code' => $code,
'msg' => $msg,
'data' => $data,
'status' => $status,
];
}
protected function error($msg = 'error', $code = -1, $status = 500): array
{
return [
'code' => $code,
'msg' => $msg,
'data' => [],
'status' => $status,
];
}
}