master
cody 2 years ago
parent 8504ae0dcd
commit 25d7bf0f48

@ -8,6 +8,7 @@ use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use OwenIt\Auditing\Contracts\Auditable;
use Spatie\Permission\Models\Role;
class CommonModel extends Model
{
@ -132,4 +133,19 @@ class CommonModel extends Model
$router->post("{$prefix}/update/{id?}", "{$controller}@update");
$router->post("{$prefix}/delete", "{$controller}@delete");
}
/**
* 判断是否有导出权限
*/
public static function checkExport()
{
$userId = auth()->id();
$roleId = Role::where('name', 'like', '%导出%')->where('guard_name', 'admin')->value('id');
return DB::table('model_has_roles')
->where('role_id', $roleId)
->where('model_type', 'App\Admin')
->where('model_id', $userId)
->count();
}
}

@ -37,8 +37,9 @@
<input class="form-control" type="text" name="keyword" value="{{ request()->keyword }}"
placeholder="订单编号/联系人/联系电话">
@if(\App\Models\CommonModel::checkExport())
<button class="btn btn-primary ml-1" type="button" onclick="doExport(this)">导出</button>
@endif
</form>
</div>
<table class="table table-bordered" id="data-table">

Loading…
Cancel
Save