// Controller
$posts = Post::all();
return view('posts', ['posts' => $posts])
<?php /** @var \App\Models\Post $post */ ?>
@foreeach ($posts as $post)
<div>
{{ $post->title }}
<div>
@endforeach
$posts = Post::all()->toArray();
public function __construct(User $firstname)
{
$this->user=$firstname;
}
public $firstname;
public function __construct(string $firstname)
{
$this->firstname=$firstname;
}
Mail::to('temoha1386@gmail.com')
->send(new mailsendform($any_data));
return $this->view()->with('variable', 'value');
'invaite_token'
- нет такого правила.$token = Invite::where('invite_token', $value)->first();
if (!$token) {
$fail('Приглашение не существует');
}
protected function create(array $data)
{
$this->validator($data)->validate();
return User::create([
protected function create(array $data)
{
Validator::make($data, [
// Проверка всех других полей формы
'name' => '...',
'email' => '...',
'password' => '...',
// Проверка приглашения
'invite_token' => [
'required',
function ($attribute, $value, $fail) {
$token = Invaite::firstOrFail();
if ($value == $token->invaite_token) {
$fail('Приглашение не существует');
}
},
]
])->validate();
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'invaite_token' => $data['invaite_token'],
'password' => Hash::make($data['password']),
]);
}