protected function prepareForValidation()
{
if (!$this->input('role.slug')) {
$updatedInput = $this->collect('role')->merge([
'slug' => Str::slug($this->input('role.name'), '_'),
])->toArray();
$this->merge(['role' => $updatedInput]);
Request::merge(['role' => $updatedInput]);
}
}MAIL_MAILER=smtp
MAIL_HOST=localhost
MAIL_PORT=25
MAIL_ENCRYPTION=null
<form method="POST" if="myform">@csrf</form>
@foreach($posts as $post)
<button type="submit"
form="myform"
fromaction="{{ route('admin.post.delete', ['post' => $post->_id]) }}"
>Удалить</button>
@endforeach env()If you execute theconfig:cachecommand during your deployment process, you should be sure that you are only calling theenvfunction from within your configuration files. Once the configuration has been cached, the.envfile will not be loaded and all calls to theenvfunction will returnnull.
<input type="checkbox" name="check" value="1">$request->validate([
'check' => 'sometimes|bool',
]);<input type="hidden" name="check" value="0">
<input type="checkbox" name="check" value="1">protected function prepareForValidation()
{
$this->merge([
'check' => $this->has('check')
]);
} cities и airports (обратите внимание – названия во мн. числе)id | name | другие поля, если нужноid | city_id | name | другие поля, если нужноCity и Airport (обратите внимание – названия в ед. числе)City создать отношение один-ко-многим (в городе может быть несколько аэропортов)public function airports(): \Illuminate\Database\Eloquent\Relations\HasMany {}
return $this->hasMany(\App\Models\Airport::class);
}Airport создать обратное отношениеpublic function city(): \Illuminate\Database\Eloquent\Relations\BelongsTo {}
return $this->belongsTo(\App\Models\City::class);
}$from = $request->input['otkuda'];
$city = \App\Models\City::whereName($from) // По названию города
->firstOrFail();
// или
// $fromId = $request->input['otkuda'];
// $city = \App\Models\City::findOrFail($fromId); // По ID города
dump($city->toArray()); // Получили город
dump($city->airports->toArray()); // Получили список аэропортов города$airportId = $request->input['airportId'];
$airport = \App\Models\Airport::findOrFail($airportId);
dump($airport->toArray()); // Получили аэропорт по ID
dump($airport->city->toArray()); // Получили город, в котором этот аэропорт находится. {{--@if (isset($citi))--}}
<table class="table-hover">
<thead>
<tr>
</tr>
</thead>
<tbody>
@if($posts->isNotEmpty())
@foreach ($posts as $post)
<div class="post-List">
<p>{{ Spost-nane }}</p>
@endForeach
@else
<div>
<h2>No posts Found</h2>
</div>
@endif
</tbody>
</table>
{{--@endif--}} {!! old('name', $product->description) !!}{{ old('name') ?? new HtmlString($product->description) }} @if($manifestExists)
<link rel="manifest" href="{{ asset('manifests') }}/user.webmanifest">
@endif webpack.mix.site.js
webpack.mix.dashboard.jsmix.setResourceRoot('/static/frontend');mix.setResourceRoot('/static/dashboard');<link href="{{ mix('css/main.css', 'static/frontend') }}" rel="stylesheet">const mix = require('laravel-mix');
const mix2 = require('laravel-mix');
mix.js('resources/js/app.js', 'public/js').vue()
mix2.options({
vue: { customElement: true }
})
mix2.js('resources/js/app2.js', 'public/js').vue()