Similar Posts

  • PHP Artsan CLI Command For Laravel

    🔹 Laravel 11 Extensions & Packages Laravel has many useful extensions (packages) to enhance its functionality. Here are some commonly used ones: 1️⃣ Authentication & Security 🔹 Laravel Sanctum (API Authentication) 📌 Used for: Token-based API authentication. 🔹 Laravel Breeze (Simple Authentication) 📌 Used for: Lightweight authentication (Login, Register, Forgot Password). 🔹 Laravel Jetstream (Advanced…

  • Performance across different technologies for building REST APIs

    When comparing performance across different technologies for building REST APIs (Python, Java with Servlets, Java Spring Boot, and PHP with PDO), there are several factors to consider, such as scalability, speed, ease of development, and suitability for your specific use case. However, performance can vary significantly depending on your specific application and infrastructure. 1. Python…

  • insert existing users with plain-text passwords into Laravel’s users table

    To insert existing users with plain-text passwords into Laravel’s users table (used by Laravel Breeze authentication), follow these steps: ✅ Step 1: Hash Passwords Before Inserting Since Laravel requires bcrypt hashed passwords, you need to hash them before inserting into the users table. You can do this in a Laravel command, seeder, or migration script….

  • การเชื่อมต่อฐานข้อมูลใน Laravel

    Laravel รองรับการเชื่อมต่อฐานข้อมูลผ่าน Eloquent ORM และ Query Builder ซึ่งสามารถทำงานร่วมกับฐานข้อมูลหลายประเภท เช่น MySQL, PostgreSQL, SQLite และ SQL Server 1️⃣ การตั้งค่าการเชื่อมต่อฐานข้อมูล ไฟล์การตั้งค่าฐานข้อมูลใน Laravel อยู่ที่ 📌 1.1 ตั้งค่าในไฟล์ .env เปิดไฟล์ .env และตั้งค่าการเชื่อมต่อฐานข้อมูล เช่น MySQL 🔹 เปลี่ยนค่า DB_DATABASE, DB_USERNAME, และ DB_PASSWORD ตามค่าจริงของคุณ 🔹 ถ้าใช้ SQLite, ให้แก้เป็น (หรือใช้ database/database.sqlite ในโปรเจกต์) 📌 1.2 ตั้งค่าใน config/database.php แม้ว่าจะไม่ค่อยต้องแก้ไฟล์นี้ แต่ถ้าต้องการกำหนดค่าเพิ่มเติม สามารถแก้ได้ที่ ⚠️ หมายเหตุ: 2️⃣ ทดสอบการเชื่อมต่อฐานข้อมูล หลังจากตั้งค่าแล้ว…

  • Generate a Model from an Existing Migration in Laravel

    To auto-create a model from a migration file in Laravel, follow these steps: 1. Generate a Model from an Existing Migration Run the following command: For example, if your table is inventories, run: 2. Generate a Model with a Migration and Factory (if needed) If you haven’t created a migration yet and want to generate…

  • Controller ใน Laravel คืออะไร?

    📌 Controller เป็นส่วนหนึ่งของโครงสร้าง MVC (Model-View-Controller) ใน Laravel ทำหน้าที่รับคำขอจากผู้ใช้ (Request) และควบคุมการทำงานของระบบ โดยสามารถประมวลผลข้อมูลจาก Model และส่งผลลัพธ์ไปแสดงใน View 📌 MVC โครงสร้างใน Laravel 📌 การสร้าง Controller ใน Laravel เราสามารถสร้าง Controller ได้โดยใช้คำสั่ง Artisan คำสั่งนี้จะสร้างไฟล์ที่ app/Http/Controllers/ProductController.php 📌 ตัวอย่าง Controller (app/Http/Controllers/ProductController.php) 📌 การกำหนด Route ให้ Controller Laravel ใช้ Route เพื่อเชื่อมโยง URL กับ Controllerให้ไปที่ routes/web.php และเพิ่มโค้ดต่อไปนี้: 📌 Route::resource() จะสร้าง Route ทั้งหมดให้อัตโนมัติ ได้แก่ HTTP Method…

Leave a Reply

Your email address will not be published. Required fields are marked *