55 lines
1.5 KiB
PHP
55 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Helpers\Paginator;
|
|
use App\Http\Resources\FriendLinkResource;
|
|
use App\Models\FriendLink;
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Requestes\FriendLinkRequest;
|
|
use App\Http\Requestes\FriendLinkUpdateRequest;
|
|
use App\Services\OperationLogService;
|
|
use App\Enums\OperationType;
|
|
|
|
class FriendLinkController extends Controller
|
|
{
|
|
public function index(Request $request)
|
|
{
|
|
$query = FriendLink::filter($request->all());
|
|
|
|
$list = $query->paginate(Paginator::resolvePerPage('per_page', 20, 50));
|
|
|
|
return $this->json(FriendLinkResource::collection($list));
|
|
}
|
|
|
|
public function store(FriendLinkRequest $request){
|
|
$input = $request->input();
|
|
|
|
$friendLink = FriendLink::create($input);
|
|
|
|
(new OperationLogService())->inLog(OperationType::Create, '', $friendLink, $request->input());
|
|
|
|
return $this->success('添加成功');
|
|
}
|
|
|
|
public function show(FriendLink $friendLink){
|
|
return $this->json(FriendLinkResource::make($friendLink));
|
|
}
|
|
|
|
public function update(FriendLink $friendLink, FriendLinkUpdateRequest $request){
|
|
$friendLink->update($request->input());
|
|
|
|
(new OperationLogService())->inLog(OperationType::Update, '', $friendLink, $request->input());
|
|
|
|
return $this->success('修改成功');
|
|
}
|
|
|
|
public function destroy(FriendLink $friendLink){
|
|
$friendLink->delete();
|
|
|
|
(new OperationLogService())->inLog(OperationType::Delete, '', $friendLink);
|
|
|
|
return $this->success('删除成功');
|
|
}
|
|
}
|