diff --git a/app/Console/Commands/InstallCommand.php b/app/Console/Commands/InstallCommand.php new file mode 100644 index 0000000..6302e91 --- /dev/null +++ b/app/Console/Commands/InstallCommand.php @@ -0,0 +1,92 @@ +writeLogo(); + + $name = $this->ask('What is your name?'); + $email = $this->ask('What is your email address?'); + $password = $this->secret('Please provide a new password'); + + if(empty($name) || empty($email) || empty($password)) { + $this->line(" WHOOPS 😳 \n"); + $this->error('Please provide the required information!'); + return; + } + + if ($this->confirm('Do you wish to generate the default brands and categories?', true)) { + $this->call('db:seed'); + } + + User::create(['name' => $name, 'email' => $email, 'password' => bcrypt($password)]); + + $this->line(" User created with email {$email} 🤙\n"); + + $this->writeWelcomeMessage(); + + return 0; + } + + public function writeLogo() + { + $asciiLogo = <<line("\n".$asciiLogo."\n"); + } + + public function writeWelcomeMessage() + { + if ($this->confirm('Would you like to show some love by supporting this project?')) { + if(PHP_OS_FAMILY == 'Darwin') exec('open https://opencollective.com/persona-finance'); + if(PHP_OS_FAMILY == 'Windows') exec('start https://opencollective.com/persona-finance'); + if(PHP_OS_FAMILY == 'Linux') exec('xdg-open https://opencollective.com/persona-finance'); + + $this->line("Thanks! Means the world to me!"); + } + } +} diff --git a/composer.json b/composer.json index 1b3e22c..b5c9d9f 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "facade/ignition": "^2.5", "fakerphp/faker": "^1.9.1", "laravel/breeze": "^1.6", - "laravel/sail": "^1.0.1", + "laravel/sail": "^1.12", "mockery/mockery": "^1.4.4", "nunomaduro/collision": "^5.10", "phpunit/phpunit": "^9.5.10" diff --git a/composer.lock b/composer.lock index dbba16d..88e6407 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1caea8d5daaa5b7e1e232b3ed2f275e0", + "content-hash": "27e92dadb12e6b3aadcd6ef2d17432db", "packages": [ { "name": "asm89/stack-cors", diff --git a/database/seeders/CategoryBrandSeeder.php b/database/seeders/CategoryBrandSeeder.php index a3396ac..2c64115 100644 --- a/database/seeders/CategoryBrandSeeder.php +++ b/database/seeders/CategoryBrandSeeder.php @@ -14,56 +14,42 @@ class CategoryBrandSeeder extends Seeder */ public function run() { - Category::create(['name' => 'Salary', 'type' => Category::INCOME]) + Category::create(['name' => 'Income', 'type' => Category::INCOME]) ->brands() ->create(['name' => 'Salary']); Category::create(['name' => 'Housing', 'type' => Category::EXPENSES]) ->brands() - ->create(['name' => 'Housing']); + ->create(['name' => 'House Rent']); Category::create(['name' => 'Groceries', 'type' => Category::EXPENSES]) ->brands() ->createMany([ ['name' => 'LULU'], - ['name' => 'ASWAAQ'], - ['name' => 'TUDO'], ['name' => 'CARREFOUR'], ]); Category::create(['name' => 'Utilities', 'type' => Category::EXPENSES]) ->brands() ->createMany([ - ['name' => 'ETISALAT'], ['name' => 'Smart Dubai'], ]); Category::create(['name' => 'Transportation', 'type' => Category::EXPENSES]) ->brands() ->createMany([ - ['name' => 'EMARAT'], - ['name' => 'Careem'], ['name' => 'ENOC'], ]); Category::create(['name' => 'Shopping', 'type' => Category::EXPENSES]) ->brands() ->createMany([ - ['name' => 'CHOCOLALA'], ['name' => 'IKEA'], ['name' => 'HOME CENTRE'], ['name' => 'MCDONALDS'], - ['name' => 'SUBWAY'], ]); - Category::create(['name' => 'Internet Subscription', 'type' => Category::EXPENSES]) - ->brands() - ->createMany([ - ['name' => 'FACEBK'], - ['name' => 'Google'], - ]); - - Category::create(['name' => 'Family Support', 'type' => Category::EXPENSES]) + Category::create(['name' => 'Support', 'type' => Category::EXPENSES]) ->brands() ->createMany([ ['name' => 'Family Support'], @@ -74,19 +60,5 @@ public function run() ->createMany([ ['name' => 'Debt'], ]); - - Category::create(['name' => 'Medicine', 'type' => Category::EXPENSES]) - ->brands() - ->createMany([ - ['name' => 'MEDICINA'], - ['name' => 'LIFE PHY'], - ['name' => 'IBN SINA'], - ]); - - Category::create(['name' => 'Others', 'type' => Category::EXPENSES]) - ->brands() - ->createMany([ - ['name' => 'Others'], - ]); } } diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..7e6d19d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,50 @@ +# For more information: https://laravel.com/docs/sail +version: '3' +services: + laravel.test: + build: + context: ./vendor/laravel/sail/runtimes/8.1 + dockerfile: Dockerfile + args: + WWWGROUP: '${WWWGROUP}' + image: sail-8.1/app + extra_hosts: + - 'host.docker.internal:host-gateway' + ports: + - '${APP_PORT:-80}:80' + environment: + WWWUSER: '${WWWUSER}' + LARAVEL_SAIL: 1 + XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}' + XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}' + volumes: + - '.:/var/www/html' + networks: + - sail + depends_on: + - mysql + mysql: + image: 'mysql/mysql-server:8.0' + ports: + - '${FORWARD_DB_PORT:-3306}:3306' + environment: + MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}' + MYSQL_ROOT_HOST: "%" + MYSQL_DATABASE: '${DB_DATABASE}' + MYSQL_USER: '${DB_USERNAME}' + MYSQL_PASSWORD: '${DB_PASSWORD}' + MYSQL_ALLOW_EMPTY_PASSWORD: 1 + volumes: + - 'sailmysql:/var/lib/mysql' + networks: + - sail + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-p${DB_PASSWORD}"] + retries: 3 + timeout: 5s +networks: + sail: + driver: bridge +volumes: + sailmysql: + driver: local