Skip to content

Commit 1183bf0

Browse files
Merge pull request #3 from ovidiustanc123/update
Update
2 parents e0dfbe7 + a42f2fe commit 1183bf0

File tree

18 files changed

+465
-56
lines changed

18 files changed

+465
-56
lines changed

app/Http/Livewire/ForgotPassword.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
namespace App\Http\Livewire;
4+
5+
use Illuminate\Http\Request;
6+
use Illuminate\Support\Facades\Password;
7+
use Livewire\Component;
8+
use App\Models\User;
9+
use Illuminate\Notifications\Notifiable;
10+
use App\Notifications\ResetPassword;
11+
12+
class ForgotPassword extends Component
13+
{
14+
use Notifiable;
15+
16+
public $mailSentAlert = false;
17+
public $email='';
18+
public $rules=[
19+
'email' => 'required|email|exists:users'
20+
];
21+
protected $messages = [
22+
'email.exists' => 'The Email Address must be in our database.',
23+
];
24+
public function routeNotificationForMail() {
25+
return $this->email;
26+
}
27+
public function recoverPassword() {
28+
$this->validate();
29+
$user=User::where('email', $this->email)->first();
30+
$this->notify(new ResetPassword($user->remember_token));
31+
$this->mailSentAlert = true;
32+
}
33+
34+
public function render()
35+
{
36+
return view('livewire.forgot-password')
37+
->layout('layouts.base');
38+
}
39+
}

app/Http/Livewire/Login.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,27 @@
66

77
class Login extends Component
88
{
9+
10+
public $email = '';
11+
public $password = '';
12+
13+
protected $rules = [
14+
'email' => 'required|email',
15+
'password' => 'required',
16+
];
17+
18+
public function login()
19+
{
20+
$credentials = $this->validate();
21+
return auth()->attempt($credentials)
22+
? redirect()->intended('/profile')
23+
: $this->addError('email', trans('auth.failed'));
24+
25+
}
26+
927
public function render()
1028
{
11-
return view('livewire.auth.login');
29+
return view('livewire.auth.login')
30+
->layout('layouts.base');
1231
}
1332
}

app/Http/Livewire/Profile.php

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,42 @@
22

33
namespace App\Http\Livewire;
44

5+
use App\Models\User;
56
use Livewire\Component;
67

78
class Profile extends Component
89
{
10+
public User $user;
11+
public $showSavedAlert = false;
12+
13+
protected $rules = [
14+
'user.first_name' => 'max:15',
15+
'user.last_name' => 'max:20',
16+
'user.birthday' => 'date_format:Y-m-d',
17+
'user.email' => 'email',
18+
'user.phone' => '',
19+
'user.gender' => '',
20+
'user.address' => '',
21+
'user.number' => '',
22+
'user.city' => '',
23+
'user.zip' => '',
24+
];
25+
26+
public function mount() { $this->user = auth()->user(); }
27+
28+
public function save()
29+
{
30+
$this->validate();
31+
32+
$this->user->save();
33+
34+
$this->showSavedAlert = true;
35+
}
36+
37+
938
public function render()
1039
{
11-
return view('livewire.profile');
40+
return view('livewire.profile')
41+
->layout('layouts.base');
1242
}
1343
}

app/Http/Livewire/Register.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,40 @@
33
namespace App\Http\Livewire;
44

55
use Livewire\Component;
6+
use App\Models\User;
7+
use Illuminate\Support\Facades\Hash;
8+
use Illuminate\Support\Str;
69

710
class Register extends Component
811
{
12+
13+
public $email = '';
14+
public $password = '';
15+
public $passwordConfirmation = '';
16+
17+
public function updatedEmail()
18+
{
19+
$this->validate(['email'=>'required|email|unique:users']);
20+
}
21+
22+
public function register()
23+
{
24+
$this->validate([
25+
'email' => 'required',
26+
'password' => 'required|same:passwordConfirmation|min:6',
27+
]);
28+
29+
$user = User::create([
30+
'email' =>$this->email,
31+
'password' => Hash::make($this->password),
32+
'remember_token' => Str::random(10),
33+
]);
34+
35+
auth()->login($user);
36+
37+
return redirect('/profile');
38+
}
39+
940
public function render()
1041
{
1142
return view('livewire.auth.register')

app/Http/Livewire/ResetPassword.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace App\Http\Livewire;
4+
5+
use Livewire\Component;
6+
7+
class ResetPassword extends Component
8+
{
9+
public $email = '';
10+
public $password = '';
11+
public $passwordConfirmation = '';
12+
13+
public $rules=[
14+
'email' => 'required|email|exists:users',
15+
'password' => 'required|same:passwordConfirmation|min:6',
16+
];
17+
protected $messages = [
18+
'email.exists' => 'The Email Address must be in our database.',
19+
];
20+
21+
public function resetPassword() {
22+
/////to do : add functionality here
23+
}
24+
25+
public function render()
26+
{
27+
return view('livewire.reset-password')
28+
->layout('layouts.base');
29+
}
30+
}

app/Models/User.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ class User extends Authenticatable
1616
*
1717
* @var array
1818
*/
19-
protected $fillable = [
19+
/* protected $fillable = [
2020
'name',
2121
'email',
2222
'password',
23-
];
23+
]; */
24+
protected $guarded=[];
2425

2526
/**
2627
* The attributes that should be hidden for arrays.

app/Notifications/ResetPassword.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
namespace App\Notifications;
4+
5+
use Illuminate\Bus\Queueable;
6+
use Illuminate\Contracts\Queue\ShouldQueue;
7+
use Illuminate\Notifications\Messages\MailMessage;
8+
use Illuminate\Notifications\Notification;
9+
use Illuminate\Http\Request;
10+
11+
class ResetPassword extends Notification
12+
{
13+
use Queueable;
14+
15+
public $token;
16+
17+
/**
18+
* Create a new notification instance.
19+
*
20+
* @return void
21+
*/
22+
public function __construct($token)
23+
{
24+
$this->token = $token;
25+
}
26+
27+
/**
28+
* Get the notification's delivery channels.
29+
*
30+
* @param mixed $notifiable
31+
* @return array
32+
*/
33+
public function via($notifiable)
34+
{
35+
return ['mail'];
36+
}
37+
38+
/**
39+
* Get the mail representation of the notification.
40+
*
41+
* @param mixed $notifiable
42+
* @return \Illuminate\Notifications\Messages\MailMessage
43+
*/
44+
public function toMail($notifiable)
45+
{
46+
return (new MailMessage)
47+
->subject('Reset your password')
48+
->line('Hey, did you forget your password? Click the button to reset it.')
49+
->action('Reset Password', url('reset-password', $this->token))
50+
->line('Thank you for using our application!');
51+
}
52+
53+
/**
54+
* Get the array representation of the notification.
55+
*
56+
* @param mixed $notifiable
57+
* @return array
58+
*/
59+
public function toArray($notifiable)
60+
{
61+
return [
62+
//
63+
];
64+
}
65+
}

database/factories/UserFactory.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,18 @@ class UserFactory extends Factory
2424
public function definition()
2525
{
2626
return [
27-
'First Name' => $this->faker->firstName(),
28-
'Last Name' => $this->faker->lastName(),
27+
'First_Name' => $this->faker->firstName(),
28+
'Last_Name' => $this->faker->lastName(),
2929
'Gender' => Arr::random(['male', 'female', 'other']),
3030
'email' => $this->faker->unique()->safeEmail(),
3131
'email_verified_at' => now(),
3232
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
3333
'Phone' => $this->faker->phoneNumber,
34+
'Birthday' => $this->faker->dateTimeThisCentury,
35+
'Address' => $this->faker->address,
36+
'City' => $this->faker->city,
37+
'ZIP' => $this->faker->randomNumber(6),
38+
'Number' => $this->faker->buildingNumber,
3439
'remember_token' => Str::random(10),
3540
];
3641
}

database/migrations/2014_10_12_000000_create_users_table.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,17 @@ public function up()
1515
{
1616
Schema::create('users', function (Blueprint $table) {
1717
$table->increments('id')->unique();
18-
$table->string('First Name')->nullable();
19-
$table->string('Last Name')->nullable();
18+
$table->string('First_Name')->nullable();
19+
$table->string('Last_Name')->nullable();
2020
$table->string('Gender')->nullable();
2121
$table->string('Email')->unique();
2222
$table->string('password');
23-
$table->string('Phone');
23+
$table->date('Birthday')->nullable();
24+
$table->string('Address')->nullable();
25+
$table->string('Number')->nullable();
26+
$table->string('City')->nullable();
27+
$table->string('ZIP')->nullable();
28+
$table->string('Phone')->nullable();
2429
$table->timestamp('email_verified_at')->nullable();
2530
$table->rememberToken();
2631
$table->timestamps();

public/assets/js/volt.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ d.addEventListener("DOMContentLoaded", function(event) {
140140

141141

142142
// Datepicker
143-
var datepickers = [].slice.call(d.querySelectorAll('[data-datepicker]'))
143+
var datepickers = [].slice.call(document.querySelectorAll('[data-datepicker]'))
144144
var datepickersList = datepickers.map(function (el) {
145145
return new Datepicker(el, {
146146
buttonClass: 'btn'

0 commit comments

Comments
 (0)