-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdoc.txt
18 lines (18 loc) · 1.25 KB
/
doc.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
first we created project
go to laravel official web and search laravel sanctum, copy installation command (php artisan install:api)
after all we add some code in api.php and remove web.php home route code
We run this command (php artisan make:model -h) (php artisan make:model Post -a --api)
we add some code in POst.php model
we go to post migration file and add column there and we run migrate command
we worked on Postcontroller
we add all functionality in methods
create controller named AuthController
created method under this controller
we add routes and after we run this command (php artisan route:list)
we add relation into post & user model
we add foreign id in post migration table
we renamed this code into ($post = $request->user()->posts()->create($fields);) under postcontroller store function
after we run this command to add migrate command successfully (php artisan migrate:fresh)
and then we have to implement HasMiddleware into postController
all functionality working fine with userToken but if other user can delete with his token the post will be deleted for this we went to policies folder under PostPolicy we hide all method instead last one and updated this one
after all we went to postController and added gateFacade under update and destroy method