mirror of
https://github.com/Bigherollc/wticreatorstudio.git
synced 2026-08-01 17:17:12 -04:00
45 lines
1.1 KiB
PHP
45 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Modules\Frontend\Http\Controllers;
|
|
|
|
use Illuminate\Contracts\Support\Renderable;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Routing\Controller;
|
|
use Modules\Frontend\Http\Requests\SectionRequest;
|
|
use Modules\Frontend\Repositories\SectionRepository;
|
|
|
|
class SectionController extends Controller
|
|
{
|
|
protected $repository;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->repository = new SectionRepository();
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
$sections = $this->repository->all();
|
|
|
|
return response()->json([
|
|
'sections' => $sections,
|
|
]);
|
|
}
|
|
|
|
public function store(SectionRequest $request)
|
|
{
|
|
$section = $this->repository->create($request->title, $request->layout);
|
|
|
|
if ($section) {
|
|
return response()->json([
|
|
'message' => __('frontend::common.section-saved'),
|
|
'section' => $section,
|
|
]);
|
|
}
|
|
|
|
return response()->json([
|
|
'message' => __('frontend::common.store-section-failed'),
|
|
], 400);
|
|
}
|
|
}
|