Files
nexusphp/app/Http/Controllers/AgentAllowController.php

76 lines
1.8 KiB
PHP
Raw Normal View History

2021-04-02 19:48:41 +08:00
<?php
namespace App\Http\Controllers;
2021-04-21 00:07:32 +08:00
use App\Http\Requests\AgentAllowRequest;
2021-04-02 19:48:41 +08:00
use App\Http\Resources\AgentAllowResource;
use App\Models\AgentAllow;
use Illuminate\Http\Request;
class AgentAllowController extends Controller
{
/**
* Display a listing of the resource.
*
* @return array
*/
public function index()
{
$result = AgentAllow::query()->paginate();
$resource = AgentAllowResource::collection($result);
return success('agent allow list', $resource);
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
2021-04-21 00:07:32 +08:00
* @return array
2021-04-02 19:48:41 +08:00
*/
2021-04-21 00:07:32 +08:00
public function store(AgentAllowRequest $request)
2021-04-02 19:48:41 +08:00
{
2021-04-21 00:07:32 +08:00
$result = AgentAllow::query()->create($request->all());
$resource = new AgentAllowResource($result);
return success('agent allow store', $resource);
2021-04-02 19:48:41 +08:00
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
2021-04-21 00:07:32 +08:00
* @return array
2021-04-02 19:48:41 +08:00
*/
public function update(Request $request, $id)
{
2021-04-21 00:07:32 +08:00
$result = AgentAllow::query()->findOrFail($id);
$result->update($request->all());
$resource = new AgentAllowResource($result);
return success('agent allow update', $resource);
2021-04-02 19:48:41 +08:00
}
/**
* Remove the specified resource from storage.
*
* @param int $id
2021-04-21 00:07:32 +08:00
* @return array
2021-04-02 19:48:41 +08:00
*/
public function destroy($id)
{
2021-04-21 00:07:32 +08:00
$result = AgentAllow::query()->findOrFail($id);
$success = $result->delete();
return success('agent allow delete', $success);
2021-04-02 19:48:41 +08:00
}
}