ข้ามไปอ่าน Laravel: AdminLTE จะอัพเดตกว่า
ผมเลือก AdminLTE มาใช้เป็น backend เพราะว่าเขียนโดยใช้ bootstrapt สวยพอประมาณ มีตัวอย่างเยอะ และที่สำคัญแจกฟรี และคุณ Sergi Tur Badenas แปลงให้ใช้กับ laravel 5 ไว้ให้เรียบร้อยแล้ว (framework อื่นก็มีครับ ตาม link ผมก็ใช้ใน YII2 อยู่เหมือนกัน)
ติดตั้งโดย
- เพิ่ม package acacha/adminlte-laravel ในไฟล์ composer.json[code language=”text” title=”composer.json”]
"require": {
…
"acacha/admin-lte-template-laravel": "2.*"
…
},[/code] - run command[code language=”text” title=”command”]composer update[/code]
- เปิดไฟล์ \config\app.php เพิ่ม[code language=”php” title=”\config\app.php”]
…
‘providers’ => [
…
Acacha\AdminLTETemplateLaravel\Providers\AdminLTETemplateServiceProvider::class,
App\Providers\RouteServiceProvider::class
…
],‘aliases’ => [
‘AdminLTE’ => Acacha\AdminLTETemplateLaravel\Facades\AdminLTE::class,
],[/code]
- Publish ไฟล์ไปโฟลเดอร์ public โดย run command[code language=”text” title=”command”]php artisan vendor:publish –tag=adminlte –force[/code]
สร้าง backend
- สร้างไฟล์ \app\Http\Controllers\AdminController.php[code language=”php” title=”\app\Http\Controllers\AdminController.php”]<?php
namespace App\Http\Controllers;
use App\User;
use App\Http\Controllers\Controller;class AdminController extends Controller {
/**
* Show the profile for the given user.
*/
public function index()
{
return view(‘home’);
}}
[/code] - เพิ่ม route ในไฟล์ \app\Http\routes.php[code language=”php” title=”\app\Http\routes.php”]
…
Route::get(‘admin/’, ‘[email protected]’);
…
[/code]
About the author