Thursday, 13 May 2021

PHP define constant in class and use constant

https://www.php.net/manual/en/language.oop5.constants.php 

<?php

const ONE 1;
class 
foo {
    // Auto public
    const 
TWO ONE 2;
    const 
THREE ONE self::TWO;
    const 
SENTENCE 'The value of THREE is '.self::THREE;
}
?>

Example #4 Class constant visibility modifiers, as of PHP 7.1.0

<?php
class Foo {
    public const 
BAR 'bar';
    private const 
BAZ 'baz';
}
echo 
Foo::BARPHP_EOL;
echo 
Foo::BAZPHP_EOL;
?>
bar

Fatal error: Uncaught Error: Cannot access private const Foo::BAZ in …

Laravel JWTAuth plugin token time to live

Plugin

https://github.com/tymondesigns/jwt-auth/wiki/Installation


install composer require

config/jwt.php.

 /*
|--------------------------------------------------------------------------
| JWT time to live
|--------------------------------------------------------------------------
|
| Specify the length of time (in minutes) that the token will be valid for.
| Defaults to 1 hour
|
*/

'ttl' => 60,


// Get this value in code

auth()->factory()->getTTL()

Laravel Carbon getTimeStamp, getCurrentTime in PST, addMinuets

 Carbon::now()->timezone('America/Los_Angeles')->addMinutes(60)->timestamp



https://stackoverflow.com/questions/32719972/how-to-get-current-timestamp-from-carbon-in-laravel-5

https://stackoverflow.com/questions/44227007/laravel-where-with-carbon-addminutes-not-working

Wednesday, 12 May 2021

Use GoogleCatpchaV3 on local host

 Domains:

add your public IP

Make sure Verify the origin of reCAPTCHA solutions is unchecked




Vue JS npm run serve at specified port on Dev Mode

vue.config.js
module.exports = {
    devServer: {
        port: 3454    } 

}


https://reactgo.com/change-port-number-vue/ 

Access-control-allow-credential and ccess-Control-Allow-Headers x-xsrf-token

 https://stackoverflow.com/questions/38589944/angular2-x-xsrf-token-is-not-allowed-by-access-control-allow-headers



In my case I had to add the 'x-xsrf-token' value to 'Access-Control-Allow-Headers' header:

header('Access-Control-Allow-Headers: Content-Type, x-xsrf-token')


https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Credentials
Access-Control-Allow-Credentials: true


Laravel 5.7 ENV variable not read

// Clears application cache (Laravel's own redis like cache)

https://laravel.com/docs/4.2/cache#:~:text=Laravel%20provides%20a%20unified%20API,Redis%20out%20of%20the%20box.

//  To clear it 

php artisan cache:clear


// Including .env file, when you add new stuff make sure to call this

php artisan config:clear



https://stackoverflow.com/questions/43243732/laravel-5-env-always-returns-null

Other clear commands :

php artisan config:clear
php artisan cache:clear
php artisan view:clear
php artisan route:clear
composer dump-autoload