|
|
@@ -5,12 +5,12 @@ namespace App\Http\Controllers;
|
|
|
use App\Components\AsyncResponse;
|
|
|
use App\Http\Requests\Station\StationRuleBatchRequest;
|
|
|
use App\Services\OwnerService;
|
|
|
-use App\Station;
|
|
|
use App\StationRuleBatch;
|
|
|
use Illuminate\Contracts\Foundation\Application;
|
|
|
use Illuminate\Contracts\View\Factory;
|
|
|
use Illuminate\Http\Request;
|
|
|
use Illuminate\Http\Response;
|
|
|
+use Illuminate\Support\Facades\Gate;
|
|
|
use Illuminate\View\View;
|
|
|
|
|
|
|
|
|
@@ -27,6 +27,7 @@ class StationRuleBatchController extends Controller
|
|
|
*/
|
|
|
public function index(Request $request,OwnerService $ownerService)
|
|
|
{
|
|
|
+ if(!Gate::allows('站管理-站规则')){ return redirect(url('/')); }
|
|
|
$stationRuleBatches = StationRuleBatch::query()->with('stationType','owner')->orderByDesc('id')->paginate($request['paginate'] ?? 50);
|
|
|
$owners = $ownerService->getAuthorizedOwners();
|
|
|
return view('station.rule.index',compact('stationRuleBatches','owners'));
|
|
|
@@ -38,6 +39,7 @@ class StationRuleBatchController extends Controller
|
|
|
*/
|
|
|
public function storeApi(StationRuleBatchRequest $request)
|
|
|
{
|
|
|
+ $this->gate('站管理-站规则-编辑');
|
|
|
$stationRuleBatch = StationRuleBatch::query()->create($request->only(['name','owner_id']));
|
|
|
$stationRuleBatch->load('stationType','owner');
|
|
|
$this->success($stationRuleBatch);
|
|
|
@@ -49,6 +51,7 @@ class StationRuleBatchController extends Controller
|
|
|
*/
|
|
|
public function updateApi(StationRuleBatchRequest $request)
|
|
|
{
|
|
|
+ $this->gate('站管理-站规则-编辑');
|
|
|
$stationRuleBatch = StationRuleBatch::query()->whereKey($request['id'])->first();
|
|
|
$stationRuleBatch->update($request->all());
|
|
|
$stationRuleBatch->load('stationType','owner');
|
|
|
@@ -57,6 +60,7 @@ class StationRuleBatchController extends Controller
|
|
|
|
|
|
public function destroyApi(Request $request)
|
|
|
{
|
|
|
+ $this->gate('站管理-站规则-删除');
|
|
|
StationRuleBatch::query()->whereKey($request['id'])->delete();
|
|
|
$this->success();
|
|
|
}
|