初始化项目
This commit is contained in:
53
app/Http/Controllers/Service/ServiceBaseController.php
Normal file
53
app/Http/Controllers/Service/ServiceBaseController.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Service;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\YiiModels\ServiceUser;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
/**
|
||||
* 用户端基类
|
||||
*/
|
||||
class ServiceBaseController extends Controller
|
||||
{
|
||||
/**
|
||||
* @comment 用户
|
||||
* @return \App\Models\YiiModels\ServiceUser|\Illuminate\Contracts\Auth\Authenticatable|null
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
return Auth::guard(ServiceUser::GUARD)->user();
|
||||
}
|
||||
|
||||
/**
|
||||
* @comment 用户id
|
||||
* @return int
|
||||
*/
|
||||
public function userId()
|
||||
{
|
||||
return $this->user()->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @comment 当前仓库id
|
||||
* @return int
|
||||
*/
|
||||
public function currentDrugstoreId()
|
||||
{
|
||||
$serviceUser = $this->user();
|
||||
$serviceUser->loadMissing(['storeDoctorOnline.store']);
|
||||
return $serviceUser->storeDoctorOnline->store->drugstore_id ?? 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @comment 当前门店id
|
||||
* @return int
|
||||
*/
|
||||
public function currentStoreId()
|
||||
{
|
||||
$serviceUser = $this->user();
|
||||
$serviceUser->loadMissing(['storeDoctorOnline']);
|
||||
return $serviceUser->storeDoctorOnline->store_id ?? 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user