<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Notifications\SlackNotification;
use Illuminate\Support\Facades\Notification;
use Illuminate\Support\Facades\Log;

abstract class BaseCommand extends Command
{
    /**
     * Create a command instance with the environment loaded in.
     *
     * @return void
     */
    public function __construct()
    {
        // When doing commands the environment requires reloading.
        app()->loadEnvironmentFrom(base_path('.env'));

        if(env('APP_ENV', null) === null) {
            Log::debug('Failed to load .env locally, attempting `/etc/creatia/`');
            app()->loadEnvironmentFrom('/etc/creatia/');
        }

        parent::__construct();
    }

    /**
     * Send a notification.
     *
     * @return void
     */
    public static function notify($_message)
    {
        Notification::route('slack', env('SLACK_HOOK'))->notify(new SlackNotification($_message));
    }

   
}
