2024-03-07 22:42:11 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\API;
|
|
|
|
|
2024-03-08 21:09:43 +01:00
|
|
|
use App\Interfaces\PageRepositoryInterface;
|
2024-03-07 22:42:11 +01:00
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
class PageAPIController extends Controller
|
|
|
|
{
|
2024-03-08 21:09:43 +01:00
|
|
|
protected $pages;
|
|
|
|
|
2024-03-07 22:42:11 +01:00
|
|
|
public function __construct(
|
2024-03-08 21:09:43 +01:00
|
|
|
PageRepositoryInterface $pageRepository
|
2024-03-07 22:42:11 +01:00
|
|
|
) {
|
2024-03-08 21:09:43 +01:00
|
|
|
$this->pages = $pageRepository;
|
2024-03-07 22:42:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function write(Request $request)
|
|
|
|
{
|
2024-03-08 21:09:43 +01:00
|
|
|
$body = json_decode($request->getContent());
|
|
|
|
$result = $this->pages->update($body);
|
2024-03-07 22:42:11 +01:00
|
|
|
return response()->json($result)->header('Content-Type', 'application/json');
|
|
|
|
}
|
2024-03-12 23:16:36 +01:00
|
|
|
|
|
|
|
public function create(Request $request)
|
|
|
|
{
|
|
|
|
$body = json_decode($request->getContent());
|
|
|
|
$result = $this->pages->create($body);
|
|
|
|
return response()->json($result)->header('Content-Type', 'application/json');
|
|
|
|
}
|
2024-07-07 00:23:23 +02:00
|
|
|
|
|
|
|
public function delete(Request $request)
|
|
|
|
{
|
|
|
|
$body = json_decode($request->getContent());
|
|
|
|
$result = $this->pages->delete($body);
|
|
|
|
return response()->json($result)->header('Content-Type', 'application/json');
|
|
|
|
}
|
2024-03-07 22:42:11 +01:00
|
|
|
}
|