İyi günler arkadaşlar,
Bir formdan kullanıcıdan veri alıyorum. Fakat burada önemli bir durum telefon değeri unique olmak zorunda. Eğer bir önceki ile aynı telefon girerse aşağıdaki hatayı veriyor.
QueryException in Connection.php line 647:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0123456789' for key 'company_teacher_phone_unique' (SQL: insert into `company_teacher` (`company_id`, `name`, `surname`, `phone`, `email`, `password`, `updated_at`, `created_at`) values (1, Mustafa, Ceceli, 0123456789, mustafaceceli@xyz.com, 123456, 2017-04-15 10:36:25, 2017-04-15 10:36:25))
Bunu istemiyorum da direk form kayıt ekranında bu telefon daha önce kaydedilmiş lütfen farklı telefon giriniz diye uyarı versin istiyorum. Kurcaladım nette yazanları yaptım. Fakat yapamadım. Yardımcı olabilir misiniz acaba?
request dosyam
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class NewTeacherRequest 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 [
'name' => 'required|max:255',
'surname' => 'required|max:255',
'email' => 'required|email|max:255',
'password' => 'required|min:6',
'phone' => 'required|numeric',
];
}
}
form
<h1 class="page-title"> Yeni Öğretmen Kayıt </h1>
<div class="login_wrapper">
<form method="post">
{!! csrf_field() !!}
<div class="form-group">
<input type="text" class="form-control formBox" name="name" placeholder="İsim Giriniz">
</div>
<div class="form-group">
<input type="text" class="form-control formBox" name="surname" placeholder="Soyisim Giriniz">
</div>
<div class="form-group">
<input type="text" class="form-control formBox" name="phone" placeholder="Telefon Giriniz">
</div>
<div class="form-group">
<input type="email" class="form-control formBox" name="email" placeholder="Mail Giriniz">
</div>
<div class="form-group">
<input type="password" class="form-control formBox" name="password" placeholder="Şifre Giriniz">
</div>
<div>
<button class="btn btn-default submit" >Kayıt</button>
</div>
</form>
</div>
</div>