<?php

namespace Dipper\Console\Commands;

use Dipper\Console\Command;
use Dipper\Console\Filesystem;
use Symfony\Component\Console\Command\Command as SymfonyCommand;

/**
 * @author HollyTeng <n.haoyuan@gmail.com>
 */
class StorageLinkCommand extends SymfonyCommand
{
    use Command;
    use Filesystem;

    /**
     * The console command name.
     *
     * @var string
     */
    protected $name = 'storage:link';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Create a symbolic link from "public/storage" to "storage/app/public"';

    /**
     * Execute the console command.
     *
     * @return bool|null
     */
    public function fire()
    {
        if (file_exists(public_path('storage'))) {
            return $this->error('The "public/storage" directory already exists.');
        }

        $this->link(
            storage_path('app/public'),
            public_path('storage')
        );

        $this->info('The [public/storage] directory has been linked.');
    }
}
