Lae/app/Http/Requests/User/HostRequest.php

43 lines
790 B
PHP
Raw Normal View History

2022-11-25 08:14:42 +00:00
<?php
namespace App\Http\Requests\User;
2022-11-27 13:04:20 +00:00
use App\Models\Host;
2022-11-25 08:14:42 +00:00
use Illuminate\Foundation\Http\FormRequest;
class HostRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize(): bool
{
$host = $this->route('host');
2022-11-27 13:04:20 +00:00
if (!($host instanceof Host)) {
$host = Host::where('id', $host)->first();
}
if ($host->user_id ?? 0 == $this->user()->id) {
return true;
} else {
return false;
}
2022-11-25 08:14:42 +00:00
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
public function rules()
{
return [
//
];
}
}