This commit is contained in:
64
api/app/Http/Controllers/ExampleController.php
Normal file
64
api/app/Http/Controllers/ExampleController.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Example;
|
||||
use App\Services\ExampleService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class ExampleController extends Controller
|
||||
{
|
||||
protected $modulo = 'modulo';
|
||||
protected $funcionalidade = 'funcionalidade';
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json($this->get(Example::class)->get(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(ExampleService::store($request->all()), Response::HTTP_CREATED);
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json($this->get(Example::class, $id), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(ExampleService::update($id, $request->all()), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(ExampleService::destroy($id), Response::HTTP_NO_CONTENT);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user