Skip to content

Instantly share code, notes, and snippets.

@MaheKarim
Created February 15, 2020 07:01
Show Gist options
  • Save MaheKarim/1ff0dc575af9b667758379b0db148297 to your computer and use it in GitHub Desktop.
Save MaheKarim/1ff0dc575af9b667758379b0db148297 to your computer and use it in GitHub Desktop.
$user_id = User::insertGetId([
'role_id' => 2,
'name' => $request->name,
'username' => $request->username,
'email' => $request->email,
'password' => Hash::make($request->password),
'phn_number' => $request->phn_number,
'created_at' => Carbon::now()
]);
if ($request->has('bmdc_cer')){
$bmdc_cer = $request->file('bmdc_cer')->store('doctor','public');
}
if ($request->has('nid_pic')){
$nid_pic = $request->file('nid_pic')->store('doctor','public');
}
Doctor::create([
'user_id' => $user_id,
'nid_pic' => $nid_pic,
'bmdc_cer' => $bmdc_cer,
'bmdc_reg_no' => $request->bmdc_reg_no,
'area_name_id' => $request->area_name_id
]);
if (Auth::attempt(['email' => $request->email, 'password' => $request->password]))
{
return redirect('/login');
}
return "Wel Done Mr Doctor"; // error message
}
public function Area()
{
return $this->belongsTo('App\Area', 'area_name_id','id');
}
public function up()
{
Schema::create('doctors', function (Blueprint $table) {
$table->bigIncrements('id');
$table->integer('user_id');
$table->string('present_address')->nullable();
$table->string('bmdc_reg_no')->nullable();
$table->longText('work_exp')->nullable();
$table->string('edu_degree')->nullable();
$table->longText('about_me')->nullable();
$table->string('bmdc_cer')->nullable();
$table->string('nid_pic')->nullable();
$table->integer('status')->default(1);
$table->integer('area_name_id')->nullable();
$table->integer('category_name_id')->nullable();
$table->timestamps();
});
}
<!-- Area start -->
<div class="form-group form-focus">
<label class="focus-label">Select Your Area</label>
<select name="area_name_id" class="form-control select">
@php($areas= \App\Area::all())
@foreach ($areas as $area)
<option {{ $area->id }}>{{$area->area_name}}</option>
@endforeach
</select>
</div>
<!-- Area END -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment