git clone <url>
cd Auth-in-Laravel
composer install
npm i
or
bun install
- Migrate the DB files into your DB
php artisan migrate
- Also Seed some Fake Data into you Tables using this commande:
php artisan db:seed --class=PostSeeder
- for Lunch The App use this commande to create listen port
php artisan serve
- create a user in
http:/localhost:8000/register
add some posts for this user using Auth::id()- You can inserted them in you DB manuelle or use
php artisan tinker
for add post for your user using ORM(Elequont). - after that you can see in
http://127.0.0.1:8000/dashboard/posts
all posts for that user
- You can inserted them in you DB manuelle or use
- web.php int this file you can see in line 40 & 43 the two routes you will use for the test this exercices.
first config you app in .env change the mail driver to mailtrap
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=username
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="[email protected]"
second in this file Controller
you can see the function sendEmail
that will send an email to the user with the order details.
change the email for test this function.
public function sendEmail()
{
Mail::to('<email>')->send(new OrderShip(Auth::id(), Auth::user()->name, Auth::user()->email));
echo 'good, email sent successfully!';
}
for the body of the email you can modify it in this file view body of the email
finally enter this route will send email for you address
http:/localhost:8000/send-email
i guess you have already config you app for the email so this time all files are ready for you you should just search for the user that have your email for test it in this file Notification controller
or you can notify all users using this code
public function testN(){
$users = User::get();
Notification::send($users, new test());
}
http:/localhost:8000/notify
just try to create new user and this user will had an email when he register if you have some trouble for test email service in your app go to mailtrap.io and create an account and get the SMTP credentials and change the .env file with the new credentials