Posts

Anonymous Migrations in Laravel

id(); $table->timestamps(); }); } /** * Reverse the migrations. */ public function down(): void { Schema::dropIfExists('posts'); } };

Default virtual hosts file in laragon - etc\apache2\sites-enabled\00-default.conf

contents of etc\apache2\sites-enabled\00-default.conf file: AllowOverride All Require all granted

Points

How are two objects compared in PHP? PHP provides you with the ‘==’ operator, which is used to compare two objects at a time. This is used to check if there is a common presence of attributes and values between the objects in comparison. The ‘===’ operator is also used to compare if both objects in consideration are referencing to the same class. $ob2= (object)['t'=>'m']; $ob1= (object)['t'=>'m']; echo ($ob1 == $ob2); Result: 1 ---------------------------------------------------

Add select columns after already adding select

Use: $query->addSelect([])

Storage link not working on laravel another system

delete previously create symlink and run: php artisan storage:link

Import db in mysql using command line

mysql> mysql -u root -p mysql> use your_db_name; mysql> source /parth/yourfile file.sql; (note - don't enclose path in double and single quotes)

Laravel Models

Create model php artisan make:model Flight

Debug request in laravel

$request->all();

bash: cake: command not found

Add ./ befor cake example: ./cake bake all

Install plugin from git if version is not known

Add ":*" at the end of command Example: "composer require dereuromark/cakephp-queue:*"

Template literals (Template strings) Js

Template literals are enclosed by the backtick (` `) (grave accent) character instead of double or single quotes // Untagged, these create strings: `string text` `string text line 1 `string text ${expression} string text`

Policies in laravel

Create policy using artisan command: 1. php artisan make:policy PostPolicy 2. php artisan make:policy PostPolicy --model=Post here PostPolicy is poilcy name and Post is model name

Laravel Seeders

Run Seeders 1. This command runs the Database\Seeders\DatabaseSeeder class, which may in turn invoke other seed classes: php artisan db:seed 2. --class option to specify a specific seeder class to run individually: php artisan db:seed --class=UserSeeder 3. Fresh Migrate and seed to delete all tables and recreate with data: php artisan migrate:fresh --seed Create Seeders 1. php artisan make:seeder seederclassname Example: php artisan make:seeder UserSeeder

How to authenticate request postman

Add header Authorization: Bearer token here

Personal access client not found. Please create one - RuntimeException laravel

php artisan passport:install

message \storage\oauth-private.key" does not exist or is not readable"

Run: php artisan passport:install This command will create the encryption keys needed to generate secure access tokens.This will create "personal access" and "password grant" clients which will be used to generate access tokens. php artisan passport:client --personal This command may be used to create your own clients for testing your auth functionality.

Save email to local folder Xampp

sendmail_path = "\xampp\mailtodisk\mailtodisk.exe"

React Don't Do's

1. You may see people using componentWillMount to start AJAX calls to load data for your components. Don’t do this. We’ll get to that in the second.

If you click on child element but not on parent

Add this check: if (e.target === this) { //action here }

Laravel API

Run api: php artisan serve