1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-21 08:51:34 +02:00
invoiceninja/app/Http/Requests/ClientPortal/RegisterRequest.php

49 lines
1.2 KiB
PHP
Raw Normal View History

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-05-28 17:39:38 +02:00
'email' => ['required', 'string', 'email', 'max:255', 'unique:client_contacts'],
'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();
}
if ($this->company_key) {
return Company::where('company_key', $this->company_key)->firstOrFail();
}
abort(404);
}
2020-05-28 17:39:38 +02:00
}