0916 라라벨 create() 와,$fillable, 컴포넌트 만들기(생성자 함수가...

0916 라라벨 create() 와,$fillable, 컴포넌트 만들기(생성자 함수가...

css js 변경점 complie

npm run dev->>> npm run watch -->> 변경점 자동으로 컴파일. 패키징해줌

php artisan make:component PostShow

--> PostShow php 파일(클래스임)과 , post-show.blade.php 파일을 둘다 만들어줌......

app/view/component

이미지 찾을때 public은 default

/storage/images/{{ $post->image}}

method="post" form 태그 소문자로 적기.....

@csrf 꼭 붙이기...

db에 저장시,

protected $fillable = [

"title",

"content",

"user_id",

"image"

//parameter 로 많이많이와도, 여기 명시될 칼럼만 변경시켜줌

];

$post-> save() 대신에..

Post::create();

를 썼어요

이때 mass assignment (대량 할당 외 처리)로 기술해야함

대응되는 eloquent model 에 white list 인 protected $fillable -->> 에 기술하지 않으면 , 사용하지않을 칼럼명 지정

명시적으로 정의된 컬럼외에는 배열에 값이 있어도 무시하게 되므로 description 에 설정한 값은 입력되지 않는다

반대는 guarded

이게귀찮으면 save() 하기전에 post->어쩌구 저쩌구 save하기.

----> create() 하면 반환이 배열로 옴!!!!!!!!! 그래서 $fillable 에 칼럼을 명시하는것 ㅇㅇ 누가 손대지못하게

from http://habbang0.tistory.com/84 by ccl(A) rewrite - 2021-09-16 17:00:57