28 lines
862 B
PHP
28 lines
862 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Controllers\Admin\Navigation;
|
||
|
|
|
||
|
|
use App\Http\Controllers\Controller;
|
||
|
|
use App\Services\NavigationService;
|
||
|
|
use Illuminate\Http\Request;
|
||
|
|
|
||
|
|
class NavigationStoreController extends Controller
|
||
|
|
{
|
||
|
|
public function __invoke(Request $request, NavigationService $navigationService)
|
||
|
|
{
|
||
|
|
$validated = $request->validate([
|
||
|
|
'label' => 'required|string|max:255',
|
||
|
|
'url' => 'nullable|string|max:255',
|
||
|
|
'page_id' => 'nullable|exists:pages,id',
|
||
|
|
'parent_id' => 'nullable|exists:navigation_items,id',
|
||
|
|
'target' => 'required|string|in:_self,_blank',
|
||
|
|
]);
|
||
|
|
|
||
|
|
if ($navigationService->store($validated)) {
|
||
|
|
return back()->with('success', 'Navigation item added.');
|
||
|
|
}
|
||
|
|
|
||
|
|
return back()->withInput()->with('error', 'Failed to add navigation item.');
|
||
|
|
}
|
||
|
|
}
|