This is where your description should go. Take a look at contributing.md to see a to do list.
Via Composer
$ composer require lichris/blitz
<?php
namespace Api\V1\Models;
use Lichris\Blitz\Models\Model;
class User extends Model
{
// 모델 __construct(dbRecord) 시 존재하지 않는
// 열 (column) 을 자동적으로 제외합니다
// 예) new User(['asdf' => 1, 'id' => 1]) -> User(['id' => 1])
protected $filter = [
'id',
'uuid',
'email',
'password',
'name',
'nickname',
'phone_number',
];
// toArray() __toString() toJson() 시 출력되지 않아야할 필드들
protected $hidden = [
'id',
'email',
'password',
];
// 관계 모델
// __construct() 시 $filter 와 array_merge 되어 삽입
protected $relations = [
'alert_disable',
];
}
<?php
namespace Api\V1\Blitz;
use Api\V1\Models\User;
use Lichris\Blitz\Blitz;
/**
* Class UserRepository.
*/
class UserBlitz extends Blitz
{
protected $modelClass = User::class;
protected $table = 'users';
protected $name = '사용자';
protected $single = 'user';
protected $softDelete = true;
protected $relations = [
'alert_disable',
];
public function alertDisable()
{
// Query Builder 가 지원하는 함수 체이닝 해서 사용 가능합니다
return $this->hasOne(AlertDisableRepository::class, 'alert_disables', 'user_id')
->orderBy('id', 'desc');
}
}
<?php
namespace Api\V1\Controllers;
use Api\V1\Blitz\UserBlitz;
class UserController extends BaseController
{
public function test()
{
$uBlitz = new UserBlitz();
return view('test', [
'dump' => [
$uBlitz->whereIn('id', [1, 2, 3, 4])->first(),
$uBlitz->whereIn('id', [1, 2, 3, 4])->get(),
$uBlitz->find(1),
$uBlitz->find(1)->with(null),
],
]);
}
}
Please see the changelog for more information on what has changed recently.
Testing is not yet supported (in progress)
Please see contributing.md for details and a todolist.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
MIT. Please see the license file for more information.