This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// belongs to - one to one - one to many - many to mayn | |
class PostModel extends Model | |
{ | |
protected $fillable =['title','des','user_id']; | |
public function user(){ | |
return $this->belongsTo(User::class); | |
// return User::findOrFail($this->user_id); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new laravel --auth | |
//add custom lib ---------------------------------------------------- | |
npm install @fortawesome/fontawesome-free --save // icon library V:5.13 | |
// in resource css app.scss add | |
@import '~@fortawesome/fontawesome-free/scss/fontawesome'; | |
@import '~@fortawesome/fontawesome-free/scss/regular'; | |
@import '~@fortawesome/fontawesome-free/scss/solid'; | |
@import '~@fortawesome/fontawesome-free/scss/brands'; | |
---------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// important in localhost : | |
MAIL_USERNAME=bambboapp@gmail.com | |
MAIL_PASSWORD=112859112859 | |
MAIL_ENCRYPTION=tls | |
MAIL_DRIVER=smtp | |
MAIL_HOST=smtp.gmail.com | |
MAIL_PORT=587 | |
MAIL_FROM_ADDRESS=bambboapp@gmail.com | |
MAIL_FROM_NAME=bambboapp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
php artisan make:event RegisterUser // this event actioned | |
// in class EventServiceProvider | |
protected $listen =[ | |
Registered::class=>[ | |
SendEmailVerificationNotification::class, | |
], | |
RegisterUser::class=>[ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$user=auth()->user(); | |
$post=Post::where('user_id',1)->first(); | |
$allow=\Gate::allows('update-post',$post); // not need to send user it use current logined user | |
// if user not logined allow is false | |
// if you want to user another user for check a gate | |
$allow=\Gate::forUser(User::find(2))->allows('update-post',$post); | |
if($allow){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
---in file config queue you should change QUEUE_CONNECTION------> in env QUEUE_CONNECTION=database -------> reset config env in command | |
php artisan queue:table // create a migration for jobs | |
php artisan make:job SendVerificationEmailJob | |
// where you want to do : | |
SendVerificationEmailJob.dispatch($user); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// very important | |
1- use | |
Content-Type: application/json | |
Accept: application/json | |
** you should for every request set customRequest | |
in all of your api client request. | |
2- to avoid show server error in client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this file contain 3 part | |
//1-simple auth system rest api with mobile | |
//3-simple auth system rest api with email | |
//3- passport api auth system - we do not use default auth laravel beacuse it is session base | |
// add $table->string('api_token')->nullable(); to user migration | |
// 1 - With Mobile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
composer require laravel/passport | |
php artisan migrate | |
php artisan passport:install | |
//2- in Class AuthServiceProvider: | |
public function boot() | |
{ | |
$this->registerPolicies(); | |
Passport::routes(); // if you donot want to user route comment this line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://ourcodeworld.com/articles/read/374/how-to-download-the-source-code-js-css-and-images-of-a-website-through-its-url-web-scraping-with-node-js | |
npm install website-scraper | |
// create a file index.js | |
const scrape = require('website-scraper'); | |
let options = { |