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' );
mingyukim / more-command example snippets
return [
'repository-namespace' => 'App' ,
'trait-namespace' => 'App' ,
'service-namespace' => 'App' ,
'view-root-path' => 'resources'
];
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);
}
public function all (array $columns = ['*' ], array $relations = [])
{
return parent ::all($columns, $relations);
}
public function firstOrNew (array $attributes = [], array $values = [])
{
return parent ::firstOrNew($attributes, $values);
}
public function firstOrCreate (array $attributes = [], array $values = [])
{
return parent ::firstOrCreate($attributes, $values);
}
public function insert ($arrItems)
{
return parent ::insert($arrItems);
}
public function create (array $attributes)
{
return parent ::create($attributes);
}
public function update ($id, array $attributes)
{
return parent ::update($id, $attributes);
}
public function updateOrCreate (array $attributes, array $values = [])
{
return parent ::updateOrCreate($attributes, $values);
}
public function delete ($ids)
{
return parent ::delete($ids);
}
}
namespace App \Traits ;
trait TestTrait
{
}
namespace App \Traits ;
trait TestSingleTonTrait
{
private static $instanse = null ;
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