Skip to content

Commit

Permalink
框架加表
Browse files Browse the repository at this point in the history
  • Loading branch information
yudayue committed May 7, 2018
1 parent dcd0131 commit 221d952
Show file tree
Hide file tree
Showing 794 changed files with 105,353 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:X2HTFXYXez3RwZ5plFA220P8HrFtXtflp+8o6Lx1X5E=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=papershop
DB_USERNAME=root
DB_PASSWORD=root

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* text=auto
*.css linguist-vendored
*.scss linguist-vendored
*.js linguist-vendored
CHANGELOG.md export-ignore
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/node_modules
/public/hot
/public/storage
/storage/*.key
/.idea
/.vagrant
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
.env
/vendor
1 change: 1 addition & 0 deletions 1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3
96 changes: 96 additions & 0 deletions app/Admin/Controllers/ExampleController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?php

namespace App\Admin\Controllers;

use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Facades\Admin;
use Encore\Admin\Layout\Content;
use App\Http\Controllers\Controller;
use Encore\Admin\Controllers\ModelForm;

class ExampleController extends Controller
{
use ModelForm;

/**
* Index interface.
*
* @return Content
*/
public function index()
{
return Admin::content(function (Content $content) {

$content->header('header');
$content->description('description');

$content->body($this->grid());
});
}

/**
* Edit interface.
*
* @param $id
* @return Content
*/
public function edit($id)
{
return Admin::content(function (Content $content) use ($id) {

$content->header('header');
$content->description('description');

$content->body($this->form()->edit($id));
});
}

/**
* Create interface.
*
* @return Content
*/
public function create()
{
return Admin::content(function (Content $content) {

$content->header('header');
$content->description('description');

$content->body($this->form());
});
}

/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Admin::grid(YourModel::class, function (Grid $grid) {

$grid->id('ID')->sortable();

$grid->created_at();
$grid->updated_at();
});
}

/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
return Admin::form(YourModel::class, function (Form $form) {

$form->display('id', 'ID');

$form->display('created_at', 'Created At');
$form->display('updated_at', 'Updated At');
});
}
}
39 changes: 39 additions & 0 deletions app/Admin/Controllers/HomeController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace App\Admin\Controllers;

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

class HomeController extends Controller
{
public function index()
{
return Admin::content(function (Content $content) {

$content->header('Dashboard');
$content->description('Description...');

$content->row(Dashboard::title());

$content->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());
});
});
});
}
}
47 changes: 47 additions & 0 deletions app/Admin/Extensions/Column/ExpandRow.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace App\Admin\Extensions\Column;

use Encore\Admin\Admin;
use Encore\Admin\Grid\Displayers\AbstractDisplayer;

class ExpandRow extends AbstractDisplayer
{
public function display(\Closure $callback = null, $btn = '')
{
$callback = $callback->bindTo($this->row);

$html = call_user_func($callback);

$script = <<<EOT
$('.grid-expand').on('click', function () {
if ($(this).data('inserted') == '0') {
var key = $(this).data('key');
var row = $(this).closest('tr');
var html = $('template.grid-expand-'+key).html();
row.after("<tr><td colspan='"+row.find('td').length+"' style='padding:0 !important; border:0px;'>"+html+"</td></tr>");
$(this).data('inserted', 1);
}
$("i", this).toggleClass("fa-caret-right fa-caret-down");
});
EOT;
Admin::script($script);

$btn = $btn ?: $this->column->getName();

$key = $this->getKey();

return <<<EOT
<a class="btn btn-xs btn-default grid-expand" data-inserted="0" data-key="{$key}" data-toggle="collapse" data-target="#grid-collapse-{$key}">
<i class="fa fa-caret-right"></i> $btn
</a>
<template class="grid-expand-{$key}">
<div id="grid-collapse-{$key}" class="collapse">$html</div>
</template>
EOT;
}
}
30 changes: 30 additions & 0 deletions app/Admin/Extensions/WangEditor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace App\Admin\Extensions;

use Encore\Admin\Form\Field;

class WangEditor extends Field
{
protected $view = 'admin::form.editor';

protected static $css = [
'/packages/wangEditor-2.1.23/dist/css/wangEditor.min.css',
];

protected static $js = [
'/packages/wangEditor-2.1.23/dist/js/wangEditor.min.js',
];

public function render()
{
$this->script = <<<EOT
var editor = new wangEditor('{$this->id}');
editor.create();
EOT;
return parent::render();

}
}
25 changes: 25 additions & 0 deletions app/Admin/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?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');
*
*/
// sqc添加
use App\Admin\Extensions\Column\ExpandRow;
use Encore\Admin\Grid\Column;
Column::extend('expand', ExpandRow::class);

Encore\Admin\Form::forget(['map', 'editor']);
24 changes: 24 additions & 0 deletions app/Admin/routes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?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');

//商品管理
$router->resource('goods', GoodsController::class);
//用户表管理
$router->resource('user', UserController::class);
//收货地址表管理
$router->resource('addresses', AddressesController::class);
//积分商品表管理
$router->resource('point_good', Point_GoodsController::class);


});
64 changes: 64 additions & 0 deletions app/Console/Commands/AutoCompleteOrder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

namespace App\Console\Commands;

use App\Models\Order;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;

class AutoCompleteOrder extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'order:autocomplete';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
//
Carbon::setToStringFormat('Y-m-d');

$inSchoolTime = Carbon::now()->subDays(5);
$outSchoolTime = Carbon::now()->subDays(10);
DB::table('order')
->where([
['status', '=', Order::STATUS_DELIVERING],
['sid', '<>', 0 ],
])
->whereDate('updated_at', '<=', $inSchoolTime)
->update(['status' => Order::STATUS_COMPLETED]);

DB::table('order')
->where([
['status', '=', Order::STATUS_DELIVERING],
['sid', '=', 0 ],
])
->whereDate('updated_at', '<=', $outSchoolTime)
->update(['status' => Order::STATUS_COMPLETED]);
}
}
Loading

0 comments on commit 221d952

Please sign in to comment.