2022-10-02 18:38:41 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use App\Http\Requests\Templates\CreateTemplateRequest;
|
2022-12-01 12:13:32 +00:00
|
|
|
use App\Http\Resources\TemplateResource;
|
2022-10-02 18:38:41 +00:00
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use App\Models\Template;
|
|
|
|
|
|
|
|
class TemplateController extends Controller
|
|
|
|
{
|
|
|
|
public function index()
|
|
|
|
{
|
2022-12-01 12:13:32 +00:00
|
|
|
return TemplateResource::collection(Template::all());
|
2022-10-02 18:38:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function create(CreateTemplateRequest $request)
|
|
|
|
{
|
2022-11-16 12:12:48 +00:00
|
|
|
$this->authorize('create', Template::class);
|
2022-10-02 18:38:41 +00:00
|
|
|
|
|
|
|
// Create template
|
|
|
|
$template = $request->getTemplate();
|
|
|
|
$template->save();
|
|
|
|
|
|
|
|
return $this->success([
|
|
|
|
'message' => 'Template created.',
|
|
|
|
'template_id' => $template->id
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|