PHP/Larabel

Route Get

WS.GI 2023. 7. 17. 16:00
여러분의 후원은 큰 힘이 됩니다. 기업은행 35611080101018
반응형

Client -> FTController -> Controller 

web : 주로 일반 페이지만 불러오는 곳

Route : 페이지 이동 및 Controller 연결

Controller : 페이지 이동 및 복잡한 데이터처리.


get 방식

 

1. Route::get('path', [ controller name::class,'function name']); 

Route::get('get', [Amain::class, 'index']);

ex ) 

/routes/web.php

use App\Http\Controllers\standard\main as Amain;

Route::get('path', [ controller name::class,'function name']); 

Route::get('get', [Amain::class, 'index']);

 

App/Http/Controllers/standard/main.php

public function index(){
   // /resources/views/welcome.blade.php 을 가르킨다.
   return view("welcome");
}

 

2. Route::get('path', function(){ }); 

Route::get('get/{id}', function ($id) {
   // return view('standard.header').view('welcome').view('standard.footer');
   // /resources/views/welcome.blade.php를 가르킨다.
   return view('welcome',['id' => $id]);
});

ex ) 

routes/web.php

Route::get('get/{id}', function ($id) {
   // return view('standard.header').view('welcome').view('standard.footer');
   // /resources/views/welcome.blade.php를 가르킨다.
   return view('welcome',['id' => $id]);
});

 

/resources/views/welcome.blade.php

<div class="">
   {{ $id }}
</div>

 

 

반응형