Skip to content

Commit

Permalink
🎨 Add docker and install command
Browse files Browse the repository at this point in the history
  • Loading branch information
saleem-hadad committed Jan 15, 2022
1 parent 9a73e08 commit f3e53d7
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 33 deletions.
92 changes: 92 additions & 0 deletions app/Console/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php

namespace App\Console\Commands;

use App\Models\User;
use Illuminate\Console\Command;

class InstallCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'finance:install';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Init the finance app';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$this->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("<options=bold,reverse;fg=red> 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("<options=bold,reverse;fg=green> User created with email {$email} </> 🤙\n");

$this->writeWelcomeMessage();

return 0;
}

public function writeLogo()
{
$asciiLogo = <<<EOT
$$$$$$$$\ $$$$$$\ $$\ $$\ $$$$$$\ $$\ $$\ $$$$$$\ $$$$$$$$\
$$ _____|\_$$ _|$$$\ $$ |$$ __$$\ $$$\ $$ |$$ __$$\ $$ _____|
$$ | $$ | $$$$\ $$ |$$ / $$ |$$$$\ $$ |$$ / \__|$$ |
$$$$$\ $$ | $$ $$\$$ |$$$$$$$$ |$$ $$\$$ |$$ | $$$$$\
$$ __| $$ | $$ \$$$$ |$$ __$$ |$$ \$$$$ |$$ | $$ __|
$$ | $$ | $$ |\$$$ |$$ | $$ |$$ |\$$$ |$$ | $$\ $$ |
$$ | $$$$$$\ $$ | \$$ |$$ | $$ |$$ | \$$ |\$$$$$$ |$$$$$$$$\
\__| \______|\__| \__|\__| \__|\__| \__| \______/ \________|
EOT;

$this->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!");
}
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 3 additions & 31 deletions database/seeders/CategoryBrandSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -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'],
]);
}
}
50 changes: 50 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f3e53d7

Please sign in to comment.