Add customer/user's email validation
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
namespace App\Http\Requests\Common;
|
||||
|
||||
use App\Abstracts\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class Contact extends FormRequest
|
||||
{
|
||||
@ -23,7 +24,7 @@ class Contact extends FormRequest
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
$email = '';
|
||||
$email = [];
|
||||
$required = '';
|
||||
|
||||
$type = $this->request->get('type', 'customer');
|
||||
@ -43,7 +44,18 @@ class Contact extends FormRequest
|
||||
}
|
||||
|
||||
if (!empty($this->request->get('email'))) {
|
||||
$email = 'email|unique:contacts,NULL,' . $id . ',id,company_id,' . $company_id . ',type,' . $type . ',deleted_at,NULL';
|
||||
$email[] = 'email';
|
||||
$email[] = Rule::unique('contacts')
|
||||
->ignore($id)
|
||||
->where('company_id', $company_id)
|
||||
->where('type', $type)
|
||||
->where('deleted_at');
|
||||
|
||||
if (isset($model) && $this->$model->user_id) {
|
||||
$email[] = Rule::unique('users')
|
||||
->ignore($this->$model->user_id)
|
||||
->where('deleted_at');
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
|
Reference in New Issue
Block a user