2026/04 7

Laravel 06. Eloquent ORM

Eloquent ( 읽기 쉬운 )ORM (Object Relational Mapping) 라라벨은 데이터를 객체로 만들어 다루게 해줍니다. 기존 PHP 에서 다음과 같은 sql 문으로 데이터를 가져옵니다.SELECT * FROM trucks; Model테이블Model행(row)객체컬럼속성 라라벨에서는Post::all(); 모델생성php artisan make:model TruckKind 대문자로 시작하고, 두개 단어를 쓸때는 각각 대문자를 써주면 _ 로 구분된 테이블이 생성됩니다. 생성된 위치는app/Models/TruckKind.php 기본구조 보통은 migration 파일을 함께 생성하여 사용합니다. ** 삭제하고 다시 만들어보겠습니다.php artisan make:model Truck..

Laravel 05. Database Design & Migrations

데이터베이스 설계“데이터를 어떤 형태로 저장할지 미리 정의하는 것” posts 테이블컬럼 타입 설명 idbigint기본키titlestring제목contenttext내용created_attimestamp생성일updated_attimestamp수정일 Migration (테이블 생성)라라벨은 Sql 문으로 테이블을 생성하는 것이 아니라 코드로 생성합니다. php artisan make:migration create_posts_table id(); $table->timestamps(); }); } /** * Reverse the migrations. */ public function down(): void { Schema::dro..

카테고리 없음 2026.04.22

Laravel 04. Blade Templete

Blade는 Laravel의 템플릿 엔진입니다. 1. 기본 사용방법 기본위치resources/views 파일 확장자.blade.php 변수의 출력{{ $name }}Lagacy PHP 2. 왜 blade 는 별도의 문법을 가지고 있는가?1) 가독성 PHP BLADE@if($user) @foreach($items as $item) @endforeach@endif 2) HTML 중심 개발 가능마크업 중심협업 쉬움 3) 추가기능- 권한- 데이터가 없을때@auth..@endauth@guest..@endguest@isset($data)..@endisset@forelse($items as $item)..@empty....@endforelse * * * * Huda * * * * 3. 블래이드 ..

Laravel 03. Controller

1. Controller"로직을 처리하는 부분""사용자 요청을 받아 모델(Model)과 상호작용하고, 결과를 뷰(View)나 JSON으로 반환하는 '중간 관리자' 역할을 수행" 1.1 컨트롤러 생성php artisan make:controller PostController# INFO Controller [app/Http/Controllers/PostController.php] created successfully. 생성위치 app/Http/Controllers/PostController.php 1.2 컨트롤러 구조 1.3 Route 와 ControllerRoute::get('/posts', [ShipmentController::class, 'index']); // 목록Route::get('/pos..

Laravel 02. Routing

1. Route1.1 why Route ? PHP 프로젝트에서 우리는 /경로/php파일명을 URL 로 접근할 수 있습니다. /aboutus/aboutus01.php파일/aboutus/aboutus01.php 브라우저 경로http://url.com/aboutus/aboutus01.php 1) 복잡한 URL 을 간결하게 바꿀수 있다.http://teddy.school.com/board/list.php?board_id=study&step=view&bid=23=> http://teddy.school.com/board/study/23 2) 보안을 위해 직접 php 파일에 접근을 차단한다.http://url.com/aboutus.phphttp://url.com/aboutus.blade.php ( x ) ..