چله تابستون 🔥 چله تخفیف استثنایی راکت، این فرصت دیگه پیش نمیاد!
فرصت محدود، تعداد محدودسلام دوستان، من قابلیت اضافه کردن مشتری رو درست کردم ولی وقتی روی دکمه اضافه کردن مشتری میزنم ارور SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'mobile_number' cannot be null (SQL: insert into mobile_numbers
(mobile_number
, customer_id
, updated_at
, created_at
) values (?, 57, 2021-11-08 13:23:13, 2021-11-08 13:23:13)) میده.
این قسمت داخل کنترلر منه
public function addCustomer(Request $req)
{
$customer = new Customer;
$customer->first_name = $req->first_name;
$customer->last_name = $req->last_name;
$customer->birth_day = $req->birth_day;
$customer->save();
$mobileNumber = new MobileNumber;
$mobileNumber->mobile_number = $req->mobile_number;
$customer->mobileNumbers()->save($mobileNumber);
return view('Customers');
}
این قسمت هم روت منه
Route::get('/admin-panel/add-customer/', 'App\Http\Controllers\IndexController@addCustomer');
Route::post('/admin-panel/added-customer/', 'App\Http\Controllers\IndexController@addCustomer');
این هم قسمت قالب فرم منه
<form class="login100-form validate-form" action="/admin-panel/add-customer/" method="POST">
@csrf
<span class="login100-form-title">
اضافه کردن مشتری
</span>
<div class="wrap-input100 validate-input">
<input class="input100" type="text" name="first_name" placeholder="نام">
<span class="focus-input100"></span>
<span class="symbol-input100">
<i class="fa fa-address-card p-r-20" aria-hidden="true"></i>
</span>
</div>
<div class="wrap-input100 validate-input">
<input class="input100" type="text" name="last_name" placeholder="نام خانوادگی">
<span class="focus-input100"></span>
<span class="symbol-input100">
<i class="fa fa-address-book p-r-20" aria-hidden="true"></i>
</span>
</div>
<div class="wrap-input100 validate-input">
<input class="input100" type="text" name="mobile_number" placeholder="شماره مبایل">
<span class="focus-input100"></span>
<span class="symbol-input100">
<i style="font-size: 25px" class="fa fa-mobile p-r-20" aria-hidden="true"></i>
</span>
</div>
<div class="wrap-input100 validate-input">
<input class="input100" type="text" name="birth_day" placeholder="تاریخ تولد">
<span class="focus-input100"></span>
<span class="symbol-input100">
<i class="fa fa-birthday-cake p-r-20" aria-hidden="true"></i>
</span>
</div>
<div class="container-login100-form-btn">
<button class="login100-form-btn">
اضافه کردن
</button>
</div>
</form>
ممنون میشم کمکم کنید
آیا مایل به ارسال نوتیفیکیشن و اخبار از طرف راکت هستید ؟