Somehow you need to run a different implementation depending on system environment
This is what i have done for one of my case
In your .env file
DOCUMENT_INTERFACE=GoogleCloud
#DOCUMENT_INTERFACE=LocalStorage
In my AppServiceProvider.php
use Illuminate\Support\Facades\App;
public function register()
{
$this->app->bind(DocumentInterface::class, function () {
...
Thursday, 31 October 2019
Thursday, 17 October 2019
Command needed when installing MySQL
MySQL command not found? Looking tru this forum https://stackoverflow.com/questions/10577374/mysql-command-not-found-in-os-x-10-7
echo 'export PATH="/usr/local/mysql/bin:$PATH"' >> ~/.bash_profile
To connect to MySQL prompt
mysql -u root -p
Change the MySQL password permanently
mysql -u root -p
ALTER USER `root`@`localhost` IDENTIFIED BY 'password', `root`@`localhost`...
Wednesday, 24 July 2019
The Date Problem for Laravel and Regional Settings
For every Laravel application birthday should be displayed as it was saved.
It should have a type 'date' and those 'created_at' should be 'datetime'
From New Zealand the record could be created Friday but for Cooks Island
the record can be Thursday entry.
This is where PHP Carbon date comes to uses and Javascript Moments.
Install Moment and format as required. In VueJS create a filter
import...
Monday, 8 July 2019
Laravel Eloquent Relationship 101
Laravel uses the default 'id' as the primary key when defining table.
With this in mind we will be having difficulty especially if we are using
Laravel eager loading style as stated in stackoverflow.
In order to have that peace of mind when loading fields
it is safer to create a different id key for different
table. This is how to go with that approach.
For our parent migration script we...
Thursday, 13 June 2019
Useful terminal commands for MAC, Ubuntu or Windows
Search specific type of file in all folder
find ~ -type f -name '*pdf'
find ~ -iname '*pdf'
Search specific type of file in current folder
find . -iname '*pdf'
Make file executable
chmod +x file.xx'
Run PHPFixer on current folder
php-cs-fixer fix --diff --dry-run --stop-on-violation -v --using-cache=no
php-cs-fixer fix --stop-on-violation -v --using-cache=no
Make your git branch...
Monday, 27 May 2019
Country Package for Laravel
It is often or not we need a country listing in our package to display in the view or dropdown HTML component. Instead of creating table of coutries we could use a proven PHP package library to do that.
I come across this library league/iso3166 and have use it ever since.
Methods you can use are:
#to define the library
use League\ISO3166\ISO3166;
#to get all countries
$countries...
Wednesday, 23 January 2019
PHP Number to Romans Numeral conversion
Just Playing with PHP lately and thought of a Digit to Roman Numerals conversion.
This is one of my testing exam before and just recall how I did it.
$romanString = '';
$value = 975;
do {
$converted = convertToRoman($value);
$value = $converted[0];
$romanString = $romanString . $converted[1];
} while ( $value != 0);
echo $romanString;
function convertToRoman($number){
$returnValue...