欢迎各位兄弟 发布技术文章
这里的技术是共享的
"require": { "laravel/framework": "4.2.*", "frozennode/administrator": "dev-master" },
composer update
'Frozennode\Administrator\AdministratorServiceProvider',
php artisan config:publish frozennode/administrator php artisan asset:publish frozennode/administrator
$env = $app->detectEnvironment(array( 'local' => array('homestead','myComputer'), ));
"require-dev": { "way/generators": "~2.0" },
'Way\Generators\GeneratorsServiceProvider'
php artisan generate:migration create_users_table --fields="username:string, email:string, password:string" php artisan generate:seed user
<?php class UserTableSeeder extends Seeder { public function run() { User::create([ 'username' => 'admin', 'email' => 'admin@mysite.com', 'password' => Hash::make('thepass'), 'created_at' => new DateTime(), 'updated_at' => new DateTime() ]); } }
$this->call('UserTableSeeder');
php artisan migrate php artisan db:seed
php artisan generate:controller LoginController
Route::controller('/login', 'LoginController');
<?php class LoginController extends \BaseController { public function getIndex() { return View::make('login.index'); } public function postIndex() { $username = Input::get('username'); $password = Input::get('password'); if (Auth::attempt(['username' => $username, 'password' => $password])) { return Redirect::intended('/admin'); } return Redirect::back() ->withInput() ->withErrors('Username or Password are incorrect.'); } }
php artisan generate:view layouts.master
<!DOCTYPE html> <html lang='en'> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta charset="utf-8"> <meta name='viewport' content='width=device-width, initial-scale=1'> <title>@yield('title')</title> <link rel='stylesheet' href='//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css'> <style> body { margin-top: 10px; } </style> </head> <body> <div class='container-fluid'> <div class='row'> @yield('content') </div> </div> </body> </html>
php artisan generate:view login.index
@extends('layouts.master') @section('title') Login @stop @section('content') <div class="col-md-4 col-md-offset-4"> <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title">Please sign in</h3> </div> <div class="panel-body"> @if ($errors->has()) @foreach ($errors->all() as $error) <div class='alert-danger alert'>{{ $error }}</div> @endforeach @endif {{ Form::open(['role' => 'form']) }} <fieldset> <div class="form-group"> {{ Form::text('username', null, ['placeholder' => 'Username', 'class' => 'form-control']) }} </div> <div class="form-group"> {{ Form::password('password', ['placeholder' => 'Password', 'class' => 'form-control']) }} </div> {{ Form::submit('Login', ['class' => 'btn btn-primary']) }} </fieldset> {{ Form::close() }} </div> </div> </div> @stop
cd app/config mkdir administrator cd administrator mkdir settings
'menu' => array('users'), 'home_page' => 'users', 'login_path' => 'login',
<?php /** * Users model config */ return array( 'title' => 'Users', 'single' => 'user', 'model' => 'User', 'columns' => array( 'email' => array( 'title' => 'Email', ), 'username' => array( 'title' => 'First Name', ), ), 'edit_fields' => array( 'email' => array( 'title' => 'Email', 'type' => 'text', ), 'username' => array( 'title' => 'Username', 'type' => 'text', ), 'password' => array( 'title' => 'Password', 'type' => 'password', ), ), );
188128412