I asked How to update call Session ?
How to update call Session
I have a project where the user first signs up. After registering a sms, the code will be sent to the user and in the database both the code and the mobile will be saved.
Of course, I saved before on the Session::put('mobile',$mobile) & Session::put('code',$code) registry page. How can I call it now?
So far I have no problem. And then after saving the button, it redirects to the verification code form. Here, the user must enter their mobile number and code.
Now, if the user changes the verification_code field to 1 after entering the mobile number and code.
create_users.table
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->boolean('active')->default(false);
$table->string('level')->default('user');
$table->string('first_name');
$table->string('last_name');
$table->string('mobile');
$table->string('code');
$table->boolean('verification_code')->default(0);
$table->string('birth_date');
$table->boolean('gender');
$table->bigInteger('province_id')->unsigned();
$table->bigInteger('city_id')->unsigned();
$table->text('address');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
$table->foreign('province_id')->references('id')->on('provinces')->onDelete('cascade');
$table->foreign('city_id')->references('id')->on('cities')->onDelete('cascade');
});
}
index.blade.php
<form action="{{ route('send') }}" method="post">
{{ csrf_field() }}
<div class="form-group" id="form-group-1">
<label for="mobile_number">mobile_number</label>
<input type="text" class="form-control" name="mobile_number" id="mobile_number">
</div>
<div class="form-group" id="form-group-2">
<label for="code">code</label>
<input type="text" class="form-control" name="code" id="code">
</div>
<div class="form-group">
<button type="submit" class="btn btn-danger" id="btn-ok">ok</button>
</div>
</form>
web.php
Route::get('/code', 'HomeController@code')->name('code');
Route::post('/send', 'HomeController@send')->name('send');
HomeController.php
public function send(Request $request)
{
$user = User::findOrFail($request);
$code = $request->code;
$mobile = $request->mobile;
$checkCode = User::whereCode($code)->first();
$checkMobile = User::whereCode($mobile)->first();
if ($checkCode == $checkMobile) {
$user(update->verification_code = 1);
alert()->success('ok', 'it is ok');
} else {
alert()->error('bye', 'it isn't ok');
}
return redirect()->back();
}
Please or to participate in this conversation.
