PHP code example of mingyukim / more-command

1. Go to this page and download the library: Download mingyukim/more-command library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mingyukim / more-command example snippets



return [
    'repository-namespace' => 'App', // 저장소 클래스에 대한 원하는 네임스페이스
    'trait-namespace' => 'App', // Traits에 대한 원하는 네임스페이스
    'service-namespace' => 'App', // 서비스에 대한 원하는 네임스페이스   
    'view-root-path' => 'resources' // Blade 템플릿 생성 장소. view-root-path/views/ 하위에 생성됨.
];



namespace App\Repositories;

use App\Models\Test;
use App\Repositories\BaseTemplate\BaseRepository;
use App\Repositories\BaseTemplate\RepositoryInterface;

class TestRepository extends BaseRepository implements RepositoryInterface
{
    public function __construct(Test $model = null)
    {
        if($model == null) {
            $model = new Test();
        }
        parent::__construct($model);
    }

    public function findById($id, array $columns = ['*'], array $relations = [])
    {
        return parent::findById($id, $columns, $relations); // TODO: Change the autogenerated stub
    }

    public function all(array $columns = ['*'], array $relations = [])
    {
        return parent::all($columns, $relations); // TODO: Change the autogenerated stub
    }

    public function firstOrNew(array $attributes = [], array $values = [])
    {
        return parent::firstOrNew($attributes, $values); // TODO: Change the autogenerated stub
    }

    public function firstOrCreate(array $attributes = [], array $values = [])
    {
        return parent::firstOrCreate($attributes, $values); // TODO: Change the autogenerated stub
    }

    public function insert($arrItems)
    {
        return parent::insert($arrItems); // TODO: Change the autogenerated stub
    }

    public function create(array $attributes)
    {
        return parent::create($attributes); // TODO: Change the autogenerated stub
    }

    public function update($id, array $attributes)
    {
        return parent::update($id, $attributes); // TODO: Change the autogenerated stub
    }

    public function updateOrCreate(array $attributes, array $values = [])
    {
        return parent::updateOrCreate($attributes, $values); // TODO: Change the autogenerated stub
    }

    public function delete($ids)
    {
        return parent::delete($ids); // TODO: Change the autogenerated stub
    }

}



namespace App\Traits;

trait TestTrait
{

}




namespace App\Traits;

trait TestSingleTonTrait
{
    private static $instanse = null;

    /**
     *
     * @return self
     */
    static function getInstance()
    {
        if (self::$instanse == null) {
            self::$instanse = new self;
        }

        return self::$instanse;
    }
}





namespace App\Services;

use App\Repositories\TestRepository;

class TestService
{
    protected $repository;

    public function __construct(TestRepository $repository)
    {
        $this->repository = $repository;
    }

    public function getAllTest()
    {
        return $this->repository->all();
    }

    public function createTest(array $data)
    {
        return $this->repository->create($data);
    }

    public function updateTest(mixed $id, array $data)
    {
        return $this->repository->update($id, $data);
    }

    public function deleteTest(mixed $ids)
    {
        return $this->repository->delete($ids);
    }
    
}

shell
 php artisan vendor:publish --provider="MingyuKim\MoreCommand\MoreCommandProvider" --tag="config"
shell
php artisan make:repositories
shell
php artisan make:repository TestRepository
shell
php artisan make:service TestService
shell
php artisan make:view testview

/resources/views/testview.blade.php