laravel auto create uuid
1.0.0
작곡가를 통해 패키지를 설치할 수 있습니다.
composer require mindtwo/laravel-auto-create-uuid
웅변 모델에서 autocreateuuid 특성을 사용하기 만하면됩니다.
namespace example;
use Illuminate Database Eloquent Model ;
use mindtwo LaravelAutoCreateUuid AutoCreateUuid ;
class Example extends Model
{
use AutoCreateUuid ;
}
마이그레이션 파일에 열을 추가하십시오.
$ table -> string ( ' uuid ' , 36 )-> unique ();
자동 생성 UUID의 기본 속성 이름은 'uuid'입니다. 그러나 필요한 경우 사용자 정의 할 수 있습니다. 그렇게 할 수있는 두 가지 가능성이 있습니다.
'uuid_column'이라는 속성을 설정하십시오.
namespace example;
use Illuminate Database Eloquent Model ;
use mindtwo LaravelAutoCreateUuid AutoCreateUuid ;
class Example extends Model
{
use AutoCreateUuid ;
protected $ uuid_column = ' id '
}
또는 getuuidcolumn () 메소드를 과부하시킵니다.
namespace example;
use Illuminate Database Eloquent Model ;
use mindtwo LaravelAutoCreateUuid AutoCreateUuid ;
class Example extends Model
{
use AutoCreateUuid ;
/**
* Get the column name for uuid attribute.
*
* @return string
*/
public function getUuidColumn (): string
{
return ' id ' ;
}
}
두 경우 모두 UUID의 속성 이름은 이제 'uuid'대신 'id'입니다.
최근에 변경된 내용에 대한 자세한 내용은 Changelog를 참조하십시오.
자세한 내용은 기여를 참조하십시오.
보안 관련 문제를 발견하면 문제 추적기를 사용하는 대신 [email protected]로 이메일을 보내주십시오.
MIT 라이센스 (MIT). 자세한 내용은 라이센스 파일을 참조하십시오.