wesley.chen 7 年 前
コミット
f3cbaa09b0

+ 136 - 57
app/Http/Controllers/Admin/Major/InfoController.php

xqd xqd xqd
@@ -1,59 +1,67 @@
 <?php
 /**
  *  专业信息
- *  @author  system
- *  @version    1.0
- *  @date 2018-06-06 01:44:59
+ * @author  system
+ * @version    1.0
+ * @date 2018-06-06 01:44:59
  *
  */
+
 namespace App\Http\Controllers\Admin\Major;
+
 use App\Http\Controllers\Admin\Controller;
+use App\Models\MajorInfoModel;
 use Illuminate\Http\Request;
 use App\Repositories\Base\Criteria\OrderBy;
 use App\Repositories\Major\Criteria\MultiWhere;
 use App\Repositories\Major\InfoRepository;
+use Maatwebsite\Excel\Facades\Excel;
+
 
 class InfoController extends Controller
 {
     private $repository;
 
-    public function __construct(InfoRepository $repository) {
-        if(!$this->repository) $this->repository = $repository;
+    public function __construct(InfoRepository $repository)
+    {
+        if (!$this->repository) $this->repository = $repository;
     }
 
-    function index(Request $request) {
+    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'));
+        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.major.info.index',compact('list'));
+        $list = $query->paginate(10);
+        return view('admin.major.info.index', compact('list'));
     }
 
 
-    function check(Request $request) {
+    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'])) {
+        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.major.info.check',compact('list'));
+        $list = $this->repository->search($search, $orderby);
+        return view('admin.major.info.check', compact('list'));
     }
 
 
     /**
      * 添加
-     * 
+     *
      */
     public function create(Request $request)
     {
-        if($request->method() == 'POST') {
+        if ($request->method() == 'POST') {
             return $this->_createSave();
         }
         return view('admin.major.info.edit');
@@ -62,51 +70,55 @@ class InfoController extends Controller
     /**
      * 保存修改
      */
-    private function _createSave(){
-        $data = (array) request('data');
+    private function _createSave()
+    {
+        $data = (array)request('data');
         $id = $this->repository->create($data);
-        if($id) {
-            $url[] = array('url'=>U( 'Major/Info/index'),'title'=>'返回列表');
-            $url[] = array('url'=>U( 'Major/Info/create'),'title'=>'继续添加');
-            $this->showMessage('添加成功',$url);
-        }else{
-            $url[] = array('url'=>U( 'Major/Info/index'),'title'=>'返回列表');
-            return $this->showWarning('添加失败',$url);
+        if ($id) {
+            $url[] = array('url' => U('Major/Info/index'), 'title' => '返回列表');
+            $url[] = array('url' => U('Major/Info/create'), 'title' => '继续添加');
+            $this->showMessage('添加成功', $url);
+        } else {
+            $url[] = array('url' => U('Major/Info/index'), 'title' => '返回列表');
+            return $this->showWarning('添加失败', $url);
         }
     }
-    
+
     /**
-     * 
+     *
      * 修改
-     * 
-     * 
+     *
+     *
      */
-    public function update(Request $request) {
-        if($request->method() == 'POST') {
+    public function update(Request $request)
+    {
+        if ($request->method() == 'POST') {
             return $this->_updateSave();
         }
         $data = $this->repository->find($request->get('id'));
-        return view('admin.major.info.edit',compact('data'));
+        return view('admin.major.info.edit', compact('data'));
     }
 
     /**
      * 保存修改
      */
-    private function _updateSave() {
-        $data = (array) request('data');
-        $ok = $this->repository->update(request('id'),$data);
-        if($ok) {
-            $url[] = array('url'=>U( 'Major/Info/index'),'title'=>'返回列表');
-            return $this->showMessage('操作成功',urldecode(request('_referer')));
-        }else{
-            $url[] = array('url'=>U( 'Major/Info/index'),'title'=>'返回列表');
-            return $this->showWarning('操作失败',$url);
+    private function _updateSave()
+    {
+        $data = (array)request('data');
+        $ok = $this->repository->update(request('id'), $data);
+        if ($ok) {
+            $url[] = array('url' => U('Major/Info/index'), 'title' => '返回列表');
+            return $this->showMessage('操作成功', urldecode(request('_referer')));
+        } else {
+            $url[] = array('url' => U('Major/Info/index'), 'title' => '返回列表');
+            return $this->showWarning('操作失败', $url);
         }
     }
 
-    public function view(Request $request) {
+    public function view(Request $request)
+    {
         $data = $this->repository->find(request('id'));
-        return view('admin.major.info.view',compact('data'));
+        return view('admin.major.info.view', compact('data'));
     }
 
 
@@ -115,28 +127,95 @@ class InfoController extends Controller
      * 状态改变
      *
      */
-    public function status(Request $request) {
-        $ok = $this->repository->updateStatus(request('id'),request('status'));
-        if($ok) {
+    public function status(Request $request)
+    {
+        $ok = $this->repository->updateStatus(request('id'), request('status'));
+        if ($ok) {
             return $this->showMessage('操作成功');
-        }else{
+        } else {
             return $this->showWarning('操作失败');
         }
     }
-    
+
     /**
      * 删除
      */
-    public function destroy(Request $request) {
+    public function destroy(Request $request)
+    {
         $bool = $this->repository->destroy($request->get('id'));
-        if($bool) {
-            return  $this->showMessage('操作成功');
-        }else{
-            return  $this->showWarning("操作失败");
+        if ($bool) {
+            return $this->showMessage('操作成功');
+        } else {
+            return $this->showWarning("操作失败");
         }
     }
 
-    public function import(){
-        dd('excel');
+    /***
+     * 导入excel表格
+     * @param Request $request
+     * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\View\View
+     */
+    public function import(Request $request)
+    {
+        if ($request->method() == 'GET') {
+            return view('kid_import');
+        } else {
+            $tmp_file = $_FILES['test'] ['name'];
+            $file_types = explode(".", $tmp_file);
+            $file_type = $file_types [count($file_types) - 1];
+            if (strtolower($file_type) == "xls" || strtolower($file_type) == "xlsx") {
+                $file = $request->file('test');
+                $path = 'upload/excel_import';
+                $filename = $tmp_file;
+                $file->move($path, $filename);
+                $filePath = $path . '/' . $filename;
+                Excel::load($filePath, function ($reader) {
+                    $data = $reader->toArray();
+                    $a = [];
+                    if (empty($data)) {
+                        die('<script>alert("信息填写不完整,请检查后导入数据");history.back();</script>');
+                    } else {
+                        foreach ($data as $k1 => $v1) {
+
+                            foreach ($v1 as $k2 => $v2) {
+                                $a[$k1]['year'] = $v2['年度'];
+                                $a[$k1]['class'] = $v2['科类'];
+                                $a[$k1]['batch'] = $v2['批次'];
+                                $a[$k1]['level'] = $v2['层次'];
+                                $a[$k1]['type'] = $v2['类别'];
+                                $a[$k1]['college'] = $v2['院校'];
+                                $a[$k1]['province'] = $v2['所在省份'];
+                                $a[$k1]['city'] = $v2['所在地市'];
+                                $a[$k1]['major'] = $v2['专业'];
+                                $a[$k1]['comment'] = $v2['专业备注'];
+                                $a[$k1]['min_grade'] = $v2['最低分'];
+                                $a[$k1]['avg_grade'] = $v2['平均分'];
+                                $a[$k1]['max_grade'] = $v2['最高分'];
+                                $a[$k1]['batch_grade'] = $v2['批次线'];
+                                $a[$k1]['miss_grade'] = $v2['线差'];
+                                $a[$k1]['min_rank'] = $v2['最低位次'];
+                                $a[$k1]['max_rank'] = $v2['最高位次'];
+                                $a[$k1]['avg_rank'] = $v2['平均位次'];
+
+                                $a[$k1]['created_at'] = date('Y-m-d H:i:s', time());
+                                $a[$k1]['updated_at'] = date('Y-m-d H:i:s', time());
+
+                                $res = $this->repository->create($a[$k1]);
+                            }
+
+                        }
+                    }
+
+                    if (!$res) {
+                        die('<script>alert("导入专业信息失败");history.back();</script>');
+                    }
+                });
+//                读取.xls文件后删除文件
+                unlink($filePath);
+                return back()->with('success', '导入专业信息成功');
+            } else {
+                return back()->with('error', '不是Excel .xls或者.xlsx文件,请重新上传');
+            }
+        }
     }
 }

+ 60 - 2
app/Http/Controllers/Admin/Student/CountController.php

xqd xqd xqd
@@ -12,6 +12,7 @@ use Illuminate\Http\Request;
 use App\Repositories\Base\Criteria\OrderBy;
 use App\Repositories\Student\Criteria\MultiWhere;
 use App\Repositories\Student\CountRepository;
+use Maatwebsite\Excel\Facades\Excel;
 
 class CountController extends Controller
 {
@@ -28,9 +29,9 @@ class CountController extends Controller
         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'));
+            $query = $query->pushCriteria(new OrderBy('total','asc'));
         }
-        $list = $query->paginate();
+        $list = $query->paginate(10);
         return view('admin.student.count.index',compact('list'));
     }
 
@@ -135,4 +136,61 @@ class CountController extends Controller
             return  $this->showWarning("操作失败");
         }
     }
+
+    /***
+     * 导入excel表格
+     * @param Request $request
+     * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\View\View
+     */
+    public function import(Request $request)
+    {
+        if ($request->method() == 'GET') {
+            return view('kid_import');
+        } else {
+            $tmp_file = $_FILES['test'] ['name'];
+            $file_types = explode(".", $tmp_file);
+            $file_type = $file_types [count($file_types) - 1];
+            if (strtolower($file_type) == "xls" || strtolower($file_type) == "xlsx") {
+                $file = $request->file('test');
+                $path = 'upload/excel_import';
+                $filename = $tmp_file;
+                $file->move($path, $filename);
+                $filePath = $path . '/' . $filename;
+                Excel::load($filePath, function ($reader) {
+                    $data = $reader->toArray();
+                    $a = [];
+                    if (empty($data)) {
+                        die('<script>alert("信息填写不完整,请检查后导入数据");history.back();</script>');
+                    } else {
+                        foreach ($data as $k1 => $v1) {
+
+                            foreach ($v1 as $k2 => $v2) {
+                                $a[$k1]['year'] = $v2['年份'];
+                                $a[$k1]['class'] = $v2['科类'];
+                                $a[$k1]['grade'] = $v2['分数'];
+                                $a[$k1]['sum'] = $v2['人数'];
+                                $a[$k1]['total'] = $v2['累计'];
+
+
+                                $a[$k1]['created_at'] = date('Y-m-d H:i:s', time());
+                                $a[$k1]['updated_at'] = date('Y-m-d H:i:s', time());
+
+                                $res = $this->repository->create($a[$k1]);
+                            }
+
+                        }
+                    }
+
+                    if (!$res) {
+                        die('<script>alert("导入人数统计信息失败");history.back();</script>');
+                    }
+                });
+//                读取.xls文件后删除文件
+                unlink($filePath);
+                return back()->with('success', '导入人数统计信息成功');
+            } else {
+                return back()->with('error', '不是Excel .xls或者.xlsx文件,请重新上传');
+            }
+        }
+    }
 }

+ 2 - 1
composer.json

xqd
@@ -6,12 +6,13 @@
     "type": "project",
     "require": {
         "php": ">=7.0.0",
+        "dingo/api": "2.0.*@dev",
         "fideloper/proxy": "~3.3",
         "intervention/image": "^2.4",
         "laravel/framework": "5.5.*",
         "laravel/passport": "^2.0",
         "laravel/tinker": "~1.0",
-        "dingo/api": "2.0.*@dev"
+        "maatwebsite/excel": "2.1.28"
     },
     "require-dev": {
         "barryvdh/laravel-ide-helper": "^2.4",

+ 2 - 0
config/app.php

xqd xqd
@@ -179,6 +179,7 @@ return [
         Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
         Laravel\Passport\PassportServiceProvider::class,
         Intervention\Image\ImageServiceProvider::class,
+        Maatwebsite\Excel\ExcelServiceProvider::class,
     ],
 
     /*
@@ -228,6 +229,7 @@ return [
         'Validator' => Illuminate\Support\Facades\Validator::class,
         'View' => Illuminate\Support\Facades\View::class,
         'Image' => Intervention\Image\Facades\Image::class,
+        'Excel' => Maatwebsite\Excel\Facades\Excel::class,
     ],
 
 ];

+ 704 - 0
config/excel.php

xqd
@@ -0,0 +1,704 @@
+<?php
+
+return array(
+
+    'cache'      => [
+
+        /*
+        |--------------------------------------------------------------------------
+        | Enable/Disable cell caching
+        |--------------------------------------------------------------------------
+        */
+        'enable'   => true,
+
+        /*
+        |--------------------------------------------------------------------------
+        | Caching driver
+        |--------------------------------------------------------------------------
+        |
+        | Set the caching driver
+        |
+        | Available methods:
+        | memory|gzip|serialized|igbinary|discISAM|apc|memcache|temp|wincache|sqlite|sqlite3
+        |
+        */
+        'driver'   => 'memory',
+
+        /*
+        |--------------------------------------------------------------------------
+        | Cache settings
+        |--------------------------------------------------------------------------
+        */
+        'settings' => [
+
+            'memoryCacheSize' => '32MB',
+            'cacheTime'       => 600
+
+        ],
+
+        /*
+        |--------------------------------------------------------------------------
+        | Memcache settings
+        |--------------------------------------------------------------------------
+        */
+        'memcache' => [
+
+            'host' => 'localhost',
+            'port' => 11211,
+
+        ],
+
+        /*
+        |--------------------------------------------------------------------------
+        | Cache dir (for discISAM)
+        |--------------------------------------------------------------------------
+        */
+
+        'dir'      => storage_path('cache')
+    ],
+
+    'properties' => [
+        'creator'        => 'Maatwebsite',
+        'lastModifiedBy' => 'Maatwebsite',
+        'title'          => 'Spreadsheet',
+        'description'    => 'Default spreadsheet export',
+        'subject'        => 'Spreadsheet export',
+        'keywords'       => 'maatwebsite, excel, export',
+        'category'       => 'Excel',
+        'manager'        => 'Maatwebsite',
+        'company'        => 'Maatwebsite',
+    ],
+
+    /*
+    |--------------------------------------------------------------------------
+    | Sheets settings
+    |--------------------------------------------------------------------------
+    */
+    'sheets'     => [
+
+        /*
+        |--------------------------------------------------------------------------
+        | Default page setup
+        |--------------------------------------------------------------------------
+        */
+        'pageSetup' => [
+            'orientation'           => 'portrait',
+            'paperSize'             => '9',
+            'scale'                 => '100',
+            'fitToPage'             => false,
+            'fitToHeight'           => true,
+            'fitToWidth'            => true,
+            'columnsToRepeatAtLeft' => ['', ''],
+            'rowsToRepeatAtTop'     => [0, 0],
+            'horizontalCentered'    => false,
+            'verticalCentered'      => false,
+            'printArea'             => null,
+            'firstPageNumber'       => null,
+        ],
+    ],
+
+    /*
+    |--------------------------------------------------------------------------
+    | Creator
+    |--------------------------------------------------------------------------
+    |
+    | The default creator of a new Excel file
+    |
+    */
+
+    'creator'    => 'Maatwebsite',
+
+    'csv'        => [
+        /*
+       |--------------------------------------------------------------------------
+       | Delimiter
+       |--------------------------------------------------------------------------
+       |
+       | The default delimiter which will be used to read out a CSV file
+       |
+       */
+
+        'delimiter'   => ',',
+
+        /*
+        |--------------------------------------------------------------------------
+        | Enclosure
+        |--------------------------------------------------------------------------
+        */
+
+        'enclosure'   => '"',
+
+        /*
+        |--------------------------------------------------------------------------
+        | Line endings
+        |--------------------------------------------------------------------------
+        */
+
+        'line_ending' => "\r\n",
+
+        /*
+        |--------------------------------------------------------------------------
+        | setUseBom
+        |--------------------------------------------------------------------------
+        */
+
+        'use_bom' => false
+    ],
+
+    'export'     => [
+
+        /*
+        |--------------------------------------------------------------------------
+        | Autosize columns
+        |--------------------------------------------------------------------------
+        |
+        | Disable/enable column autosize or set the autosizing for
+        | an array of columns ( array('A', 'B') )
+        |
+        */
+        'autosize'                    => true,
+
+        /*
+        |--------------------------------------------------------------------------
+        | Autosize method
+        |--------------------------------------------------------------------------
+        |
+        | --> PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX
+        | The default is based on an estimate, which does its calculation based
+        | on the number of characters in the cell value (applying any calculation
+        | and format mask, and allowing for wordwrap and rotation) and with an
+        | "arbitrary" adjustment based on the font (Arial, Calibri or Verdana,
+        | defaulting to Calibri if any other font is used) and a proportional
+        | adjustment for the font size.
+        |
+        | --> PHPExcel_Shared_Font::AUTOSIZE_METHOD_EXACT
+        | The second method is more accurate, based on actual style formatting as
+        | well (bold, italic, etc), and is calculated by generating a gd2 imagettf
+        | bounding box and using its dimensions to determine the size; but this
+        | method is significantly slower, and its accuracy is still dependent on
+        | having the appropriate fonts installed.
+        |
+        */
+        'autosize-method'             => PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX,
+
+        /*
+        |--------------------------------------------------------------------------
+        | Auto generate table heading
+        |--------------------------------------------------------------------------
+        |
+        | If set to true, the array indices (or model attribute names)
+        | will automatically be used as first row (table heading)
+        |
+        */
+        'generate_heading_by_indices' => true,
+
+        /*
+        |--------------------------------------------------------------------------
+        | Auto set alignment on merged cells
+        |--------------------------------------------------------------------------
+        */
+        'merged_cell_alignment'       => 'left',
+
+        /*
+        |--------------------------------------------------------------------------
+        | Pre-calculate formulas during export
+        |--------------------------------------------------------------------------
+        */
+        'calculate'                   => false,
+
+        /*
+        |--------------------------------------------------------------------------
+        | Include Charts during export
+        |--------------------------------------------------------------------------
+        */
+        'includeCharts'               => false,
+
+        /*
+        |--------------------------------------------------------------------------
+        | Default sheet settings
+        |--------------------------------------------------------------------------
+        */
+        'sheets'                      => [
+
+            /*
+            |--------------------------------------------------------------------------
+            | Default page margin
+            |--------------------------------------------------------------------------
+            |
+            | 1) When set to false, default margins will be used
+            | 2) It's possible to enter a single margin which will
+            |    be used for all margins.
+            | 3) Alternatively you can pass an array with 4 margins
+            |    Default order: array(top, right, bottom, left)
+            |
+            */
+            'page_margin'          => false,
+
+            /*
+            |--------------------------------------------------------------------------
+            | Value in source array that stands for blank cell
+            |--------------------------------------------------------------------------
+            */
+            'nullValue'            => null,
+
+            /*
+            |--------------------------------------------------------------------------
+            | Insert array starting from this cell address as the top left coordinate
+            |--------------------------------------------------------------------------
+            */
+            'startCell'            => 'A1',
+
+            /*
+            |--------------------------------------------------------------------------
+            | Apply strict comparison when testing for null values in the array
+            |--------------------------------------------------------------------------
+            */
+            'strictNullComparison' => false
+        ],
+
+        /*
+        |--------------------------------------------------------------------------
+        | Store settings
+        |--------------------------------------------------------------------------
+        */
+
+        'store'                       => [
+
+            /*
+            |--------------------------------------------------------------------------
+            | Path
+            |--------------------------------------------------------------------------
+            |
+            | The path we want to save excel file to
+            |
+            */
+            'path'       => storage_path('exports'),
+
+            /*
+            |--------------------------------------------------------------------------
+            | Return info
+            |--------------------------------------------------------------------------
+            |
+            | Whether we want to return information about the stored file or not
+            |
+            */
+            'returnInfo' => false
+
+        ],
+
+        /*
+        |--------------------------------------------------------------------------
+        | PDF Settings
+        |--------------------------------------------------------------------------
+        */
+        'pdf'                         => [
+
+            /*
+            |--------------------------------------------------------------------------
+            | PDF Drivers
+            |--------------------------------------------------------------------------
+            | Supported: DomPDF, tcPDF, mPDF
+            */
+            'driver'  => 'DomPDF',
+
+            /*
+            |--------------------------------------------------------------------------
+            | PDF Driver settings
+            |--------------------------------------------------------------------------
+            */
+            'drivers' => [
+
+                /*
+                |--------------------------------------------------------------------------
+                | DomPDF settings
+                |--------------------------------------------------------------------------
+                */
+                'DomPDF' => [
+                    'path' => base_path('vendor/dompdf/dompdf/')
+                ],
+
+                /*
+                |--------------------------------------------------------------------------
+                | tcPDF settings
+                |--------------------------------------------------------------------------
+                */
+                'tcPDF'  => [
+                    'path' => base_path('vendor/tecnick.com/tcpdf/')
+                ],
+
+                /*
+                |--------------------------------------------------------------------------
+                | mPDF settings
+                |--------------------------------------------------------------------------
+                */
+                'mPDF'   => [
+                    'path' => base_path('vendor/mpdf/mpdf/')
+                ],
+            ]
+        ]
+    ],
+
+    'filters'    => [
+        /*
+        |--------------------------------------------------------------------------
+        | Register read filters
+        |--------------------------------------------------------------------------
+        */
+
+        'registered' => [
+            'chunk' => 'Maatwebsite\Excel\Filters\ChunkReadFilter'
+        ],
+
+        /*
+        |--------------------------------------------------------------------------
+        | Enable certain filters for every file read
+        |--------------------------------------------------------------------------
+        */
+
+        'enabled'    => []
+    ],
+
+    'import'     => [
+
+        /*
+        |--------------------------------------------------------------------------
+        | Has heading
+        |--------------------------------------------------------------------------
+        |
+        | The sheet has a heading (first) row which we can use as attribute names
+        |
+        | Options: true|false|slugged|slugged_with_count|ascii|numeric|hashed|hashed_with_lower|trans|original
+        |
+        */
+
+        'heading'                 => 'slugged',
+
+        /*
+        |--------------------------------------------------------------------------
+        | First Row with data or heading of data
+        |--------------------------------------------------------------------------
+        |
+        | If the heading row is not the first row, or the data doesn't start
+        | on the first row, here you can change the start row.
+        |
+        */
+
+        'startRow'                => 1,
+
+        /*
+        |--------------------------------------------------------------------------
+        | Cell name word separator
+        |--------------------------------------------------------------------------
+        |
+        | The default separator which is used for the cell names
+        | Note: only applies to 'heading' settings 'true' && 'slugged'
+        |
+        */
+
+        'separator'               => '_',
+
+        /*
+        |--------------------------------------------------------------------------
+        | Slug whitelisting
+        |--------------------------------------------------------------------------
+        |
+        | Here you can whitelist certain characters in the slug.
+        | E.g. user.last_name will not remove . and _
+        | Note: only applies to 'heading' settings 'true' && 'slugged'
+        |
+        */
+
+        'slug_whitelist'       => '._',
+
+        /*
+        |--------------------------------------------------------------------------
+        | Include Charts during import
+        |--------------------------------------------------------------------------
+        */
+
+        'includeCharts'           => false,
+
+        /*
+        |--------------------------------------------------------------------------
+        | Sheet heading conversion
+        |--------------------------------------------------------------------------
+        |
+        | Convert headings to ASCII
+        | Note: only applies to 'heading' settings 'true' && 'slugged'
+        |
+        */
+
+        'to_ascii'                => false,
+
+        /*
+        |--------------------------------------------------------------------------
+        | Import encoding
+        |--------------------------------------------------------------------------
+        */
+
+        'encoding'                => [
+
+            'input'  => 'UTF-8',
+            'output' => 'UTF-8'
+
+        ],
+
+        /*
+        |--------------------------------------------------------------------------
+        | Calculate
+        |--------------------------------------------------------------------------
+        |
+        | By default cells with formulas will be calculated.
+        |
+        */
+
+        'calculate'               => true,
+
+        /*
+        |--------------------------------------------------------------------------
+        | Ignore empty cells
+        |--------------------------------------------------------------------------
+        |
+        | By default empty cells are not ignored
+        |
+        */
+
+        'ignoreEmpty'             => false,
+
+        /*
+        |--------------------------------------------------------------------------
+        | Force sheet collection
+        |--------------------------------------------------------------------------
+        |
+        | For a sheet collection even when there is only 1 sheets.
+        | When set to false and only 1 sheet found, the parsed file will return
+        | a row collection instead of a sheet collection.
+        | When set to true, it will return a sheet collection instead.
+        |
+        */
+        'force_sheets_collection' => false,
+
+        /*
+        |--------------------------------------------------------------------------
+        | Date format
+        |--------------------------------------------------------------------------
+        |
+        | The format dates will be parsed to
+        |
+        */
+
+        'dates'                   => [
+
+            /*
+            |--------------------------------------------------------------------------
+            | Enable/disable date formatting
+            |--------------------------------------------------------------------------
+            */
+            'enabled' => true,
+
+            /*
+            |--------------------------------------------------------------------------
+            | Default date format
+            |--------------------------------------------------------------------------
+            |
+            | If set to false, a carbon object will return
+            |
+            */
+            'format'  => false,
+
+            /*
+            |--------------------------------------------------------------------------
+            | Date columns
+            |--------------------------------------------------------------------------
+            */
+            'columns' => []
+        ],
+
+        /*
+        |--------------------------------------------------------------------------
+        | Import sheets by config
+        |--------------------------------------------------------------------------
+        */
+        'sheets'                  => [
+
+            /*
+            |--------------------------------------------------------------------------
+            | Example sheet
+            |--------------------------------------------------------------------------
+            |
+            | Example sheet "test" will grab the firstname at cell A2
+            |
+            */
+
+            'test' => [
+
+                'firstname' => 'A2'
+
+            ]
+
+        ]
+    ],
+
+    'views'      => [
+
+        /*
+        |--------------------------------------------------------------------------
+        | Styles
+        |--------------------------------------------------------------------------
+        |
+        | The default styles which will be used when parsing a view
+        |
+        */
+
+        'styles' => [
+
+            /*
+            |--------------------------------------------------------------------------
+            | Table headings
+            |--------------------------------------------------------------------------
+            */
+            'th'     => [
+                'font' => [
+                    'bold' => true,
+                    'size' => 12,
+                ]
+            ],
+
+            /*
+            |--------------------------------------------------------------------------
+            | Strong tags
+            |--------------------------------------------------------------------------
+            */
+            'strong' => [
+                'font' => [
+                    'bold' => true,
+                    'size' => 12,
+                ]
+            ],
+
+            /*
+            |--------------------------------------------------------------------------
+            | Bold tags
+            |--------------------------------------------------------------------------
+            */
+            'b'      => [
+                'font' => [
+                    'bold' => true,
+                    'size' => 12,
+                ]
+            ],
+
+            /*
+            |--------------------------------------------------------------------------
+            | Italic tags
+            |--------------------------------------------------------------------------
+            */
+            'i'      => [
+                'font' => [
+                    'italic' => true,
+                    'size'   => 12,
+                ]
+            ],
+
+            /*
+            |--------------------------------------------------------------------------
+            | Heading 1
+            |--------------------------------------------------------------------------
+            */
+            'h1'     => [
+                'font' => [
+                    'bold' => true,
+                    'size' => 24,
+                ]
+            ],
+
+            /*
+            |--------------------------------------------------------------------------
+            | Heading 2
+            |--------------------------------------------------------------------------
+            */
+            'h2'     => [
+                'font' => [
+                    'bold' => true,
+                    'size' => 18,
+                ]
+            ],
+
+            /*
+            |--------------------------------------------------------------------------
+            | Heading 3
+            |--------------------------------------------------------------------------
+            */
+            'h3'     => [
+                'font' => [
+                    'bold' => true,
+                    'size' => 13.5,
+                ]
+            ],
+
+            /*
+             |--------------------------------------------------------------------------
+             | Heading 4
+             |--------------------------------------------------------------------------
+             */
+            'h4'     => [
+                'font' => [
+                    'bold' => true,
+                    'size' => 12,
+                ]
+            ],
+
+            /*
+             |--------------------------------------------------------------------------
+             | Heading 5
+             |--------------------------------------------------------------------------
+             */
+            'h5'     => [
+                'font' => [
+                    'bold' => true,
+                    'size' => 10,
+                ]
+            ],
+
+            /*
+             |--------------------------------------------------------------------------
+             | Heading 6
+             |--------------------------------------------------------------------------
+             */
+            'h6'     => [
+                'font' => [
+                    'bold' => true,
+                    'size' => 7.5,
+                ]
+            ],
+
+            /*
+             |--------------------------------------------------------------------------
+             | Hyperlinks
+             |--------------------------------------------------------------------------
+             */
+            'a'      => [
+                'font' => [
+                    'underline' => true,
+                    'color'     => ['argb' => 'FF0000FF'],
+                ]
+            ],
+
+            /*
+             |--------------------------------------------------------------------------
+             | Horizontal rules
+             |--------------------------------------------------------------------------
+             */
+            'hr'     => [
+                'borders' => [
+                    'bottom' => [
+                        'style' => 'thin',
+                        'color' => ['FF000000']
+                    ],
+                ]
+            ]
+        ]
+
+    ]
+
+);

+ 15 - 15
database/migrations/2018_06_05_090930_create_major_info_table.php

xqd
@@ -15,24 +15,24 @@ class CreateMajorInfoTable extends Migration
     {
         Schema::create('major_info', function (Blueprint $table) {
             $table->increments('id');
-            $table->integer('year')->comment('年份');
-            $table->string('class',255)->comment('科类');
-            $table->string('batch',255)->comment('批次');
+            $table->integer('year')->nullable()->comment('年份');
+            $table->string('class',255)->nullable()->comment('科类');
+            $table->string('batch',255)->nullable()->comment('批次');
             $table->string('level',255)->nullable()->comment('层次');
             $table->string('type',255)->nullable()->comment('类别');
-            $table->string('college',64)->comment('院校名称');
-            $table->string('province',64)->comment('省份');
+            $table->string('college',64)->nullable()->comment('院校名称');
+            $table->string('province',64)->nullable()->comment('省份');
             $table->string('city',64)->nullable()->comment('城市');
-            $table->string('major',100)->comment('专业名称');
-            $table->integer('max_grade')->comment('最高分');
-            $table->integer('min_grade')->comment('最低分');
-            $table->integer('avg_grade')->comment('平均分');
-            $table->integer('batch_grade')->comment('批次线');
-            $table->integer('miss_grade')->comment('线差');
-            $table->integer('max_rank')->comment('最高位次');
-            $table->integer('min_rank')->comment('最低位次');
-            $table->integer('avg_rank')->comment('平均位次');
-            $table->string('comment',255)->comment('备注');
+            $table->string('major',100)->nullable()->comment('专业名称');
+            $table->integer('max_grade')->nullable()->comment('最高分');
+            $table->integer('min_grade')->nullable()->comment('最低分');
+            $table->integer('avg_grade')->nullable()->comment('平均分');
+            $table->integer('batch_grade')->nullable()->comment('批次线');
+            $table->integer('miss_grade')->nullable()->comment('线差');
+            $table->integer('max_rank')->nullable()->comment('最高位次');
+            $table->integer('min_rank')->nullable()->comment('最低位次');
+            $table->integer('avg_rank')->nullable()->comment('平均位次');
+            $table->string('comment',255)->nullable()->comment('备注');
             $table->softDeletes();
             $table->timestamps();
         });

+ 5 - 5
database/migrations/2018_06_05_102858_create_student_count_table.php

xqd
@@ -15,11 +15,11 @@ class CreateStudentCountTable extends Migration
     {
         Schema::create('student_count', function (Blueprint $table) {
             $table->increments('id');
-            $table->integer('year')->comment('年份');
-            $table->string('class',32)->comment('科类');
-            $table->integer('grade')->comment('分数');
-            $table->integer('sum')->comment('人数');
-            $table->integer('total')->comment('累计');
+            $table->integer('year')->nullable()->comment('年份');
+            $table->string('class',32)->nullable()->comment('科类');
+            $table->integer('grade')->nullable()->comment('分数');
+            $table->integer('sum')->nullable()->comment('人数');
+            $table->integer('total')->nullable()->comment('累计');
 
             $table->softDeletes();
             $table->timestamps();

+ 8 - 1
resources/views/admin/major/info/index.blade.php

xqd
@@ -28,7 +28,14 @@
                         @if(role('Major/Info/create'))
                             <div class="col-sm-3 pull-right">
                                 <a href="{{ U('Major/Info/create')}}" class="btn btn-sm btn-primary pull-right">添加</a>
-                                <a href="{{ U('Major/Info/import')}}" class="btn btn-sm btn-primary pull-right" style="margin-right: 5px">Excel导入</a>
+
+                                <form class="form-horizontal" role="form" method="post" enctype="multipart/form-data" action="{{ U('Major/Info/import')}}">
+                                    {{csrf_field()}}
+                                            <input type="file" name="test"  id="form-field-4" class="col-xs-12 col-sm-6 file" />
+                                            <button class="btn btn-sm btn-primary pull-right" style="margin-right: 5px" type="submit">
+                                                Excel导入
+                                            </button>
+                                </form>
                             </div>
                         @endif
                     </div>

+ 9 - 2
resources/views/admin/student/count/index.blade.php

xqd xqd
@@ -28,7 +28,14 @@
                         @if(role('Student/Count/create'))
                             <div class="col-sm-3 pull-right">
                                 <a href="{{ U('Student/Count/create')}}" class="btn btn-sm btn-primary pull-right">添加</a>
-                                <a href="{{ U('Student/Count/import')}}" class="btn btn-sm btn-primary pull-right" style="margin-right: 5px">Excel导入</a>
+                                <form class="form-horizontal" role="form" method="post" enctype="multipart/form-data" action="{{ U('Student/Count/import')}}">
+                                    {{csrf_field()}}
+                                    <input type="file" name="test"  id="form-field-4" class="col-xs-12 col-sm-6 file" />
+                                    <button class="btn btn-sm btn-primary pull-right" style="margin-right: 5px" type="submit">
+                                        Excel导入
+                                    </button>
+                                </form>
+
                             </div>
                         @endif
                     </div>
@@ -42,7 +49,7 @@
                             <th class="sorting" data-sort="grade"> 分数</th>
                             <th class="sorting" data-sort="sum"> 人数</th>
                             <th class="sorting" data-sort="total"> 累计</th>
-                            <th class="sorting" data-sort="created_at"></th>
+                            <th class="sorting" data-sort="created_at">创建时间</th>
                             <th width="22%">相关操作</th>
                         </tr>
                         </thead>