Thursday, 1 May 2025

DAY24 Create FrontEnd Home101

13 Dec 2024
66

สวัสดีครับวันนี้เราจะมาสร้างหน้าเว็บกันครับ ซึ่งเราจะทิ้งหลังบ้านไว้ก่อน โดยมาสร้าง controller ก่อน ด้วยคำสั่ง

php artisan make:UserController

จากนั้นระบบจะสรา้ง controller ให้แล้วเราก็นำ use App\Http\Controllers\UserController; ไปวางที่ web.php

จากนั้นก็ปิด route เดิมที่ชี้ไป /   แล้วก็ทำ route ใหม่ ที่ web.php

Route::get(‘/’, [UserController::class, ‘index’]);

set route home frontend

set route home frontend

จากนั้นก็ไปเขียน function ให้ชี้ไปที่ welcome

class UserController extends Controller
{
    public function index(){
        return view(‘frontend.frontend_dashboard’);
    } //end method
}

 

สร้าง folder frontend ที่ view  และสรา้ง folder ใน C:\xampp\htdocs\project\realestate\public\frontend   ด้วย  แล้วสร้าง view ขึ้นมาที่ views โดยตั้งชื่อว่า frontend_dashboard.blade.php

จากนั้นก็มาแก้โหลด css/js กันครับ

{{ asset (‘frontend/’)}}