[Laravel] 3장 Eloquent ORM을 이용한 데이터베이스 쿼리 및 관계 설정
1. 모델 생성Laravel의 Eloquent ORM을 사용해 데이터베이스 쿼리 및 관계 설정을 하는 방법을 설명합니다. Eloquent는 Laravel의 ORM으로, 데이터베이스와의 상호작용을 쉽게 해줍니다. 먼저 Eloquent 모델을 생성합니다.php artisan make:model Post -mphp artisan make:model Comment -m 2. 마이그레이션 설정database/migrations 폴더에 생성된 마이그레이션 파일을 열어 게시글과 댓글 테이블을 설정합니다.create_posts_table.phppublic function up(): void { Schema::create('posts', function (Blueprint $table) { ..