2020-05-28 17:39:38 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Requests\ClientPortal;
|
|
|
|
|
2020-06-22 10:26:48 +02:00
|
|
|
use App\Models\Company;
|
2020-05-28 17:39:38 +02:00
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
|
|
|
|
class RegisterRequest extends FormRequest
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Determine if the user is authorized to make this request.
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function authorize()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the validation rules that apply to the request.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function rules()
|
|
|
|
{
|
|
|
|
return [
|
2020-05-28 17:52:44 +02:00
|
|
|
'first_name' => ['required', 'string', 'max:255'],
|
|
|
|
'last_name' => ['required', 'string', 'max:255'],
|
2020-06-18 17:09:28 +02:00
|
|
|
'phone' => ['required', 'string', 'max:255'],
|
2020-10-12 23:27:42 +02:00
|
|
|
'email' => ['required', 'string', 'email:rfc,dns', 'max:255', 'unique:client_contacts'],
|
2020-05-28 17:39:38 +02:00
|
|
|
'password' => ['required', 'string', 'min:6', 'confirmed'],
|
|
|
|
];
|
|
|
|
}
|
2020-06-22 10:26:48 +02:00
|
|
|
|
|
|
|
public function company()
|
|
|
|
{
|
|
|
|
if ($this->subdomain) {
|
|
|
|
return Company::where('subdomain', $this->subdomain)->firstOrFail();
|
|
|
|
}
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2020-06-22 10:26:48 +02:00
|
|
|
if ($this->company_key) {
|
|
|
|
return Company::where('company_key', $this->company_key)->firstOrFail();
|
|
|
|
}
|
|
|
|
|
|
|
|
abort(404);
|
|
|
|
}
|
2020-05-28 17:39:38 +02:00
|
|
|
}
|