public function index(TabRepository $repository)
{
return inertia()->render('Index', [
'default_tab' => fn () => $repository->getDefaultTabData(), // отдаст по умолчанию и по требованию
'tab2' => Inertia::lazy(fn () => $repository->getTab2Data()), // отдаст только по требованию
'tab3' => Inertia::lazy(fn () => $repository->getTab3Data()), // отдаст только по требованию
]);
}
<Link class="tab" href="route('blabla')" :only="['default_tab']">default_tab</Link>
<Link class="tab" href="route('blabla')" :only="['tab2']">tab2</Link>
<Link class="tab" href="route('blabla')" :only="['tab3']">tab3</Link>
return inertia()->render('Some/Component', ['some' => 'data'])
form.reset()
.Route::fallback(function ()
{
return redirect()->to('/');
});
/app/Exceptions/Handler.php
/**
* Render an exception into a response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
if ($e instanceof NotFoundHttpException) {
return redirect()->to('/');
}
return parent::render($request, $e);
}
public function handle($request, Closure $next)
{
if(! in_array($request->route()->getName(), ['home', 'pages'])) {
return redirect()->route('home');
}
return $next($request);
}
public function incomeMessages()
{
return $this->hasMany(Message::class, 'receiver_id');
}
public function sentMessages()
{
return $this->hasMany(Message::class, 'sender_id');
}
public function sender()
{
return $this->belongsTo(User::class, 'sender_id');
}
public function receiver()
{
return $this->belongsTo(User::class, 'receiver_id');
}
public function handleForm(Request $request)
{
// dispatch(...); Тут отправляем Email
return back()->withSuccess('Письмо успешно отправлено!');
}
@include('includes.alerts')
@if (($isSuccess = isset($success)) || isset($error))
<div class="alert {{ $isSuccess ? 'alert-success' : 'alert-error' }} mb-3">
<p>{{ $success ?? $error }}</p>
</div>
@endif