Written by
php-style
on
on
Laravel(라라벨)에서 모델에서 참조하는 기본 Table 명 및 PK 변경하기
Laravel(라라벨)에서 모델에서 참조하는 기본 Table 명 및 PK 변경하기
참고 url : https://laravel.kr/docs/7.x/eloquent#Primary%20Keys
라라벨에는 모델명과 동일한 테이블명을 자동으로 참고하지만,
수작업으로 변경해야 할 때가 있다.
그럴땐 모델파일을 열고
아래 4줄을 추가한다.
protected $table = "tableSample";
protected $primaryKey = 'pkSample';
public $incrementing = false; // pk가 auto-increment인지 아닌지를 명시
protected $keyType = 'string'; // pk가 int형이 아닌경우 string 명시
from http://gonpress.tistory.com/33 by ccl(A) rewrite - 2020-04-22 16:00:58