Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

Commit

Permalink
安裝 laravel-admin 後台
Browse files Browse the repository at this point in the history
  • Loading branch information
tad0616 committed May 20, 2019
1 parent e05a847 commit 725c52d
Show file tree
Hide file tree
Showing 290 changed files with 21,532 additions and 1 deletion.
10 changes: 10 additions & 0 deletions app/Admin/Controllers/AuthController.php
@@ -0,0 +1,10 @@
<?php

namespace App\Admin\Controllers;

use Encore\Admin\Controllers\AuthController as BaseAuthController;

class AuthController extends BaseAuthController
{

}
122 changes: 122 additions & 0 deletions app/Admin/Controllers/ExampleController.php
@@ -0,0 +1,122 @@
<?php

namespace App\Admin\Controllers;

use App\Http\Controllers\Controller;
use Encore\Admin\Controllers\HasResourceActions;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Layout\Content;
use Encore\Admin\Show;

class ExampleController extends Controller
{
use HasResourceActions;

/**
* Index interface.
*
* @param Content $content
* @return Content
*/
public function index(Content $content)
{
return $content
->header('Index')
->description('description')
->body($this->grid());
}

/**
* Show interface.
*
* @param mixed $id
* @param Content $content
* @return Content
*/
public function show($id, Content $content)
{
return $content
->header('Detail')
->description('description')
->body($this->detail($id));
}

/**
* Edit interface.
*
* @param mixed $id
* @param Content $content
* @return Content
*/
public function edit($id, Content $content)
{
return $content
->header('Edit')
->description('description')
->body($this->form()->edit($id));
}

/**
* Create interface.
*
* @param Content $content
* @return Content
*/
public function create(Content $content)
{
return $content
->header('Create')
->description('description')
->body($this->form());
}

/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
$grid = new Grid(new YourModel);

$grid->id('ID')->sortable();
$grid->created_at('Created at');
$grid->updated_at('Updated at');

return $grid;
}

/**
* Make a show builder.
*
* @param mixed $id
* @return Show
*/
protected function detail($id)
{
$show = new Show(YourModel::findOrFail($id));

$show->id('ID');
$show->created_at('Created at');
$show->updated_at('Updated at');

return $show;
}

/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
$form = new Form(new YourModel);

$form->display('id', 'ID');
$form->display('created_at', 'Created At');
$form->display('updated_at', 'Updated At');

return $form;
}
}
34 changes: 34 additions & 0 deletions app/Admin/Controllers/HomeController.php
@@ -0,0 +1,34 @@
<?php

namespace App\Admin\Controllers;

use App\Http\Controllers\Controller;
use Encore\Admin\Controllers\Dashboard;
use Encore\Admin\Layout\Column;
use Encore\Admin\Layout\Content;
use Encore\Admin\Layout\Row;

class HomeController extends Controller
{
public function index(Content $content)
{
return $content
->header('Dashboard')
->description('Description...')
->row(Dashboard::title())
->row(function (Row $row) {

$row->column(4, function (Column $column) {
$column->append(Dashboard::environment());
});

$row->column(4, function (Column $column) {
$column->append(Dashboard::extensions());
});

$row->column(4, function (Column $column) {
$column->append(Dashboard::dependencies());
});
});
}
}
21 changes: 21 additions & 0 deletions app/Admin/bootstrap.php
@@ -0,0 +1,21 @@
<?php

/**
* Laravel-admin - admin builder based on Laravel.
* @author z-song <https://github.com/z-song>
*
* Bootstraper for Admin.
*
* Here you can remove builtin form field:
* Encore\Admin\Form::forget(['map', 'editor']);
*
* Or extend custom form field:
* Encore\Admin\Form::extend('php', PHPEditor::class);
*
* Or require js and css assets:
* Admin::css('/packages/prettydocs/css/styles.css');
* Admin::js('/packages/prettydocs/js/main.js');
*
*/

Encore\Admin\Form::forget(['map', 'editor']);
15 changes: 15 additions & 0 deletions app/Admin/routes.php
@@ -0,0 +1,15 @@
<?php

use Illuminate\Routing\Router;

Admin::registerAuthRoutes();

Route::group([
'prefix' => config('admin.route.prefix'),
'namespace' => config('admin.route.namespace'),
'middleware' => config('admin.route.middleware'),
], function (Router $router) {

$router->get('/', 'HomeController@index')->name('admin.home');

});
1 change: 1 addition & 0 deletions composer.json
Expand Up @@ -10,6 +10,7 @@
"require": {
"php": "^7.1.3",
"caouecs/laravel-lang": "~4.0",
"encore/laravel-admin": "^1.6",
"fideloper/proxy": "^4.0",
"laravel/framework": "5.8.*",
"laravel/tinker": "^1.0"
Expand Down

0 comments on commit 725c52d

Please sign in to comment.