wesley.chen il y a 7 ans
Parent
commit
97d1b18f15

+ 138 - 0
app/Http/Controllers/Admin/Introduction/InfoController.php

xqd
@@ -0,0 +1,138 @@
+<?php
+/**
+ *  使用说明
+ *  @author  system
+ *  @version    1.0
+ *  @date 2018-06-07 07:34:45
+ *
+ */
+namespace App\Http\Controllers\Admin\Introduction;
+use App\Http\Controllers\Admin\Controller;
+use Illuminate\Http\Request;
+use App\Repositories\Base\Criteria\OrderBy;
+use App\Repositories\Introduction\Criteria\MultiWhere;
+use App\Repositories\Introduction\InfoRepository;
+
+class InfoController extends Controller
+{
+    private $repository;
+
+    public function __construct(InfoRepository $repository) {
+        if(!$this->repository) $this->repository = $repository;
+    }
+
+    function index(Request $request) {
+        $search['keyword'] = $request->input('keyword');
+        $query = $this->repository->pushCriteria(new MultiWhere($search));
+
+        if(isset($request['sort_field']) && $request['sort_field'] && isset($request['sort_field_by'])) {
+        $query = $query->pushCriteria(new OrderBy($request['sort_field'],$request['sort_field_by']));
+        }else{
+            $query = $query->pushCriteria(new OrderBy('id','DESC'));
+        }
+        $list = $query->paginate();
+        return view('admin.introduction.info.index',compact('list'));
+    }
+
+
+    function check(Request $request) {
+        $request = $request->all();
+        $search['keyword'] = $request->input('keyword');
+        $orderby = array();
+        if(isset($request['sort_field']) && $request['sort_field'] && isset($request['sort_field_by'])) {
+            $orderby[$request['sort_field']] = $request['sort_field_by'];
+        }
+        $list = $this->repository->search($search,$orderby);
+        return view('admin.introduction.info.check',compact('list'));
+    }
+
+
+    /**
+     * 添加
+     * 
+     */
+    public function create(Request $request)
+    {
+        if($request->method() == 'POST') {
+            return $this->_createSave();
+        }
+        return view('admin.introduction.info.edit');
+    }
+
+    /**
+     * 保存修改
+     */
+    private function _createSave(){
+        $data = (array) request('data');
+        $id = $this->repository->create($data);
+        if($id) {
+            $url[] = array('url'=>U( 'Introduction/Info/index'),'title'=>'返回列表');
+            $url[] = array('url'=>U( 'Introduction/Info/create'),'title'=>'继续添加');
+            $this->showMessage('添加成功',$url);
+        }else{
+            $url[] = array('url'=>U( 'Introduction/Info/index'),'title'=>'返回列表');
+            return $this->showWarning('添加失败',$url);
+        }
+    }
+    
+    /**
+     * 
+     * 修改
+     * 
+     * 
+     */
+    public function update(Request $request) {
+        if($request->method() == 'POST') {
+            return $this->_updateSave();
+        }
+        $data = $this->repository->find($request->get('id'));
+        return view('admin.introduction.info.edit',compact('data'));
+    }
+
+    /**
+     * 保存修改
+     */
+    private function _updateSave() {
+        $data = (array) request('data');
+        $ok = $this->repository->update(request('id'),$data);
+        if($ok) {
+            $url[] = array('url'=>U( 'Introduction/Info/index'),'title'=>'返回列表');
+            return $this->showMessage('操作成功',urldecode(request('_referer')));
+        }else{
+            $url[] = array('url'=>U( 'Introduction/Info/index'),'title'=>'返回列表');
+            return $this->showWarning('操作失败',$url);
+        }
+    }
+
+    public function view(Request $request) {
+        $data = $this->repository->find(request('id'));
+        return view('admin.introduction.info.view',compact('data'));
+    }
+
+
+    /**
+     *
+     * 状态改变
+     *
+     */
+    public function status(Request $request) {
+        $ok = $this->repository->updateStatus(request('id'),request('status'));
+        if($ok) {
+            return $this->showMessage('操作成功');
+        }else{
+            return $this->showWarning('操作失败');
+        }
+    }
+    
+    /**
+     * 删除
+     */
+    public function destroy(Request $request) {
+        $bool = $this->repository->destroy($request->get('id'));
+        if($bool) {
+            return  $this->showMessage('操作成功');
+        }else{
+            return  $this->showWarning("操作失败");
+        }
+    }
+}

+ 47 - 0
app/Models/IntroductionInfoModel.php

xqd
@@ -0,0 +1,47 @@
+<?php
+namespace App\Models;
+use App\Models\BaseModel;
+/**
+ *  @description 使用说明
+ *  @author  system;
+ *  @version    1.0
+ *  @date 2018-06-07 07:34:45
+ *
+ */
+class IntroductionInfoModel extends BaseModel
+{
+    /**
+     * 数据表名
+     *
+     * @var string
+     *
+     */
+    protected $table = 'introduction_info';
+    /**
+    主键
+     */
+    protected $primaryKey = 'id';
+
+    //分页
+    protected $perPage = PAGE_NUMS;
+
+    /**
+     * 可以被集体附值的表的字段
+     *
+     * @var string
+     */
+    protected $fillable = [
+                           'title',
+                           'content',
+                           'type'
+                          ];
+
+    public function type(){
+        if((new IntroductionInfoModel())->find($this->id)->type == 0){
+            return '使用说明';
+        }else{
+            return '使用协议';
+        }
+    }
+
+}

+ 45 - 0
app/Repositories/Introduction/Criteria/MultiWhere.php

xqd
@@ -0,0 +1,45 @@
+<?php
+/**
+ * User: Mike
+ * Email: m@9026.com
+ * Date: 2017/1/12
+ * Time: 17:52
+ */
+
+namespace App\Repositories\Introduction\Criteria;
+
+
+
+
+use App\Repositories\Base\Criteria;
+use App\Repositories\Contracts\RepositoryInterface as Repository;
+
+class MultiWhere extends Criteria {
+
+    private $search = [];
+
+    /**
+     * MultiWhere constructor.
+     * @param array $search
+     *
+     */
+    public function __construct(array $search)
+    {
+        $this->search = $search;
+    }
+
+    /**
+    * @param $model
+    * @param RepositoryInterface $repository
+    * @return mixed
+    */
+    public function apply($model, Repository $repository)
+    {
+          if(isset($this->search['updated_at']) && $this->search['updated_at']) {
+                                    $model = $model->where('updated_at',$this->search['updated_at']);
+                                 }
+
+         return $model;
+    }
+
+}

+ 21 - 0
app/Repositories/Introduction/InfoRepository.php

xqd
@@ -0,0 +1,21 @@
+<?php
+/**
+ *   使用说明
+ *  @author  system
+ *  @version    1.0
+ *  @date 2018-06-07 07:34:45
+ *
+ */
+namespace App\Repositories\Introduction;
+
+use App\Repositories\Base\Repository;
+
+
+class InfoRepository extends Repository {
+
+    public function model() {
+        return \App\Models\IntroductionInfoModel::class;
+    }
+
+    
+}

+ 1 - 1
app/Repositories/Query/Criteria/MultiWhere.php

xqd
@@ -40,7 +40,7 @@ class MultiWhere extends Criteria {
                 ->orWhere('is_paid','like','%' . $this->search['keyword'] . '%')
                 ->orWhere('cnumber','like','%' . $this->search['keyword'] . '%')
                 ->orWhere('grade','like','%' . $this->search['keyword'] . '%')
-                ->orWhere('created_at','like','%' . $this->search['keyword'] . '%')
+                ->orWhere('code','like','%' . $this->search['keyword'] . '%')
                 ->orWhere('mobile','like','%' . $this->search['keyword'] . '%');
         }
 

+ 32 - 0
database/migrations/2018_06_07_064822_add_code_to_query_info.php

xqd
@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddCodeToQueryInfo extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('query_info', function (Blueprint $table) {
+            $table->string('code',64)->after('grade')->nullable()->comment('推荐码');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('query_info', function (Blueprint $table) {
+            //
+        });
+    }
+}

+ 36 - 0
database/migrations/2018_06_07_071107_create_introduction_info_table.php

xqd
@@ -0,0 +1,36 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateIntroductionInfoTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('introduction_info', function (Blueprint $table) {
+            $table->increments('id');
+            $table->string('title',255)->comment('标题');
+            $table->text('content')->comment('内容');
+            $table->tinyInteger('type')->comment('0:使用说明;1:协议');
+
+            $table->softDeletes();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('introduction_info');
+    }
+}

+ 86 - 0
resources/views/admin/introduction/info/check.blade.php

xqd
@@ -0,0 +1,86 @@
+@extends('admin.layout')
+
+@section('content')
+		<div class="row">
+			<div class="col-sm-12">
+				<div class="ibox float-e-margins">
+					<div class="ibox-title">
+						<h5>使用说明</h5>
+						<div class="ibox-tools">
+							<a class="collapse-link"> <i class="fa fa-chevron-up"></i>
+							</a>
+						</div>
+					</div>
+					<div class="ibox-content">
+						<div class="row">
+							<form method="GET" action="" accept-charset="UTF-8">
+
+								<div class="col-sm-4">
+									<div class="input-group">
+										<input type="text" value="{{Request::get('keyword')}}"	placeholder="请输入关键词" name="keyword"class="input-sm form-control">
+								<span class="input-group-btn">
+									<button type="submit" class="btn btn-sm btn-primary">搜索</button>
+								</span>
+									</div>
+								</div>
+							</form>
+							@if(role('Introduction/Info/create'))
+								<div class="col-sm-3 pull-right">
+									<a href="{{ U('Introduction/Info/create')}}" class="btn btn-sm btn-primary pull-right">添加</a>
+								</div>
+							@endif
+						</div>
+
+						<table class="table table-striped table-bordered table-hover dataTables-example dataTable dataCheckTable">
+							<thead>
+							<tr>
+								<th><input class="btSelectAll" name="btSelectAll" type="checkbox"></th>
+								
+            <th class="sorting" data-sort="id">  </th>
+            <th class="sorting" data-sort="title"> 标题 </th>
+            <th class="sorting" data-sort="type"> 0:使用说明;1:协议 </th>
+            <th class="sorting" data-sort="created_at">  </th>
+            <th class="sorting" data-sort="updated_at">  </th>
+								<th width="22%">相关操作</th>
+							</tr>
+							</thead>
+							<tbody>
+							@if(isset($list))
+								@foreach($list as $key => $item)
+									<tr>
+									<td><input data-json='{!! json_encode($item) !!}'  name="btSelectItem" class="data_key" type="checkbox" value="{{ $item->id or 0 }}" /></td>
+									
+            <td>{{ $item->id }}</td>
+            <td>{{ $item->title }}</td>
+            <td>{{ $item->type }}</td>
+            <td>{{ $item->created_at }}</td>
+            <td>{{ $item->updated_at }}</td>
+									<td>
+										@if(role('Introduction/Info/view'))
+											<button onclick="layer.open({type: 2,area: ['80%', '90%'],content: '{{ U('Introduction/Info/view',['id'=>$item->id])}}'});"  class="btn btn-primary ">查看</button>
+										@endif
+									</td>
+								</tr>
+								@endforeach
+							@endif
+
+							</tbody>
+						</table>
+						<div class="row">
+							<div class="col-sm-6">
+								<div class="dataTables_info" id="DataTables_Table_0_info"
+									 role="alert" aria-live="polite" aria-relevant="all">每页{{ $list->count() }}条,共{{ $list->lastPage() }}页,总{{ $list->total() }}条。</div>
+							</div>
+							<div class="col-sm-6">
+								<div class="dataTables_paginate paging_simple_numbers" id="DataTables_Table_0_paginate">
+									{!! $list->setPath('')->appends(Request::all())->render() !!}
+								</div>
+							</div>
+						</div>
+					</div>
+				</div>
+			</div>
+		</div>
+	@include('admin.tools.check_script');
+
+@endsection

+ 97 - 0
resources/views/admin/introduction/info/edit.blade.php

xqd
@@ -0,0 +1,97 @@
+@extends('admin.layout')
+
+@section('content')
+
+    <?php
+    if (!isset($data)) $data = array();
+    if (!$data && session("data")) {
+        $data = session("data");
+    }
+    if (!$data && session('_old_input')) {
+        $data = session("_old_input");
+    }
+    ?>
+    <div class="row">
+        <div class="col-sm-12">
+            <div class="ibox float-e-margins">
+                <div class="ibox-title">
+                    <h5>使用说明</h5>
+                    <div class="ibox-tools">
+                        <a class="collapse-link"> <i class="fa fa-chevron-up"></i>
+                        </a>
+                    </div>
+                </div>
+                <div class="ibox-content">
+                    @if(role('Introduction/Info/index'))
+                        <div class="row">
+                            <div class="col-sm-3 pull-right">
+                                <a href="{{ U('Introduction/Info/index')}}" class="btn btn-sm btn-primary pull-right">返回列表</a>
+                            </div>
+                        </div>
+                    @endif
+
+                    <div class="row">
+                        <div class="col-lg-10">
+                            <form name="form_product" id="form-validation" action=""
+                                  class="form-horizontal form-validation" accept-charset="UTF-8" method="post">
+
+
+                                <div class="form-group">
+
+                                    <label class="control-label col-sm-3">标题</label>
+
+                                    <div class="col-sm-9">
+                                        <input id="data_title" name="data[title]" class="form-control"
+                                               value="{{ $data['title'] or ''}}" required="" aria-required="true"
+                                               placeholder="">
+                                    </div>
+
+                                </div>
+                                <div class="form-group">
+
+                                    <label class="control-label col-sm-3">内容</label>
+
+                                    <div class="col-sm-9">
+                                        {!! editor('') !!}
+
+                                        <script id="container" name="data[content]"
+                                                type="text/plain">{!!  $data['content'] or ''!!} </script>
+
+                                    </div>
+
+                                </div>
+                                <div class="form-group">
+
+                                    <label class="control-label col-sm-3">0:使用说明;1:协议</label>
+
+                                    <div class="col-sm-9">
+                                        <select id="data_type" name="data[type]" class="form-control">
+                                            <option value='{{ $data['type'] or 0}}'>使用说明</option>
+                                            <option value='{{ $data['type'] or 1}}'>使用协议</option>
+                                        </select>
+                                    </div>
+
+                                </div>
+
+                                <div class="form-group">
+                                    <label class="control-label col-sm-3">&nbsp;</label>
+                                    <div class="col-sm-9">
+                                        <input type="hidden" name="_referer"
+                                               value="<?php echo urlencode(request()->server('HTTP_REFERER'));?>"/>
+                                        <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>"/>
+                                        <input type="submit" class="btn btn-success" style="margin-right:20px;">
+                                        <input type="reset" class="btn btn-default">
+                                    </div>
+                                </div>
+
+                            </form>
+                        </div>
+                        <!-- /.col-lg-10 -->
+                    </div>
+                    <!-- /.row -->
+                </div>
+            </div>
+        </div>
+    </div>
+
+@endsection

+ 109 - 0
resources/views/admin/introduction/info/index.blade.php

xqd
@@ -0,0 +1,109 @@
+@extends('admin.layout')
+
+@section('content')
+    <div class="row">
+        <div class="col-sm-12">
+            <div class="ibox float-e-margins">
+                <div class="ibox-title">
+                    <h5>使用说明</h5>
+                    <div class="ibox-tools">
+                        <a class="collapse-link"> <i class="fa fa-chevron-up"></i>
+                        </a>
+                    </div>
+                </div>
+                <div class="ibox-content">
+                    <div class="row">
+                        <form method="GET" action="" accept-charset="UTF-8">
+
+                            <div class="col-sm-4">
+                                <div class="input-group">
+                                    <input type="text" value="{{Request::get('keyword')}}" placeholder="请输入关键词"
+                                           name="keyword" class="input-sm form-control">
+                                    <span class="input-group-btn">
+									<button type="submit" class="btn btn-sm btn-primary">搜索</button>
+								</span>
+                                </div>
+                            </div>
+                        </form>
+                        @if(role('Introduction/Info/create'))
+                            <div class="col-sm-3 pull-right">
+                                <a href="{{ U('Introduction/Info/create')}}" class="btn btn-sm btn-primary pull-right">添加</a>
+                            </div>
+                        @endif
+                    </div>
+
+                    <table class="table table-striped table-bordered table-hover dataTables-example dataTable">
+                        <thead>
+                        <tr>
+
+                            <th class="sorting" data-sort="id">ID</th>
+                            <th class="sorting" data-sort="title"> 标题</th>
+                            <th class="sorting" data-sort="type">类型</th>
+                            <th class="sorting" data-sort="created_at">创建时间</th>
+                            <th class="sorting" data-sort="updated_at">更新时间</th>
+                            <th width="22%">相关操作</th>
+                        </tr>
+                        </thead>
+                        <tbody>
+                        @if(isset($list))
+                            @foreach($list as $key => $item)
+                                <tr>
+
+                                    <td>{{ $item->id }}</td>
+                                    <td>{{ $item->title }}</td>
+                                    <td>{{ $item->type() }}</td>
+                                    <td>{{ $item->created_at }}</td>
+                                    <td>{{ $item->updated_at }}</td>
+                                    <td>
+                                        <div class="btn-group">
+                                            <button data-toggle="dropdown"
+                                                    class="btn btn-warning btn-sm dropdown-toggle"
+                                                    aria-expanded="false">
+                                                操作 <span class="caret"></span>
+                                            </button>
+                                            <ul class="dropdown-menu">
+
+
+                                                @if(role('Introduction/Info/update'))
+                                                    <li><a href="{{ U('Introduction/Info/update',['id'=>$item->id])}}"
+                                                           class="font-bold">修改</a></li>
+                                                @endif
+
+                                                @if(role('Introduction/Info/destroy'))
+                                                    <li class="divider"></li>
+                                                    <li><a href="{{ U('Introduction/Info/destroy',['id'=>$item->id])}}"
+                                                           onclick="return confirm('你确定执行删除操作?');">删除</a></li>
+                                                @endif
+
+                                            </ul>
+                                        </div>
+                                        @if(role('Introduction/Info/view'))
+                                            <button onclick="layer.open({type: 2,area: ['80%', '90%'],content: '{{ U('Introduction/Info/view',['id'=>$item->id])}}'});"
+                                                    class="btn btn-primary ">查看
+                                            </button>
+                                        @endif
+                                    </td>
+                                </tr>
+                            @endforeach
+                        @endif
+
+                        </tbody>
+                    </table>
+                    <div class="row">
+                        <div class="col-sm-6">
+                            <div class="dataTables_info" id="DataTables_Table_0_info"
+                                 role="alert" aria-live="polite" aria-relevant="all">每页{{ $list->count() }}
+                                条,共{{ $list->lastPage() }}页,总{{ $list->total() }}条。
+                            </div>
+                        </div>
+                        <div class="col-sm-6">
+                            <div class="dataTables_paginate paging_simple_numbers" id="DataTables_Table_0_paginate">
+                                {!! $list->setPath('')->appends(Request::all())->render() !!}
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+@endsection

+ 40 - 0
resources/views/admin/introduction/info/view.blade.php

xqd
@@ -0,0 +1,40 @@
+@extends('admin.layout')
+
+@section('content')
+<div class="row">
+    <div class="ibox-content">
+        <div class="list-group">
+
+               <div class="list-group-item">
+                                                  
+                   <h3 class="list-group-item-heading">标题</h3>
+                                                   
+                   <p class="list-group-item-text"> {{ $data['title'] or ''}}</p>
+                                                 
+               </div>                     
+               <div class="list-group-item">
+                                                  
+                   <h3 class="list-group-item-heading">内容</h3>
+                                                   
+                   <p class="list-group-item-text"> {!!  $data['content'] or '' !!} </p>
+                                                 
+               </div>
+
+               <div class="list-group-item">
+                                                  
+                   <h3 class="list-group-item-heading">创建时间</h3>
+                                                   
+                   <p class="list-group-item-text"> {{ $data['created_at'] or ''}}</p>
+                                                 
+               </div>                     
+               <div class="list-group-item">
+                                                  
+                   <h3 class="list-group-item-heading">更新时间</h3>
+                                                   
+                   <p class="list-group-item-text"> {{ $data['updated_at'] or ''}}</p>
+                                                 
+               </div>
+        </div>
+    </div>
+</div>
+@endsection

+ 3 - 1
resources/views/admin/query/info/index.blade.php

xqd xqd xqd
@@ -17,7 +17,7 @@
 
                             <div class="col-sm-4">
                                 <div class="input-group">
-                                    <input type="text" value="{{Request::get('keyword')}}" placeholder="考号/联系方式/查询时间"
+                                    <input type="text" value="{{Request::get('keyword')}}" placeholder="考号/联系方式/推荐码"
                                            name="keyword" class="input-sm form-control">
                                     <span class="input-group-btn">
 									<button type="submit" class="btn btn-sm btn-primary">搜索</button>
@@ -35,6 +35,7 @@
                             <th class="sorting" data-sort="grade"> 高考分数</th>
                             <th class="sorting" data-sort="mobile"> 联系方式</th>
                             <th class="sorting" data-sort="query_time">查询时间</th>
+                            <th class="sorting" data-sort="code">推荐码</th>
                         </tr>
                         </thead>
                         <tbody>
@@ -46,6 +47,7 @@
                                     <td>{{ $item->grade }}</td>
                                     <td>{{ $item->mobile }}</td>
                                     <td>{{ $item->query_time }}</td>
+                                    <td>{{ $item->code }}</td>
 
                                 </tr>
                             @endforeach