tungpt / base-api
基于仓库模式的Base API Laravel应用程序
dev-main
2023-04-07 09:05 UTC
Requires
- laravel/framework: ~7.0|~8.0|~9.0
This package is not auto-updated.
Last update: 2024-09-20 16:02:25 UTC
README
此软件包可以帮助您创建一个基于仓库模式的Base API Laravel应用程序
安装
composer require tungpt/base-api:dev-main
提供命令
创建API控制器
php artisan make:tcontroller ControllerName
<?php
namespace App\Http\Controllers\Api;
use Illuminate\Http\Request;
use Tungpt\Base\BaseApiController;
class ControllerName extends BaseApiController
{
/**
* Construct example
*
public function __construct(Service $service)
{
$this->service = $service;
}
*/
public function __construct()
{
// Inject service here
}
}
创建仓库
php artisan make:repository RepositoryName
<?php
namespace App\Repositories;
use Tungpt\Base\BaseRepository;
class RepositoryName extends BaseRepository
{
public function getModel()
{
// Return model instance here
// return new Model();
}
}
创建服务
php artisan make:service ServiceName
<?php
namespace App\Services;
use Tungpt\Base\BaseService;
class ServiceName extends BaseService
{
/**
* Construct example
*
public function __construct(Repository $repository)
{
$this->repository = $repository;
}
*/
public function __construct()
{
// Inject repository here
}
}
许可证
MIT许可证。 阅读此处