commit
239fc20902
12412 changed files with 2198667 additions and 0 deletions
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
root = true |
||||
|
||||
[*] |
||||
charset = utf-8 |
||||
end_of_line = lf |
||||
insert_final_newline = true |
||||
indent_style = space |
||||
indent_size = 4 |
||||
trim_trailing_whitespace = true |
||||
|
||||
[*.md] |
||||
trim_trailing_whitespace = false |
||||
|
||||
[*.{yml,yaml}] |
||||
indent_size = 2 |
||||
|
||||
[docker-compose.yml] |
||||
indent_size = 4 |
@ -0,0 +1,52 @@
@@ -0,0 +1,52 @@
|
||||
APP_NAME=WelcomeSystem |
||||
APP_ENV=local |
||||
APP_KEY=base64:pux+XmH5w1vB9Ujt3NA1DjMfVzYK8BbvYACgIBRnjqY= |
||||
APP_DEBUG=true |
||||
APP_URL=https://swyx.admin.yungao-tech.com |
||||
|
||||
LOG_CHANNEL=stack |
||||
LOG_DEPRECATIONS_CHANNEL=null |
||||
LOG_LEVEL=debug |
||||
|
||||
DB_CONNECTION=mysql |
||||
DB_HOST=127.0.0.1 |
||||
DB_PORT=3306 |
||||
DB_DATABASE=welcomesystem1 |
||||
DB_USERNAME=root |
||||
DB_PASSWORD=yungaodapao3306 |
||||
|
||||
BROADCAST_DRIVER=log |
||||
CACHE_DRIVER=file |
||||
FILESYSTEM_DRIVER=local |
||||
QUEUE_CONNECTION=sync |
||||
SESSION_DRIVER=file |
||||
SESSION_LIFETIME=120 |
||||
|
||||
MEMCACHED_HOST=127.0.0.1 |
||||
|
||||
REDIS_HOST=127.0.0.1 |
||||
REDIS_PASSWORD=null |
||||
REDIS_PORT=6379 |
||||
|
||||
MAIL_MAILER=smtp |
||||
MAIL_HOST=mailhog |
||||
MAIL_PORT=1025 |
||||
MAIL_USERNAME=null |
||||
MAIL_PASSWORD=null |
||||
MAIL_ENCRYPTION=null |
||||
MAIL_FROM_ADDRESS=null |
||||
MAIL_FROM_NAME="${APP_NAME}" |
||||
|
||||
AWS_ACCESS_KEY_ID= |
||||
AWS_SECRET_ACCESS_KEY= |
||||
AWS_DEFAULT_REGION=us-east-1 |
||||
AWS_BUCKET= |
||||
AWS_USE_PATH_STYLE_ENDPOINT=false |
||||
|
||||
PUSHER_APP_ID= |
||||
PUSHER_APP_KEY= |
||||
PUSHER_APP_SECRET= |
||||
PUSHER_APP_CLUSTER=mt1 |
||||
|
||||
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" |
||||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" |
@ -0,0 +1,52 @@
@@ -0,0 +1,52 @@
|
||||
APP_NAME=Laravel |
||||
APP_ENV=local |
||||
APP_KEY= |
||||
APP_DEBUG=true |
||||
APP_URL=http://localhost |
||||
|
||||
LOG_CHANNEL=stack |
||||
LOG_DEPRECATIONS_CHANNEL=null |
||||
LOG_LEVEL=debug |
||||
|
||||
DB_CONNECTION=mysql |
||||
DB_HOST=127.0.0.1 |
||||
DB_PORT=3306 |
||||
DB_DATABASE=laravel |
||||
DB_USERNAME=root |
||||
DB_PASSWORD= |
||||
|
||||
BROADCAST_DRIVER=log |
||||
CACHE_DRIVER=file |
||||
FILESYSTEM_DRIVER=local |
||||
QUEUE_CONNECTION=sync |
||||
SESSION_DRIVER=file |
||||
SESSION_LIFETIME=120 |
||||
|
||||
MEMCACHED_HOST=127.0.0.1 |
||||
|
||||
REDIS_HOST=127.0.0.1 |
||||
REDIS_PASSWORD=null |
||||
REDIS_PORT=6379 |
||||
|
||||
MAIL_MAILER=smtp |
||||
MAIL_HOST=mailhog |
||||
MAIL_PORT=1025 |
||||
MAIL_USERNAME=null |
||||
MAIL_PASSWORD=null |
||||
MAIL_ENCRYPTION=null |
||||
MAIL_FROM_ADDRESS=null |
||||
MAIL_FROM_NAME="${APP_NAME}" |
||||
|
||||
AWS_ACCESS_KEY_ID= |
||||
AWS_SECRET_ACCESS_KEY= |
||||
AWS_DEFAULT_REGION=us-east-1 |
||||
AWS_BUCKET= |
||||
AWS_USE_PATH_STYLE_ENDPOINT=false |
||||
|
||||
PUSHER_APP_ID= |
||||
PUSHER_APP_KEY= |
||||
PUSHER_APP_SECRET= |
||||
PUSHER_APP_CLUSTER=mt1 |
||||
|
||||
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" |
||||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" |
@ -0,0 +1,10 @@
@@ -0,0 +1,10 @@
|
||||
* text=auto |
||||
|
||||
*.blade.php diff=html |
||||
*.css diff=css |
||||
*.html diff=html |
||||
*.md diff=markdown |
||||
*.php diff=php |
||||
|
||||
/.github export-ignore |
||||
CHANGELOG.md export-ignore |
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
/node_modules |
||||
/public/hot |
||||
.env.backup |
||||
.phpunit.result.cache |
||||
docker-compose.override.yml |
||||
Homestead.json |
||||
Homestead.yaml |
||||
npm-debug.log |
||||
yarn-error.log |
||||
/.idea |
||||
/.vscode |
@ -0,0 +1,14 @@
@@ -0,0 +1,14 @@
|
||||
php: |
||||
preset: laravel |
||||
version: 8 |
||||
disabled: |
||||
- no_unused_imports |
||||
finder: |
||||
not-name: |
||||
- index.php |
||||
- server.php |
||||
js: |
||||
finder: |
||||
not-name: |
||||
- webpack.mix.js |
||||
css: true |
@ -0,0 +1,64 @@
@@ -0,0 +1,64 @@
|
||||
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400"></a></p> |
||||
|
||||
<p align="center"> |
||||
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a> |
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a> |
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a> |
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a> |
||||
</p> |
||||
|
||||
## About Laravel |
||||
|
||||
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as: |
||||
|
||||
- [Simple, fast routing engine](https://laravel.com/docs/routing). |
||||
- [Powerful dependency injection container](https://laravel.com/docs/container). |
||||
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage. |
||||
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent). |
||||
- Database agnostic [schema migrations](https://laravel.com/docs/migrations). |
||||
- [Robust background job processing](https://laravel.com/docs/queues). |
||||
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting). |
||||
|
||||
Laravel is accessible, powerful, and provides tools required for large, robust applications. |
||||
|
||||
## Learning Laravel |
||||
|
||||
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. |
||||
|
||||
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library. |
||||
|
||||
## Laravel Sponsors |
||||
|
||||
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell). |
||||
|
||||
### Premium Partners |
||||
|
||||
- **[Vehikl](https://vehikl.com/)** |
||||
- **[Tighten Co.](https://tighten.co)** |
||||
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)** |
||||
- **[64 Robots](https://64robots.com)** |
||||
- **[Cubet Techno Labs](https://cubettech.com)** |
||||
- **[Cyber-Duck](https://cyber-duck.co.uk)** |
||||
- **[Many](https://www.many.co.uk)** |
||||
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)** |
||||
- **[DevSquad](https://devsquad.com)** |
||||
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)** |
||||
- **[OP.GG](https://op.gg)** |
||||
- **[WebReinvent](https://webreinvent.com/?utm_source=laravel&utm_medium=github&utm_campaign=patreon-sponsors)** |
||||
- **[Lendio](https://lendio.com)** |
||||
|
||||
## Contributing |
||||
|
||||
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions). |
||||
|
||||
## Code of Conduct |
||||
|
||||
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct). |
||||
|
||||
## Security Vulnerabilities |
||||
|
||||
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed. |
||||
|
||||
## License |
||||
|
||||
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). |
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
<?php |
||||
|
||||
|
||||
namespace App\Admin\Actions\Form; |
||||
use App\Imports\BedDataExcel; |
||||
use Dcat\Admin\Widgets\Form; |
||||
use Symfony\Component\HttpFoundation\Response; |
||||
use Maatwebsite\Excel\Facades\Excel; |
||||
use Maatwebsite\Excel\Validators\ValidationException; |
||||
use Throwable; |
||||
|
||||
class ImportExcelBedForm extends Form |
||||
{ |
||||
public function handle(array $input) |
||||
{ |
||||
$file = env('APP_URL').'/upload/'.$input['file']; |
||||
|
||||
try { |
||||
Excel::import(new BedDataExcel(time()), $input['file'],'public'); |
||||
//dcat-2.0版本写法 |
||||
return $this->response() |
||||
->success('导入成功') |
||||
->redirect('/allocation_dormitory_bed'); |
||||
|
||||
} catch (ValidationException $validationException) { |
||||
return Response::withException($validationException); |
||||
} catch (Throwable $throwable) { |
||||
//dcat 2.0写法 |
||||
$this->response()->error(false); |
||||
return $this->response()->error($throwable->getMessage())->refresh(); |
||||
} |
||||
} |
||||
|
||||
public function form() |
||||
{ |
||||
$this->file('file', '上传床位数据(Excel)')->rules('required', ['required' => '文件不能为空']); |
||||
|
||||
} |
||||
|
||||
} |
||||
|
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
<?php |
||||
|
||||
|
||||
namespace App\Admin\Actions\Form; |
||||
use Dcat\Admin\Widgets\Form; |
||||
use Symfony\Component\HttpFoundation\Response; |
||||
use App\Imports\DataExcel; |
||||
use Maatwebsite\Excel\Facades\Excel; |
||||
use Maatwebsite\Excel\Validators\ValidationException; |
||||
use Throwable; |
||||
|
||||
class ImportExcelStudentForm extends Form |
||||
{ |
||||
public function handle(array $input) |
||||
{ |
||||
$file = env('APP_URL').'/upload/'.$input['file']; |
||||
|
||||
try { |
||||
Excel::import(new DataExcel(time()), $input['file'],'public'); |
||||
//dcat-2.0版本写法 |
||||
return $this->response() |
||||
->success('导入成功') |
||||
->redirect('/admission_new_students'); |
||||
|
||||
} catch (ValidationException $validationException) { |
||||
return Response::withException($validationException); |
||||
} catch (Throwable $throwable) { |
||||
//dcat 2.0写法 |
||||
$this->response()->error(false); |
||||
return $this->response()->error($throwable->getMessage())->refresh(); |
||||
} |
||||
} |
||||
|
||||
public function form() |
||||
{ |
||||
$this->file('file', '上传新生数据(Excel)')->rules('required', ['required' => '文件不能为空']); |
||||
|
||||
} |
||||
|
||||
} |
||||
|
@ -0,0 +1,86 @@
@@ -0,0 +1,86 @@
|
||||
<?php |
||||
|
||||
|
||||
namespace App\Admin\Actions\Grid; |
||||
|
||||
|
||||
use App\Admin\Actions\Form\Import; |
||||
use App\Admin\Actions\Form\ImportExcelBedForm; |
||||
use App\Admin\Actions\Form\ImportExcelStudentForm; |
||||
use Dcat\Admin\Admin; |
||||
use Dcat\Admin\Grid\Tools\AbstractTool; |
||||
use Dcat\Admin\Traits\HasPermissions; |
||||
use Dcat\Admin\Widgets\Form; |
||||
use Illuminate\Contracts\Auth\Authenticatable; |
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
|
||||
|
||||
class ImportExcelBed extends AbstractTool |
||||
{ |
||||
/** |
||||
* @return string |
||||
*/ |
||||
protected $title = 'Title'; |
||||
public function render() |
||||
{ |
||||
$id = "reset-pwd-{$this->getKey()}"; |
||||
|
||||
// 模态窗 |
||||
$this->modal($id); |
||||
|
||||
return <<<HTML |
||||
<span class="grid-expand" data-toggle="modal" data-target="#{$id}"> |
||||
<a href="javascript:void(0)"><button class="btn btn-primary ">导入床位信息</button></a> |
||||
</span> |
||||
HTML; |
||||
} |
||||
|
||||
protected function modal($id) |
||||
{ |
||||
$form = new ImportExcelBedForm(); |
||||
|
||||
Admin::script('Dcat.onPjaxComplete(function () { |
||||
$(".modal-backdrop").remove(); |
||||
$("body").removeClass("modal-open"); |
||||
}, true)'); |
||||
|
||||
// 通过 Admin::html 方法设置模态窗HTML |
||||
Admin::html( |
||||
<<<HTML |
||||
<div class="modal fade" id="{$id}"> |
||||
<div class="modal-dialog modal-lg" role="document"> |
||||
<div class="modal-content"> |
||||
<div class="modal-header"> |
||||
<h4 class="modal-title">导入数据</h4> |
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> |
||||
</div> |
||||
<div class="modal-body"> |
||||
{$form->render()} |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
HTML |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* @param Model|Authenticatable|HasPermissions|null $user |
||||
* |
||||
* @return bool |
||||
*/ |
||||
protected function authorize($user): bool |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* @return array |
||||
*/ |
||||
protected function parameters() |
||||
{ |
||||
return []; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,83 @@
@@ -0,0 +1,83 @@
|
||||
<?php |
||||
|
||||
|
||||
namespace App\Admin\Actions\Grid; |
||||
|
||||
|
||||
use App\Admin\Actions\Form\Import; |
||||
use App\Admin\Actions\Form\ImportExcelStudentForm; |
||||
use Dcat\Admin\Admin; |
||||
use Dcat\Admin\Grid\Tools\AbstractTool; |
||||
use Dcat\Admin\Traits\HasPermissions; |
||||
use Illuminate\Contracts\Auth\Authenticatable; |
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
|
||||
class ImportExcelStudent extends AbstractTool |
||||
{ |
||||
/** |
||||
* @return string |
||||
*/ |
||||
protected $title = 'Title'; |
||||
public function render() |
||||
{ |
||||
$id = "reset-pwd-{$this->getKey()}"; |
||||
|
||||
// 模态窗 |
||||
$this->modal($id); |
||||
|
||||
return <<<HTML |
||||
<span class="grid-expand" data-toggle="modal" data-target="#{$id}"> |
||||
<a href="javascript:void(0)"><button class="btn btn-primary ">导入新生名单</button></a> |
||||
</span> |
||||
HTML; |
||||
} |
||||
|
||||
protected function modal($id) |
||||
{ |
||||
$form = new ImportExcelStudentForm(); |
||||
|
||||
Admin::script('Dcat.onPjaxComplete(function () { |
||||
$(".modal-backdrop").remove(); |
||||
$("body").removeClass("modal-open"); |
||||
}, true)'); |
||||
|
||||
// 通过 Admin::html 方法设置模态窗HTML |
||||
Admin::html( |
||||
<<<HTML |
||||
<div class="modal fade" id="{$id}"> |
||||
<div class="modal-dialog modal-lg" role="document"> |
||||
<div class="modal-content"> |
||||
<div class="modal-header"> |
||||
<h4 class="modal-title">导入数据</h4> |
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> |
||||
</div> |
||||
<div class="modal-body"> |
||||
{$form->render()} |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
HTML |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* @param Model|Authenticatable|HasPermissions|null $user |
||||
* |
||||
* @return bool |
||||
*/ |
||||
protected function authorize($user): bool |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* @return array |
||||
*/ |
||||
protected function parameters() |
||||
{ |
||||
return []; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,132 @@
@@ -0,0 +1,132 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Controllers; |
||||
|
||||
use App\Models\AdmissionGuide; |
||||
use App\Models\Step; |
||||
use Dcat\Admin\Form; |
||||
use Dcat\Admin\Grid; |
||||
use Dcat\Admin\Show; |
||||
use Dcat\Admin\Http\Controllers\AdminController; |
||||
|
||||
class AdmissionGuideController extends AdminController |
||||
{ |
||||
/** |
||||
* Make a grid builder. |
||||
* |
||||
* @return Grid |
||||
*/ |
||||
protected function grid() |
||||
{ |
||||
return Grid::make(new AdmissionGuide(), function (Grid $grid) { |
||||
//开启边框模式 |
||||
$grid->withBorder(); |
||||
// 开启字段选择器功能 |
||||
$grid->showColumnSelector(); |
||||
|
||||
$grid->column('id')->sortable(); |
||||
$grid->column('step_id')->display(function () { |
||||
$info = Step::query()->where("id", $this->step_id)->first("title"); |
||||
if(!empty($info)){ |
||||
return $info->title; |
||||
} |
||||
})->help("该步骤时弹窗显示内容"); |
||||
$grid->column('content')->limit(50); |
||||
$grid->column('msg'); |
||||
$grid->column('status')->select([1=>"正常", 2=>"禁用"]); |
||||
$grid->column('create_time')->display(function (){ |
||||
if(!empty($this->create_time)){ |
||||
return date("Y-m-d H:i:s", $this->create_time); |
||||
} |
||||
})->sortable(); |
||||
$grid->column('update_time')->display(function (){ |
||||
if(!empty($this->update_time)){ |
||||
return date("Y-m-d H:i:s", $this->update_time); |
||||
} |
||||
}); |
||||
|
||||
|
||||
$grid->filter(function (Grid\Filter $filter) { |
||||
$filter->equal('step_id', "步骤")->select(Step::query()->pluck("title as value", "id")); |
||||
$filter->equal('status')->select([1 => "正常", 2 => "禁用"]); |
||||
}); |
||||
|
||||
// 禁用创建按钮 |
||||
$grid->disableCreateButton(); |
||||
// 禁用删除按钮 |
||||
$grid->disableDeleteButton(); |
||||
//禁用批量操作按钮 |
||||
$grid->disableBatchDelete(); |
||||
|
||||
// 禁用详情按钮 |
||||
$grid->disableViewButton(); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a show builder. |
||||
* |
||||
* @param mixed $id |
||||
* |
||||
* @return Show |
||||
*/ |
||||
protected function detail($id) |
||||
{ |
||||
return Show::make($id, new AdmissionGuide(), function (Show $show) { |
||||
$show->field('id'); |
||||
$show->field('step_id'); |
||||
$show->field('content'); |
||||
$show->field('status'); |
||||
$show->field('create_time'); |
||||
$show->field('update_time'); |
||||
$show->field('msg'); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a form builder. |
||||
* |
||||
* @return Form |
||||
*/ |
||||
protected function form() |
||||
{ |
||||
return Form::make(new AdmissionGuide(), function (Form $form) { |
||||
$form->display('id'); |
||||
$form->select('step_id', '步骤')->options(Step::query()->where("status", Step::STATUS_YES)->pluck("title as value", "id"))->required(); |
||||
$form->select('status', '状态')->options([1 => '正常', 2 => '禁用'])->required(); |
||||
$form->text('msg'); |
||||
$form->editor('content'); |
||||
$form->hidden("create_time"); |
||||
$form->hidden("update_time"); |
||||
|
||||
// 去除删除按钮 |
||||
$form->disableDeleteButton(); |
||||
// 去除跳转详情按钮 |
||||
$form->disableViewButton(); |
||||
|
||||
$form->footer(function ($footer) { |
||||
|
||||
// 去掉`查看`checkbox |
||||
$footer->disableViewCheck(); |
||||
|
||||
// 去掉`继续编辑`checkbox |
||||
$footer->disableEditingCheck(); |
||||
|
||||
// 去掉`继续创建`checkbox |
||||
$footer->disableCreatingCheck(); |
||||
|
||||
}); |
||||
|
||||
$form->saving(function (Form $form) { |
||||
|
||||
if ($form->isCreating()) { |
||||
$form->create_time =time(); |
||||
// 删除用户提交的数据 |
||||
$form->deleteInput('update_time'); |
||||
}else{ |
||||
$form->update_time =time(); |
||||
} |
||||
}); |
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,344 @@
@@ -0,0 +1,344 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Controllers; |
||||
|
||||
use App\Admin\Actions\Grid\ImportExcelStudent; |
||||
use App\Admin\Extensions\Exporter\ImportStudentExporter; |
||||
use App\Admin\Metrics\Examples\AdmissionExcelUsers; |
||||
use App\Admin\Metrics\Examples\AdmissionPayUsers; |
||||
use App\Admin\Metrics\Examples\AdmissionRegisterUsers; |
||||
use App\Admin\Metrics\Examples\AdmissionStepUsers; |
||||
use App\Admin\Metrics\Examples\Sessions; |
||||
use App\Models\AdmissionNewStudents; |
||||
use App\Models\Config; |
||||
use App\Models\SecondaryCollege; |
||||
use App\Models\Speciality; |
||||
use App\Models\UsersMember; |
||||
use Dcat\Admin\Form; |
||||
use Dcat\Admin\Grid; |
||||
use Dcat\Admin\Layout\Content; |
||||
use Dcat\Admin\Layout\Row; |
||||
use Dcat\Admin\Show; |
||||
use Dcat\Admin\Http\Controllers\AdminController; |
||||
use Illuminate\Http\Request; |
||||
use Illuminate\Support\Facades\DB; |
||||
|
||||
class AdmissionNewStudentController extends AdminController |
||||
{ |
||||
public function index(Content $content) |
||||
{ |
||||
return $content |
||||
->header('录入名单') |
||||
->description('数据统计') |
||||
->body(function (Row $row) { |
||||
$row->column(3, new AdmissionExcelUsers()); |
||||
$row->column(3, new AdmissionRegisterUsers()); |
||||
$row->column(3, new AdmissionPayUsers()); |
||||
$row->column(3, new AdmissionStepUsers()); |
||||
}) |
||||
->body($this->grid()); |
||||
} |
||||
|
||||
/** |
||||
* Make a grid builder. |
||||
* |
||||
* @return Grid |
||||
*/ |
||||
protected function grid() |
||||
{ |
||||
return Grid::make(new AdmissionNewStudents(), function (Grid $grid) { |
||||
//开启边框模式 |
||||
$grid->withBorder(); |
||||
// 开启字段选择器功能 |
||||
$grid->showColumnSelector(); |
||||
//开启导出功能 |
||||
$grid->export(new ImportStudentExporter()); |
||||
|
||||
$grid->column('id')->sortable(); |
||||
$grid->column('mobile'); |
||||
$grid->column('name'); |
||||
$grid->column('idCard'); |
||||
$grid->column('admission_code'); |
||||
$grid->column('admission_college'); |
||||
$grid->column('admitted_major'); |
||||
$grid->column('secondary_college_id')->display(function () { |
||||
$info = Speciality::query()->where("id", $this->speciality_id)->first(); |
||||
if(!empty($info)){ |
||||
$secondaryInfo = SecondaryCollege::query()->where("id", $info->secondary_college_id)->first(); |
||||
if(!empty($secondaryInfo)){ |
||||
return $secondaryInfo->name; |
||||
} |
||||
} |
||||
|
||||
})->help("未显示学院时请检查是否已经分配专业"); |
||||
$grid->column('speciality_id')->display(function () { |
||||
$info = Speciality::where("id", $this->speciality_id)->first(); |
||||
if(!empty($info)){ |
||||
return $info->speciality_name; |
||||
} |
||||
})->help("未显示专业时请检查是否已经分配专业"); |
||||
$grid->column('sex')->display(function () { |
||||
return $this->sex == 0 ? "未知" : ($this->sex == 1 ? "男" : "女"); |
||||
}); |
||||
|
||||
$grid->column('is_register')->display(function () { |
||||
if($this->is_register == 2){ |
||||
return "已注册"; |
||||
} |
||||
|
||||
return "未注册"; |
||||
})->help("此注册指是否已使用该身份证在迎新小程序上注册登录"); |
||||
$grid->column('resuming_school')->display(function (){ |
||||
if($this->resuming_school == AdmissionNewStudents::RESUMING_SCHOOL_ZERO) return "普通学生"; |
||||
if($this->resuming_school == AdmissionNewStudents::RESUMING_SCHOOL_ONE) return "退伍复学"; |
||||
if($this->resuming_school == AdmissionNewStudents::RESUMING_SCHOOL_TWO) return "普通复学"; |
||||
})->help("区分统招或复学");; |
||||
$grid->column('is_test')->display(function (){ |
||||
if($this->is_test == UsersMember::IS_TEST_YES){ |
||||
return "是"; |
||||
} |
||||
})->help("为测试账号时则不受系统开放时间限制");; |
||||
$grid->column('status')->select([1=>"正常", 2=>"禁用"]); |
||||
$grid->column('create_time')->display(function (){ |
||||
if(!empty($this->create_time)){ |
||||
return date("Y-m-d H:i:s", $this->create_time); |
||||
} |
||||
})->sortable(); |
||||
|
||||
|
||||
$grid->filter(function (Grid\Filter $filter) { |
||||
$filter->equal('mobile'); |
||||
$filter->equal('name'); |
||||
$filter->equal('idCard'); |
||||
$filter->equal('speciality_id')->select(function (){ |
||||
$list = Speciality::query()->where("status", Speciality::STATUS_YES)->get()->toArray(); |
||||
if(empty($list)){ |
||||
return []; |
||||
} |
||||
$select = []; |
||||
foreach($list as $item){ |
||||
$college = SecondaryCollege::query()->where("id", $item["secondary_college_id"])->first(); |
||||
$select[$item["id"]] = $item["speciality_name"]."({$college->name})"; |
||||
} |
||||
|
||||
return $select; |
||||
}); |
||||
$filter->equal('is_test')->select(function (){ |
||||
return [ |
||||
"1" => "否", |
||||
"2" => "是" |
||||
]; |
||||
}); |
||||
|
||||
$filter->equal('sex')->select(function (){ |
||||
return [ |
||||
"1" => "男", |
||||
"2" => "女" |
||||
]; |
||||
}); |
||||
$filter->equal('is_register')->select(function (){ |
||||
return [ |
||||
"1" => "未注册", |
||||
"2" => "已注册" |
||||
]; |
||||
}); |
||||
$filter->equal('resuming_school')->select(function (){ |
||||
return [ |
||||
"0" => "普通学生", |
||||
"1" => "退伍复学", |
||||
"2" => "普通复学" |
||||
]; |
||||
}); |
||||
$filter->equal('status')->select([1 => "正常", 2 => "禁用"]); |
||||
$filter->between('create_time')->datetime()->toTimestamp(); |
||||
}); |
||||
|
||||
// 禁用删除按钮 |
||||
$grid->disableDeleteButton(); |
||||
//禁用批量操作按钮 |
||||
$grid->disableBatchDelete(); |
||||
// 禁用详情按钮 |
||||
$grid->disableViewButton(); |
||||
|
||||
$grid->tools(function (Grid\Tools $tools) { |
||||
// excle 导入 |
||||
$tools->append(new ImportExcelStudent()); |
||||
}); |
||||
//下载模版 |
||||
$grid->tools('<a href="/storage/excelTemplate/studentTemplate.xlsx" download="studentTemplate.xlsx" target="_blank"><button class="btn btn-success ">下载新生模版</button></a>'); |
||||
|
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a show builder. |
||||
* |
||||
* @param mixed $id |
||||
* |
||||
* @return Show |
||||
*/ |
||||
protected function detail($id) |
||||
{ |
||||
return Show::make($id, new AdmissionNewStudents(), function (Show $show) { |
||||
$show->field('id'); |
||||
$show->field('mobile'); |
||||
$show->field('name'); |
||||
$show->field('idCard'); |
||||
$show->field('admission_code'); |
||||
$show->field('admission_college'); |
||||
$show->field('admitted_major'); |
||||
$show->field('sex'); |
||||
$show->field('status'); |
||||
$show->field('create_time'); |
||||
$show->field('update_time'); |
||||
$show->field('is_register'); |
||||
$show->field('speciality_id'); |
||||
$show->field('is_test'); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a form builder. |
||||
* |
||||
* @return Form |
||||
*/ |
||||
protected function form() |
||||
{ |
||||
return Form::make(new AdmissionNewStudents(), function (Form $form) { |
||||
$form->display('id'); |
||||
$form->text('mobile'); |
||||
$form->text('name')->required(); |
||||
$form->text('idCard')->required(); |
||||
$form->text('admission_code'); |
||||
|
||||
$form->select('sex')->options([0 => "未知", 1 => '男', 2 => '女'])->required(); |
||||
$form->select("speciality_id")->options(function () { |
||||
$list = Speciality::query()->where("status", Speciality::STATUS_YES)->get()->toArray(); |
||||
if(empty($list)){ |
||||
return []; |
||||
} |
||||
$select = []; |
||||
foreach($list as $item){ |
||||
$college = SecondaryCollege::query()->where("id", $item["secondary_college_id"])->first(); |
||||
$select[$item["id"]] = $item["speciality_name"]."({$college->name})"; |
||||
} |
||||
|
||||
return $select; |
||||
})->required(); |
||||
$form->select('status', '状态')->options([1 => '正常', 2 => '禁用'])->required(); |
||||
$form->select('is_test', '测试账号')->options([1 => '否', 2 => '是'])->required(); |
||||
$form->select('resuming_school')->options([ |
||||
"0" => "普通学生", |
||||
"1" => "退伍复学", |
||||
"2" => "普通复学" |
||||
])->required(); |
||||
|
||||
$form->hidden("annual_session"); |
||||
$form->hidden("create_time"); |
||||
$form->hidden("update_time"); |
||||
$form->hidden("admission_college"); |
||||
$form->hidden("admitted_major"); |
||||
|
||||
// 去除删除按钮 |
||||
$form->disableDeleteButton(); |
||||
// 去除跳转详情按钮 |
||||
$form->disableViewButton(); |
||||
|
||||
$form->footer(function ($footer) { |
||||
|
||||
// 去掉`查看`checkbox |
||||
$footer->disableViewCheck(); |
||||
|
||||
// 去掉`继续编辑`checkbox |
||||
$footer->disableEditingCheck(); |
||||
|
||||
// 去掉`继续创建`checkbox |
||||
$footer->disableCreatingCheck(); |
||||
|
||||
}); |
||||
|
||||
//保存前回调 |
||||
$form->saving(function (Form $form) { |
||||
|
||||
if ($form->isCreating()) { |
||||
$config = Config::query()->where([ |
||||
"unique_identification" => "annual_session" |
||||
])->first(); |
||||
$form->annual_session = $config->data; |
||||
$form->create_time =time(); |
||||
// 删除用户提交的数据 |
||||
$form->deleteInput('update_time'); |
||||
if(!$form->mobile){ |
||||
// 删除用户提交的数据 |
||||
$form->deleteInput('mobile'); |
||||
} |
||||
if(!$form->admission_code){ |
||||
// 删除用户提交的数据 |
||||
$form->deleteInput('admission_code'); |
||||
} |
||||
}else{ |
||||
$form->update_time =time(); |
||||
if(!$form->mobile){ |
||||
//因库中设置了该字段不能为空 |
||||
$form->mobile = ""; |
||||
} |
||||
if(!$form->admission_code){ |
||||
//因库中设置了该字段不能为空 |
||||
$form->admission_code = ""; |
||||
} |
||||
} |
||||
|
||||
|
||||
//初始化专业名及二级学院名 |
||||
$specialityName = ""; |
||||
$collegeName = ""; |
||||
|
||||
//取出专业信息 |
||||
$specialityInfo = Speciality::query()->where("id", $form->speciality_id)->first(); |
||||
if(!empty($specialityInfo)){ |
||||
$specialityName = $specialityInfo->speciality_name; |
||||
//取出二级学院名称 |
||||
$college = SecondaryCollege::query()->where("id", $specialityInfo->secondary_college_id)->first(); |
||||
if(!empty($college)){ |
||||
$collegeName = $college->name; |
||||
} |
||||
} |
||||
$form->admission_college = $collegeName; |
||||
$form->admitted_major = $specialityName; |
||||
|
||||
}); |
||||
|
||||
//保存后回调 |
||||
$form->saved(function (Form $form) { |
||||
|
||||
DB::beginTransaction(); |
||||
try { |
||||
|
||||
//同步修改用户列表里的专业 |
||||
$info = UsersMember::query()->where("idcard", $form->idCard)->first(); |
||||
if(!empty($info)){ |
||||
$update = UsersMember::query()->where("idcard", $form->idCard)->update([ |
||||
"speciality_id" => $form->speciality_id, |
||||
"is_test" => $form->is_test, |
||||
"name" => $form->name, |
||||
"idcard" => $form->idCard, |
||||
"sex" => $form->sex, |
||||
"update_time" => time() |
||||
]); |
||||
if(empty($update)){ |
||||
// 抛出异常 |
||||
throw new \Exception('修改学生专业出错2'); |
||||
} |
||||
} |
||||
DB::commit(); |
||||
}catch (\Exception $e){ |
||||
DB::rollBack(); |
||||
throw new \Exception($e->getMessage()); |
||||
} |
||||
|
||||
}); |
||||
|
||||
}); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,362 @@
@@ -0,0 +1,362 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Controllers; |
||||
|
||||
use App\Admin\Actions\Grid\ImportExcelBed; |
||||
use App\Admin\Extensions\Exporter\ImportBedExporter; |
||||
use App\Admin\Metrics\Examples\AllocationExcelBed; |
||||
use App\Admin\Metrics\Examples\AllocationExcelBedNotSelect; |
||||
use App\Admin\Metrics\Examples\AllocationExcelBedSelect; |
||||
use App\Models\AllocationDormitoryBed; |
||||
use App\Models\Bed; |
||||
use App\Models\Building; |
||||
use App\Models\Config; |
||||
use App\Models\DormitoryNumber; |
||||
use App\Models\DormitoryType; |
||||
use App\Models\Floor; |
||||
use App\Models\LivingArea; |
||||
use App\Models\MultipleWorld; |
||||
use App\Models\SecondaryCollege; |
||||
use App\Models\SelectedDormitory; |
||||
use App\Models\Speciality; |
||||
use App\Models\UsersMember; |
||||
use Dcat\Admin\Actions\Action; |
||||
use Dcat\Admin\Form; |
||||
use Dcat\Admin\Grid; |
||||
use Dcat\Admin\Layout\Content; |
||||
use Dcat\Admin\Layout\Row; |
||||
use Dcat\Admin\Show; |
||||
use Dcat\Admin\Http\Controllers\AdminController; |
||||
use Dcat\Admin\Widgets\Metrics\Card; |
||||
use Illuminate\Support\MessageBag; |
||||
|
||||
class AllocationDormitoryBedController extends AdminController |
||||
{ |
||||
public function index(Content $content) |
||||
{ |
||||
return $content |
||||
->header('床位管理') |
||||
->description('数据统计') |
||||
->body(function (Row $row) { |
||||
$row->column(4, new AllocationExcelBed()); |
||||
$row->column(4, new AllocationExcelBedSelect()); |
||||
$row->column(4, new AllocationExcelBedNotSelect()); |
||||
}) |
||||
->body($this->grid()); |
||||
} |
||||
|
||||
/** |
||||
* Make a grid builder. |
||||
* |
||||
* @return Grid |
||||
*/ |
||||
protected function grid() |
||||
{ |
||||
return Grid::make(new AllocationDormitoryBed(), function (Grid $grid) { |
||||
|
||||
//开启边框模式 |
||||
$grid->withBorder(); |
||||
// 开启字段选择器功能 |
||||
$grid->showColumnSelector(); |
||||
//开启导出功能 |
||||
$grid->export(new ImportBedExporter()); |
||||
|
||||
//取出当前年份 |
||||
$config = Config::query()->where([ |
||||
"unique_identification" => "annual_session" |
||||
])->first(); |
||||
|
||||
$grid->model()->where("annual_session", $config->data); |
||||
|
||||
$grid->column('id')->sortable(); |
||||
|
||||
$grid->column('is_select')->display(function (){ |
||||
$info = SelectedDormitory::query()->where([ |
||||
"allocation_dormitory_id" => $this->id, |
||||
"annual_session" => $this->annual_session, |
||||
"status" => SelectedDormitory::STATUS_YES |
||||
])->first(); |
||||
if(!empty($info)){ |
||||
return "占用"; |
||||
} |
||||
|
||||
})->help("显示占用时则代表该床位已被学生选中,不建议修改床位的信息"); |
||||
|
||||
$grid->column('sex')->display(function () { |
||||
return $this->sex == 0 ? "未知" : ($this->sex == 1 ? "男" : "女"); |
||||
}); |
||||
|
||||
$grid->column('dormitory_type')->display(function(){ |
||||
$info = DormitoryType::query()->where("id", $this->dormitory_type)->first(); |
||||
if(!empty($info)){ |
||||
return $info->dormitory; |
||||
} |
||||
})->help("未显示时则找不到对应的宿舍类型或该宿舍类型已被删除"); |
||||
$grid->column('multiple_worlds')->display(function(){ |
||||
$info = MultipleWorld::query()->where("id", $this->multiple_worlds)->first(); |
||||
if(!empty($info)){ |
||||
return $info->people; |
||||
} |
||||
})->help("未显示时则找不到对应的几人间或该几人间已被删除"); |
||||
$grid->column('living_area')->display(function(){ |
||||
$info = LivingArea::query()->where("id", $this->living_area)->first(); |
||||
if(!empty($info)){ |
||||
return $info->title; |
||||
} |
||||
})->help("未显示时则找不到对应的生活区或该生活区已被删除"); |
||||
$grid->column('building_id')->display(function(){ |
||||
$info = Building::query()->where("id", $this->building_id)->first(); |
||||
if(!empty($info)){ |
||||
return $info->building_title; |
||||
} |
||||
})->help("未显示时则找不到对应的楼栋或该楼栋已被删除"); |
||||
$grid->column('floor_id')->display(function(){ |
||||
$info = Floor::query()->where("id", $this->floor_id)->first(); |
||||
if(!empty($info)){ |
||||
return $info->floor_title; |
||||
} |
||||
})->help("未显示时则找不到对应的楼层或该楼层已被删除"); |
||||
$grid->column('dormitory_number')->display(function(){ |
||||
$info = DormitoryNumber::query()->where("id", $this->dormitory_number)->first(); |
||||
if(!empty($info)){ |
||||
return $info->dormitory_number; |
||||
} |
||||
})->help("未显示时则找不到对应的宿舍号或该宿舍号已被删除"); |
||||
$grid->column('bed_id')->display(function(){ |
||||
$info = Bed::query()->where("id", $this->bed_id)->first(); |
||||
if(!empty($info)){ |
||||
return $info->bed_number; |
||||
} |
||||
})->help("未显示时则找不到对应的床位或该床位已被删除"); |
||||
$grid->column('secondary_college_id')->display(function () { |
||||
$info = Speciality::query()->where("id", $this->speciality_id)->first(); |
||||
if(!empty($info)){ |
||||
$secondaryInfo = SecondaryCollege::query()->where("id", $info->secondary_college_id)->first(); |
||||
if(!empty($secondaryInfo)){ |
||||
return $secondaryInfo->name; |
||||
} |
||||
} |
||||
|
||||
})->help("未显示学院时请检查是否已经分配专业"); |
||||
$grid->column('speciality_id')->display(function () { |
||||
$info = Speciality::where("id", $this->speciality_id)->first(); |
||||
if(!empty($info)){ |
||||
return $info->speciality_name; |
||||
} |
||||
})->help("未显示专业时请检查是否已经分配专业"); |
||||
$grid->column('status')->select([1=>"正常", 2=>"禁用"]); |
||||
|
||||
$grid->filter(function (Grid\Filter $filter) { |
||||
|
||||
$filter->equal('id'); |
||||
|
||||
$filter->where("is_select", function ($query) { |
||||
//取出当前年份 |
||||
$config = Config::query()->where([ |
||||
"unique_identification" => "annual_session" |
||||
])->first(); |
||||
|
||||
$selectList = SelectedDormitory::query()->where([ |
||||
"status" => SelectedDormitory::STATUS_YES, |
||||
"annual_session" => $config->data, |
||||
])->get()->toArray(); |
||||
|
||||
if(!empty($selectList)){ |
||||
$selectIds = array_column($selectList, "allocation_dormitory_id"); |
||||
} |
||||
|
||||
if($this->input == 1){ |
||||
//占用时 |
||||
$query->whereIn('id', $selectIds); |
||||
}else { |
||||
//未占用时 |
||||
$query->whereNotIn("id", $selectIds); |
||||
} |
||||
|
||||
})->select([ |
||||
"1" => "占用", |
||||
"2" => "未占用" |
||||
]); |
||||
|
||||
|
||||
$filter->equal('speciality_id')->select(function (){ |
||||
$list = Speciality::query()->where("status", Speciality::STATUS_YES)->get()->toArray(); |
||||
if(empty($list)){ |
||||
return []; |
||||
} |
||||
$select = []; |
||||
foreach($list as $item){ |
||||
$college = SecondaryCollege::query()->where("id", $item["secondary_college_id"])->first(); |
||||
$select[$item["id"]] = $item["speciality_name"]."({$college->name})"; |
||||
} |
||||
|
||||
return $select; |
||||
}); |
||||
|
||||
$filter->equal('dormitory_type')->select(DormitoryType::query()->pluck("dormitory as value", "id")) |
||||
->load("multiple_worlds", config("app.url")."/api/getMultipleWorldsByList"); |
||||
|
||||
$filter->equal("multiple_worlds")->select(); |
||||
$filter->equal('living_area')->select(LivingArea::query()->pluck("title as value", "id")); |
||||
$filter->equal('building_id')->select(Building::query()->pluck("building_title as value", "id")); |
||||
$filter->equal('floor_id')->select(Floor::query()->pluck("floor_title as value", "id")); |
||||
$filter->equal('dormitory_number')->select(DormitoryNumber::query()->pluck("dormitory_number as value", "id")); |
||||
$filter->equal('bed_id')->select(Bed::query()->pluck("bed_number as value", "id")); |
||||
$filter->equal('sex')->select([1 => "男", 2 => "女"]); |
||||
$filter->equal('status')->select([1 => "正常", 2 => "禁用"]); |
||||
}); |
||||
|
||||
// 禁用详情按钮 |
||||
$grid->disableViewButton(); |
||||
|
||||
$grid->tools(function (Grid\Tools $tools) { |
||||
// excle 导入 |
||||
$tools->append(new ImportExcelBed()); |
||||
}); |
||||
//下载模版 |
||||
$grid->tools('<a href="/storage/excelTemplate/dormitoryTemplate.xlsx" download="dormitoryTemplate.xlsx" target="_blank"><button class="btn btn-success ">下载宿舍模版</button></a>'); |
||||
|
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a show builder. |
||||
* |
||||
* @param mixed $id |
||||
* |
||||
* @return Show |
||||
*/ |
||||
protected function detail($id) |
||||
{ |
||||
return Show::make($id, new AllocationDormitoryBed(), function (Show $show) { |
||||
$show->field('id'); |
||||
$show->field('dormitory_type'); |
||||
$show->field('multiple_worlds'); |
||||
$show->field('living_area'); |
||||
$show->field('building_id'); |
||||
$show->field('floor_id'); |
||||
$show->field('dormitory_number'); |
||||
$show->field('bed_id'); |
||||
$show->field('speciality_id'); |
||||
$show->field('status'); |
||||
$show->field('create_time'); |
||||
$show->field('update_time'); |
||||
$show->field('sex'); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a form builder. |
||||
* |
||||
* @return Form |
||||
*/ |
||||
protected function form() |
||||
{ |
||||
return Form::make(new AllocationDormitoryBed(), function (Form $form) { |
||||
$form->display('id'); |
||||
$form->select('dormitory_type') |
||||
->options(DormitoryType::query()->where("status",DormitoryType::STATUS_YES)->pluck("dormitory as value", "id")) |
||||
->load("multiple_worlds", config("app.url")."/api/getMultipleWorldsByList") |
||||
->required(); |
||||
$form->select("multiple_worlds"); |
||||
$form->select('living_area')->options(LivingArea::query()->where("status",LivingArea::STATUS_YES)->pluck("title as value", "id"))->required(); |
||||
$form->select('building_id')->options(Building::query()->where("status",Building::STATUS_YES)->pluck("building_title as value", "id"))->required(); |
||||
$form->select('floor_id')->options(Floor::query()->where("status",Floor::STATUS_YES)->pluck("floor_title as value", "id"))->required(); |
||||
$form->select('dormitory_number')->options(DormitoryNumber::query()->where("status",DormitoryNumber::STATUS_YES)->pluck("dormitory_number as value", "id"))->required(); |
||||
$form->select('bed_id')->options(Bed::query()->where("status",Bed::STATUS_YES)->pluck("bed_number as value", "id"))->required(); |
||||
$form->select("speciality_id")->options(function (){ |
||||
$list = Speciality::query()->where("status",Speciality::STATUS_YES)->get()->toArray(); |
||||
if(empty($list)){ |
||||
return []; |
||||
} |
||||
$arr = []; |
||||
foreach($list as $item){ |
||||
//取出所有二级学院 |
||||
$seconInfo = SecondaryCollege::query()->where("id", $item["secondary_college_id"])->first(); |
||||
|
||||
if(empty($seconInfo)){ |
||||
$arr[$item["id"]] = $item["speciality_name"]."(未分配二级学院)"; |
||||
}else{ |
||||
$arr[$item["id"]] = $item["speciality_name"]."({$seconInfo->name})"; |
||||
} |
||||
|
||||
} |
||||
|
||||
return $arr; |
||||
})->required(); |
||||
$form->select('sex', '性别')->options([1 => '男', 2 => '女'])->required(); |
||||
$form->select('status', '状态')->options([1 => '正常', 2 => '禁用'])->required(); |
||||
|
||||
$form->hidden("annual_session"); |
||||
$form->hidden("create_time"); |
||||
$form->hidden("update_time"); |
||||
|
||||
// 去除跳转详情按钮 |
||||
$form->disableViewButton(); |
||||
|
||||
$form->footer(function ($footer) { |
||||
|
||||
// 去掉`查看`checkbox |
||||
$footer->disableViewCheck(); |
||||
|
||||
// 去掉`继续编辑`checkbox |
||||
$footer->disableEditingCheck(); |
||||
|
||||
// 去掉`继续创建`checkbox |
||||
$footer->disableCreatingCheck(); |
||||
|
||||
}); |
||||
|
||||
$form->submitted(function (Form $form) { |
||||
// 获取用户提交参数 |
||||
$dormitory_type = $form->dormitory_type; |
||||
$multiple_worlds = $form->multiple_worlds; |
||||
$living_area = $form->living_area; |
||||
$building_id = $form->building_id; |
||||
$floor_id = $form->floor_id; |
||||
$dormitory_number = $form->dormitory_number; |
||||
$bed_id = $form->bed_id; |
||||
$speciality_id = $form->speciality_id; |
||||
$sex = $form->sex; |
||||
$annual_session = $form->annual_session; |
||||
|
||||
$where = [ |
||||
"dormitory_type" => $dormitory_type, |
||||
"multiple_worlds" => $multiple_worlds, |
||||
"living_area" => $living_area, |
||||
"building_id" => $building_id, |
||||
"floor_id" => $floor_id, |
||||
"dormitory_number" => $dormitory_number, |
||||
"bed_id" => $bed_id, |
||||
"speciality_id" => $speciality_id, |
||||
"sex" => $sex, |
||||
"annual_session" => $annual_session, |
||||
]; |
||||
|
||||
$check = AllocationDormitoryBed::query()->where($where)->count(); |
||||
if(!empty($check)){ |
||||
// 中断后续逻辑 |
||||
return $form->response()->error('当前床位已存在,无需重复添加~'); |
||||
} |
||||
|
||||
}); |
||||
|
||||
$form->saving(function (Form $form) { |
||||
|
||||
if ($form->isCreating()) { |
||||
$form->create_time =time(); |
||||
// 删除用户提交的数据 |
||||
$form->deleteInput('update_time'); |
||||
}else{ |
||||
$form->update_time =time(); |
||||
} |
||||
}); |
||||
|
||||
$config = Config::query()->where([ |
||||
"unique_identification" => "annual_session" |
||||
])->first(); |
||||
$form->annual_session = $config->data; |
||||
|
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,9 @@
@@ -0,0 +1,9 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Controllers; |
||||
|
||||
use Dcat\Admin\Http\Controllers\AuthController as BaseAuthController; |
||||
|
||||
class AuthController extends BaseAuthController |
||||
{ |
||||
} |
@ -0,0 +1,107 @@
@@ -0,0 +1,107 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Controllers; |
||||
|
||||
use App\Admin\Repositories\Bed; |
||||
use Dcat\Admin\Form; |
||||
use Dcat\Admin\Grid; |
||||
use Dcat\Admin\Show; |
||||
use Dcat\Admin\Http\Controllers\AdminController; |
||||
|
||||
class BedController extends AdminController |
||||
{ |
||||
/** |
||||
* Make a grid builder. |
||||
* |
||||
* @return Grid |
||||
*/ |
||||
protected function grid() |
||||
{ |
||||
return Grid::make(new Bed(), function (Grid $grid) { |
||||
//开启边框模式 |
||||
$grid->withBorder(); |
||||
// 开启字段选择器功能 |
||||
$grid->showColumnSelector(); |
||||
|
||||
$grid->column('id')->sortable(); |
||||
$grid->column('bed_number'); |
||||
$grid->column('status')->select([1=>"正常", 2=>"禁用"]); |
||||
$grid->column('create_time')->display(function (){ |
||||
if(!empty($this->create_time)){ |
||||
return date("Y-m-d H:i:s", $this->create_time); |
||||
} |
||||
})->sortable(); |
||||
|
||||
$grid->filter(function (Grid\Filter $filter) { |
||||
$filter->equal('id'); |
||||
$filter->equal('status')->select([1 => "正常", 2 => "禁用"]); |
||||
}); |
||||
// 禁用详情按钮 |
||||
$grid->disableViewButton(); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a show builder. |
||||
* |
||||
* @param mixed $id |
||||
* |
||||
* @return Show |
||||
*/ |
||||
protected function detail($id) |
||||
{ |
||||
return Show::make($id, new Bed(), function (Show $show) { |
||||
$show->field('id'); |
||||
$show->field('bed_number'); |
||||
$show->field('status'); |
||||
$show->field('create_time'); |
||||
$show->field('update_time'); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a form builder. |
||||
* |
||||
* @return Form |
||||
*/ |
||||
protected function form() |
||||
{ |
||||
return Form::make(new Bed(), function (Form $form) { |
||||
$form->display('id'); |
||||
$form->text('bed_number')->required(); |
||||
$form->select('status', '状态')->options([1 => '正常', 2 => '禁用'])->required(); |
||||
$form->hidden("create_time"); |
||||
$form->hidden("update_time"); |
||||
|
||||
// 去除删除按钮 |
||||
$form->disableDeleteButton(); |
||||
|
||||
// 去除跳转详情按钮 |
||||
$form->disableViewButton(); |
||||
|
||||
$form->footer(function ($footer) { |
||||
|
||||
// 去掉`查看`checkbox |
||||
$footer->disableViewCheck(); |
||||
|
||||
// 去掉`继续编辑`checkbox |
||||
$footer->disableEditingCheck(); |
||||
|
||||
// 去掉`继续创建`checkbox |
||||
$footer->disableCreatingCheck(); |
||||
|
||||
}); |
||||
|
||||
$form->saving(function (Form $form) { |
||||
|
||||
if ($form->isCreating()) { |
||||
$form->create_time =time(); |
||||
// 删除用户提交的数据 |
||||
$form->deleteInput('update_time'); |
||||
}else{ |
||||
$form->update_time =time(); |
||||
} |
||||
}); |
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,108 @@
@@ -0,0 +1,108 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Controllers; |
||||
|
||||
use App\Admin\Repositories\Building; |
||||
use Dcat\Admin\Form; |
||||
use Dcat\Admin\Grid; |
||||
use Dcat\Admin\Show; |
||||
use Dcat\Admin\Http\Controllers\AdminController; |
||||
|
||||
class BuildingController extends AdminController |
||||
{ |
||||
/** |
||||
* Make a grid builder. |
||||
* |
||||
* @return Grid |
||||
*/ |
||||
protected function grid() |
||||
{ |
||||
return Grid::make(new Building(), function (Grid $grid) { |
||||
//开启边框模式 |
||||
$grid->withBorder(); |
||||
// 开启字段选择器功能 |
||||
$grid->showColumnSelector(); |
||||
|
||||
$grid->column('id')->sortable(); |
||||
$grid->column('building_title'); |
||||
$grid->column('status')->select([1=>"正常", 2=>"禁用"]); |
||||
$grid->column('create_time')->display(function (){ |
||||
if(!empty($this->create_time)){ |
||||
return date("Y-m-d H:i:s", $this->create_time); |
||||
} |
||||
})->sortable(); |
||||
|
||||
$grid->filter(function (Grid\Filter $filter) { |
||||
$filter->equal('id'); |
||||
$filter->equal('status')->select([1 => "正常", 2 => "禁用"]); |
||||
}); |
||||
// 禁用详情按钮 |
||||
$grid->disableViewButton(); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a show builder. |
||||
* |
||||
* @param mixed $id |
||||
* |
||||
* @return Show |
||||
*/ |
||||
protected function detail($id) |
||||
{ |
||||
return Show::make($id, new Building(), function (Show $show) { |
||||
$show->field('id'); |
||||
$show->field('building_title'); |
||||
$show->field('status'); |
||||
$show->field('create_time'); |
||||
$show->field('update_time'); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a form builder. |
||||
* |
||||
* @return Form |
||||
*/ |
||||
protected function form() |
||||
{ |
||||
return Form::make(new Building(), function (Form $form) { |
||||
$form->display('id'); |
||||
$form->text('building_title')->required(); |
||||
$form->select('status', '状态')->options([1 => '正常', 2 => '禁用'])->required(); |
||||
$form->hidden("create_time"); |
||||
$form->hidden("update_time"); |
||||
|
||||
// 去除删除按钮 |
||||
$form->disableDeleteButton(); |
||||
|
||||
// 去除跳转详情按钮 |
||||
$form->disableViewButton(); |
||||
|
||||
$form->footer(function ($footer) { |
||||
|
||||
// 去掉`查看`checkbox |
||||
$footer->disableViewCheck(); |
||||
|
||||
// 去掉`继续编辑`checkbox |
||||
$footer->disableEditingCheck(); |
||||
|
||||
// 去掉`继续创建`checkbox |
||||
$footer->disableCreatingCheck(); |
||||
|
||||
}); |
||||
|
||||
$form->saving(function (Form $form) { |
||||
|
||||
if ($form->isCreating()) { |
||||
$form->create_time =time(); |
||||
// 删除用户提交的数据 |
||||
$form->deleteInput('update_time'); |
||||
}else{ |
||||
$form->update_time =time(); |
||||
} |
||||
}); |
||||
|
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,108 @@
@@ -0,0 +1,108 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Controllers; |
||||
|
||||
use App\Admin\Repositories\DormitoryNumber; |
||||
use Dcat\Admin\Form; |
||||
use Dcat\Admin\Grid; |
||||
use Dcat\Admin\Show; |
||||
use Dcat\Admin\Http\Controllers\AdminController; |
||||
|
||||
class DormitoryNumberController extends AdminController |
||||
{ |
||||
/** |
||||
* Make a grid builder. |
||||
* |
||||
* @return Grid |
||||
*/ |
||||
protected function grid() |
||||
{ |
||||
return Grid::make(new DormitoryNumber(), function (Grid $grid) { |
||||
//开启边框模式 |
||||
$grid->withBorder(); |
||||
// 开启字段选择器功能 |
||||
$grid->showColumnSelector(); |
||||
|
||||
$grid->column('id')->sortable(); |
||||
$grid->column('dormitory_number'); |
||||
$grid->column('status')->select([1=>"正常", 2=>"禁用"]); |
||||
$grid->column('create_time')->display(function (){ |
||||
if(!empty($this->create_time)){ |
||||
return date("Y-m-d H:i:s", $this->create_time); |
||||
} |
||||
})->sortable(); |
||||
|
||||
$grid->filter(function (Grid\Filter $filter) { |
||||
$filter->equal('id'); |
||||
$filter->equal('status')->select([1 => "正常", 2 => "禁用"]); |
||||
}); |
||||
|
||||
// 禁用详情按钮 |
||||
$grid->disableViewButton(); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a show builder. |
||||
* |
||||
* @param mixed $id |
||||
* |
||||
* @return Show |
||||
*/ |
||||
protected function detail($id) |
||||
{ |
||||
return Show::make($id, new DormitoryNumber(), function (Show $show) { |
||||
$show->field('id'); |
||||
$show->field('dormitory_number'); |
||||
$show->field('status'); |
||||
$show->field('create_time'); |
||||
$show->field('update_time'); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a form builder. |
||||
* |
||||
* @return Form |
||||
*/ |
||||
protected function form() |
||||
{ |
||||
return Form::make(new DormitoryNumber(), function (Form $form) { |
||||
$form->display('id'); |
||||
$form->text('dormitory_number')->required(); |
||||
$form->select('status', '状态')->options([1 => '正常', 2 => '禁用'])->required(); |
||||
$form->hidden("create_time"); |
||||
$form->hidden("update_time"); |
||||
|
||||
// 去除删除按钮 |
||||
$form->disableDeleteButton(); |
||||
|
||||
// 去除跳转详情按钮 |
||||
$form->disableViewButton(); |
||||
|
||||
$form->footer(function ($footer) { |
||||
|
||||
// 去掉`查看`checkbox |
||||
$footer->disableViewCheck(); |
||||
|
||||
// 去掉`继续编辑`checkbox |
||||
$footer->disableEditingCheck(); |
||||
|
||||
// 去掉`继续创建`checkbox |
||||
$footer->disableCreatingCheck(); |
||||
|
||||
}); |
||||
|
||||
$form->saving(function (Form $form) { |
||||
|
||||
if ($form->isCreating()) { |
||||
$form->create_time =time(); |
||||
// 删除用户提交的数据 |
||||
$form->deleteInput('update_time'); |
||||
}else{ |
||||
$form->update_time =time(); |
||||
} |
||||
}); |
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,109 @@
@@ -0,0 +1,109 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Controllers; |
||||
|
||||
use App\Admin\Repositories\DormitoryType; |
||||
use Dcat\Admin\Form; |
||||
use Dcat\Admin\Grid; |
||||
use Dcat\Admin\Show; |
||||
use Dcat\Admin\Http\Controllers\AdminController; |
||||
|
||||
class DormitoryTypeController extends AdminController |
||||
{ |
||||
/** |
||||
* Make a grid builder. |
||||
* |
||||
* @return Grid |
||||
*/ |
||||
protected function grid() |
||||
{ |
||||
return Grid::make(new DormitoryType(), function (Grid $grid) { |
||||
//开启边框模式 |
||||
$grid->withBorder(); |
||||
// 开启字段选择器功能 |
||||
$grid->showColumnSelector(); |
||||
|
||||
$grid->column('id')->sortable(); |
||||
$grid->column('dormitory'); |
||||
$grid->column('status')->select([1=>"正常", 2=>"禁用"]); |
||||
$grid->column('create_time')->display(function (){ |
||||
if(!empty($this->create_time)){ |
||||
return date("Y-m-d H:i:s", $this->create_time); |
||||
} |
||||
})->sortable(); |
||||
|
||||
$grid->filter(function (Grid\Filter $filter) { |
||||
$filter->equal('id'); |
||||
$filter->equal('status')->select([1 => "正常", 2 => "禁用"]); |
||||
|
||||
}); |
||||
|
||||
// 禁用详情按钮 |
||||
$grid->disableViewButton(); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a show builder. |
||||
* |
||||
* @param mixed $id |
||||
* |
||||
* @return Show |
||||
*/ |
||||
protected function detail($id) |
||||
{ |
||||
return Show::make($id, new DormitoryType(), function (Show $show) { |
||||
$show->field('id'); |
||||
$show->field('dormitory'); |
||||
$show->field('status'); |
||||
$show->field('create_time'); |
||||
$show->field('update_time'); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a form builder. |
||||
* |
||||
* @return Form |
||||
*/ |
||||
protected function form() |
||||
{ |
||||
return Form::make(new DormitoryType(), function (Form $form) { |
||||
$form->display('id'); |
||||
$form->text('dormitory')->required(); |
||||
$form->select('status', '状态')->options([1 => '正常', 2 => '禁用'])->required(); |
||||
$form->hidden("create_time"); |
||||
$form->hidden("update_time"); |
||||
|
||||
// 去除删除按钮 |
||||
$form->disableDeleteButton(); |
||||
|
||||
// 去除跳转详情按钮 |
||||
$form->disableViewButton(); |
||||
|
||||
$form->footer(function ($footer) { |
||||
|
||||
// 去掉`查看`checkbox |
||||
$footer->disableViewCheck(); |
||||
|
||||
// 去掉`继续编辑`checkbox |
||||
$footer->disableEditingCheck(); |
||||
|
||||
// 去掉`继续创建`checkbox |
||||
$footer->disableCreatingCheck(); |
||||
|
||||
}); |
||||
|
||||
$form->saving(function (Form $form) { |
||||
|
||||
if ($form->isCreating()) { |
||||
$form->create_time =time(); |
||||
// 删除用户提交的数据 |
||||
$form->deleteInput('update_time'); |
||||
}else{ |
||||
$form->update_time =time(); |
||||
} |
||||
}); |
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,107 @@
@@ -0,0 +1,107 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Controllers; |
||||
|
||||
use App\Admin\Repositories\Floor; |
||||
use Dcat\Admin\Form; |
||||
use Dcat\Admin\Grid; |
||||
use Dcat\Admin\Show; |
||||
use Dcat\Admin\Http\Controllers\AdminController; |
||||
|
||||
class FloorController extends AdminController |
||||
{ |
||||
/** |
||||
* Make a grid builder. |
||||
* |
||||
* @return Grid |
||||
*/ |
||||
protected function grid() |
||||
{ |
||||
return Grid::make(new Floor(), function (Grid $grid) { |
||||
//开启边框模式 |
||||
$grid->withBorder(); |
||||
// 开启字段选择器功能 |
||||
$grid->showColumnSelector(); |
||||
|
||||
$grid->column('id')->sortable(); |
||||
$grid->column('floor_title'); |
||||
$grid->column('status')->select([1=>"正常", 2=>"禁用"]); |
||||
$grid->column('create_time')->display(function (){ |
||||
if(!empty($this->create_time)){ |
||||
return date("Y-m-d H:i:s", $this->create_time); |
||||
} |
||||
})->sortable(); |
||||
|
||||
$grid->filter(function (Grid\Filter $filter) { |
||||
$filter->equal('id'); |
||||
$filter->equal('status')->select([1 => "正常", 2 => "禁用"]); |
||||
}); |
||||
// 禁用详情按钮 |
||||
$grid->disableViewButton(); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a show builder. |
||||
* |
||||
* @param mixed $id |
||||
* |
||||
* @return Show |
||||
*/ |
||||
protected function detail($id) |
||||
{ |
||||
return Show::make($id, new Floor(), function (Show $show) { |
||||
$show->field('id'); |
||||
$show->field('floor_title'); |
||||
$show->field('status'); |
||||
$show->field('create_time'); |
||||
$show->field('update_time'); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a form builder. |
||||
* |
||||
* @return Form |
||||
*/ |
||||
protected function form() |
||||
{ |
||||
return Form::make(new Floor(), function (Form $form) { |
||||
$form->display('id'); |
||||
$form->text('floor_title')->required(); |
||||
$form->select('status', '状态')->options([1 => '正常', 2 => '禁用'])->required(); |
||||
$form->hidden("create_time"); |
||||
$form->hidden("update_time"); |
||||
|
||||
// 去除删除按钮 |
||||
$form->disableDeleteButton(); |
||||
|
||||
// 去除跳转详情按钮 |
||||
$form->disableViewButton(); |
||||
|
||||
$form->footer(function ($footer) { |
||||
|
||||
// 去掉`查看`checkbox |
||||
$footer->disableViewCheck(); |
||||
|
||||
// 去掉`继续编辑`checkbox |
||||
$footer->disableEditingCheck(); |
||||
|
||||
// 去掉`继续创建`checkbox |
||||
$footer->disableCreatingCheck(); |
||||
|
||||
}); |
||||
|
||||
$form->saving(function (Form $form) { |
||||
|
||||
if ($form->isCreating()) { |
||||
$form->create_time =time(); |
||||
// 删除用户提交的数据 |
||||
$form->deleteInput('update_time'); |
||||
}else{ |
||||
$form->update_time =time(); |
||||
} |
||||
}); |
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,43 @@
@@ -0,0 +1,43 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Controllers; |
||||
|
||||
use App\Admin\Metrics\Examples; |
||||
use App\Admin\Metrics\Examples\AdmissionExcelUsers; |
||||
use App\Admin\Metrics\Examples\AdmissionPayUsers; |
||||
use App\Admin\Metrics\Examples\AdmissionStepUsers; |
||||
use App\Admin\Metrics\Examples\SelectedDormitoryTotal; |
||||
use App\Admin\Metrics\Examples\TotalUsers; |
||||
use App\Http\Controllers\Controller; |
||||
use Dcat\Admin\Http\Controllers\Dashboard; |
||||
use Dcat\Admin\Layout\Column; |
||||
use Dcat\Admin\Layout\Content; |
||||
use Dcat\Admin\Layout\Row; |
||||
use Dcat\Admin\Widgets\Metrics\Card; |
||||
|
||||
class HomeController extends Controller |
||||
{ |
||||
public function index(Content $content) |
||||
{ |
||||
return $content |
||||
->header('数据概览') |
||||
->description('各项数据统计详情') |
||||
->body(function (Row $row) { |
||||
|
||||
$row->column(12, function (Column $column) { |
||||
$column->row(function (Row $row) { |
||||
$row->column(6, new Examples\NewUsers()); |
||||
$row->column(6, new TotalUsers()); |
||||
$row->column(6, new AdmissionExcelUsers()); |
||||
$row->column(6, new AdmissionPayUsers()); |
||||
$row->column(6, new AdmissionStepUsers()); |
||||
$row->column(6, new SelectedDormitoryTotal()); |
||||
}); |
||||
}); |
||||
|
||||
/*$row->column(12, function (Column $column) { |
||||
$column->row(Dashboard::title()); |
||||
});*/ |
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,109 @@
@@ -0,0 +1,109 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Controllers; |
||||
|
||||
use App\Admin\Repositories\LivingArea; |
||||
use Dcat\Admin\Form; |
||||
use Dcat\Admin\Grid; |
||||
use Dcat\Admin\Show; |
||||
use Dcat\Admin\Http\Controllers\AdminController; |
||||
|
||||
class LivingAreaController extends AdminController |
||||
{ |
||||
/** |
||||
* Make a grid builder. |
||||
* |
||||
* @return Grid |
||||
*/ |
||||
protected function grid() |
||||
{ |
||||
return Grid::make(new LivingArea(), function (Grid $grid) { |
||||
//开启边框模式 |
||||
$grid->withBorder(); |
||||
// 开启字段选择器功能 |
||||
$grid->showColumnSelector(); |
||||
|
||||
$grid->column('id')->sortable(); |
||||
$grid->column('title'); |
||||
$grid->column('status')->select([1=>"正常", 2=>"禁用"]); |
||||
$grid->column('create_time')->display(function (){ |
||||
if(!empty($this->create_time)){ |
||||
return date("Y-m-d H:i:s", $this->create_time); |
||||
} |
||||
})->sortable(); |
||||
|
||||
$grid->filter(function (Grid\Filter $filter) { |
||||
$filter->equal('id'); |
||||
$filter->equal('status')->select([1 => "正常", 2 => "禁用"]); |
||||
}); |
||||
|
||||
// 禁用详情按钮 |
||||
$grid->disableViewButton(); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a show builder. |
||||
* |
||||
* @param mixed $id |
||||
* |
||||
* @return Show |
||||
*/ |
||||
protected function detail($id) |
||||
{ |
||||
return Show::make($id, new LivingArea(), function (Show $show) { |
||||
$show->field('id'); |
||||
$show->field('title'); |
||||
$show->field('status'); |
||||
$show->field('create_time'); |
||||
$show->field('update_time'); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a form builder. |
||||
* |
||||
* @return Form |
||||
*/ |
||||
protected function form() |
||||
{ |
||||
return Form::make(new LivingArea(), function (Form $form) { |
||||
$form->display('id'); |
||||
$form->text('title')->required(); |
||||
$form->select('status', '状态')->options([1 => '正常', 2 => '禁用'])->required(); |
||||
$form->hidden("create_time"); |
||||
$form->hidden("update_time"); |
||||
|
||||
// 去除删除按钮 |
||||
$form->disableDeleteButton(); |
||||
|
||||
// 去除跳转详情按钮 |
||||
$form->disableViewButton(); |
||||
|
||||
$form->footer(function ($footer) { |
||||
|
||||
// 去掉`查看`checkbox |
||||
$footer->disableViewCheck(); |
||||
|
||||
// 去掉`继续编辑`checkbox |
||||
$footer->disableEditingCheck(); |
||||
|
||||
// 去掉`继续创建`checkbox |
||||
$footer->disableCreatingCheck(); |
||||
|
||||
}); |
||||
|
||||
$form->saving(function (Form $form) { |
||||
|
||||
if ($form->isCreating()) { |
||||
$form->create_time =time(); |
||||
// 删除用户提交的数据 |
||||
$form->deleteInput('update_time'); |
||||
}else{ |
||||
$form->update_time =time(); |
||||
} |
||||
}); |
||||
|
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,121 @@
@@ -0,0 +1,121 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Controllers; |
||||
|
||||
use App\Admin\Repositories\MultipleWorld; |
||||
use App\Models\DormitoryType; |
||||
use Dcat\Admin\Form; |
||||
use Dcat\Admin\Grid; |
||||
use Dcat\Admin\Show; |
||||
use Dcat\Admin\Http\Controllers\AdminController; |
||||
|
||||
class MultipleWorldController extends AdminController |
||||
{ |
||||
/** |
||||
* Make a grid builder. |
||||
* |
||||
* @return Grid |
||||
*/ |
||||
protected function grid() |
||||
{ |
||||
return Grid::make(new MultipleWorld(), function (Grid $grid) { |
||||
//开启边框模式 |
||||
$grid->withBorder(); |
||||
// 开启字段选择器功能 |
||||
$grid->showColumnSelector(); |
||||
|
||||
$grid->column('id')->sortable(); |
||||
$grid->column('people'); |
||||
$grid->column('price'); |
||||
$grid->column('dormitory_type_id')->display(function (){ |
||||
$info = DormitoryType::query()->where("id",$this->dormitory_type_id)->first(); |
||||
if(!empty($info)){ |
||||
return $info->dormitory; |
||||
} |
||||
})->help("未显示时则代表未找到对应宿舍类型或该宿舍类型已被删除"); |
||||
$grid->column('status')->select([1=>"正常", 2=>"禁用"]); |
||||
$grid->column('create_time')->display(function (){ |
||||
if(!empty($this->create_time)){ |
||||
return date("Y-m-d H:i:s", $this->create_time); |
||||
} |
||||
})->sortable(); |
||||
|
||||
$grid->filter(function (Grid\Filter $filter) { |
||||
$filter->equal('id'); |
||||
$filter->equal('dormitory_type_id', "宿舍类型")->select(DormitoryType::query()->pluck("dormitory as value", "id")); |
||||
$filter->equal('status')->select([1 => "正常", 2 => "禁用"]); |
||||
}); |
||||
|
||||
// 禁用详情按钮 |
||||
$grid->disableViewButton(); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a show builder. |
||||
* |
||||
* @param mixed $id |
||||
* |
||||
* @return Show |
||||
*/ |
||||
protected function detail($id) |
||||
{ |
||||
return Show::make($id, new MultipleWorld(), function (Show $show) { |
||||
$show->field('id'); |
||||
$show->field('people'); |
||||
$show->field('price'); |
||||
$show->field('dormitory_type_id'); |
||||
$show->field('status'); |
||||
$show->field('create_time'); |
||||
$show->field('update_time'); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a form builder. |
||||
* |
||||
* @return Form |
||||
*/ |
||||
protected function form() |
||||
{ |
||||
return Form::make(new MultipleWorld(), function (Form $form) { |
||||
$form->display('id'); |
||||
$form->select('dormitory_type_id', '宿舍类型')->options(DormitoryType::query()->where("status",1)->pluck("dormitory as value", "id"))->required(); |
||||
$form->text('people')->required(); |
||||
$form->number('price')->required(); |
||||
$form->select('status', '状态')->options([1 => '正常', 2 => '禁用'])->required(); |
||||
$form->hidden("create_time"); |
||||
$form->hidden("update_time"); |
||||
|
||||
// 去除删除按钮 |
||||
$form->disableDeleteButton(); |
||||
|
||||
// 去除跳转详情按钮 |
||||
$form->disableViewButton(); |
||||
|
||||
$form->footer(function ($footer) { |
||||
|
||||
// 去掉`查看`checkbox |
||||
$footer->disableViewCheck(); |
||||
|
||||
// 去掉`继续编辑`checkbox |
||||
$footer->disableEditingCheck(); |
||||
|
||||
// 去掉`继续创建`checkbox |
||||
$footer->disableCreatingCheck(); |
||||
|
||||
}); |
||||
|
||||
$form->saving(function (Form $form) { |
||||
|
||||
if ($form->isCreating()) { |
||||
$form->create_time =time(); |
||||
// 删除用户提交的数据 |
||||
$form->deleteInput('update_time'); |
||||
}else{ |
||||
$form->update_time =time(); |
||||
} |
||||
}); |
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,125 @@
@@ -0,0 +1,125 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Controllers; |
||||
|
||||
use App\Models\OfflineStep; |
||||
use Dcat\Admin\Form; |
||||
use Dcat\Admin\Grid; |
||||
use Dcat\Admin\Show; |
||||
use Dcat\Admin\Http\Controllers\AdminController; |
||||
|
||||
class OfflineStepController extends AdminController |
||||
{ |
||||
/** |
||||
* Make a grid builder. |
||||
* |
||||
* @return Grid |
||||
*/ |
||||
protected function grid() |
||||
{ |
||||
return Grid::make(new OfflineStep(), function (Grid $grid) { |
||||
//开启边框模式 |
||||
$grid->withBorder(); |
||||
// 开启字段选择器功能 |
||||
$grid->showColumnSelector(); |
||||
|
||||
$grid->column('id')->sortable(); |
||||
$grid->column('title')->help("迎新系统中显示的线下报到步骤流程名称"); |
||||
$grid->column('msg'); |
||||
$grid->column('sort'); |
||||
$grid->column('is_must', __('是否为必须完成'))->display(function(){ |
||||
return $this->is_must == 1 ? "是" : "否"; |
||||
}); |
||||
$grid->column('status')->display(function() { |
||||
return $this->status == 1 ? "正常" : "禁用"; |
||||
}); |
||||
$grid->column('create_time')->display(function (){ |
||||
if(!empty($this->create_time)){ |
||||
return date("Y-m-d H:i:s", $this->create_time); |
||||
} |
||||
})->sortable(); |
||||
$grid->column('update_time')->display(function (){ |
||||
if(!empty($this->update_time)){ |
||||
return date("Y-m-d H:i:s", $this->update_time); |
||||
} |
||||
}); |
||||
|
||||
$grid->filter(function (Grid\Filter $filter) { |
||||
$filter->equal('status')->select([1 => "正常", 2 => "禁用"]); |
||||
|
||||
}); |
||||
|
||||
// 禁用创建按钮 |
||||
$grid->disableCreateButton(); |
||||
// 禁用删除按钮 |
||||
$grid->disableDeleteButton(); |
||||
//禁用批量操作按钮 |
||||
$grid->disableBatchDelete(); |
||||
|
||||
// 禁用详情按钮 |
||||
$grid->disableViewButton(); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a show builder. |
||||
* |
||||
* @param mixed $id |
||||
* |
||||
* @return Show |
||||
*/ |
||||
protected function detail($id) |
||||
{ |
||||
return Show::make($id, new OfflineStep(), function (Show $show) { |
||||
$show->field('id'); |
||||
$show->field('title'); |
||||
$show->field('msg'); |
||||
|
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a form builder. |
||||
* |
||||
* @return Form |
||||
*/ |
||||
protected function form() |
||||
{ |
||||
return Form::make(new OfflineStep(), function (Form $form) { |
||||
$form->display('id'); |
||||
$form->text('title')->required(); |
||||
$form->text('msg')->required(); |
||||
$form->hidden("create_time"); |
||||
$form->hidden("update_time"); |
||||
|
||||
// 去除删除按钮 |
||||
$form->disableDeleteButton(); |
||||
// 去除跳转详情按钮 |
||||
$form->disableViewButton(); |
||||
|
||||
$form->footer(function ($footer) { |
||||
|
||||
// 去掉`查看`checkbox |
||||
$footer->disableViewCheck(); |
||||
|
||||
// 去掉`继续编辑`checkbox |
||||
$footer->disableEditingCheck(); |
||||
|
||||
// 去掉`继续创建`checkbox |
||||
$footer->disableCreatingCheck(); |
||||
|
||||
}); |
||||
|
||||
$form->saving(function (Form $form) { |
||||
|
||||
if ($form->isCreating()) { |
||||
$form->create_time =time(); |
||||
// 删除用户提交的数据 |
||||
$form->deleteInput('update_time'); |
||||
}else{ |
||||
$form->update_time =time(); |
||||
} |
||||
}); |
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,109 @@
@@ -0,0 +1,109 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Controllers; |
||||
|
||||
use App\Models\Order; |
||||
use Dcat\Admin\Form; |
||||
use Dcat\Admin\Grid; |
||||
use Dcat\Admin\Show; |
||||
use Dcat\Admin\Http\Controllers\AdminController; |
||||
|
||||
class OrderController extends AdminController |
||||
{ |
||||
/** |
||||
* Make a grid builder. |
||||
* |
||||
* @return Grid |
||||
*/ |
||||
protected function grid() |
||||
{ |
||||
return Grid::make(new Order(), function (Grid $grid) { |
||||
$grid->column('id')->sortable(); |
||||
$grid->column('products_name'); |
||||
$grid->column('unique_number'); |
||||
$grid->column('orders_num'); |
||||
$grid->column('amounts_price'); |
||||
$grid->column('price'); |
||||
$grid->column('transaction_id'); |
||||
$grid->column('pay_type'); |
||||
$grid->column('pay_time'); |
||||
$grid->column('create_time'); |
||||
$grid->column('update_time'); |
||||
$grid->column('status'); |
||||
$grid->column('annual_session'); |
||||
$grid->column('payment_data'); |
||||
$grid->column('source'); |
||||
$grid->column('source_orders_num'); |
||||
$grid->column('dormitory_price'); |
||||
$grid->column('source_pay_time'); |
||||
$grid->column('msg'); |
||||
|
||||
$grid->filter(function (Grid\Filter $filter) { |
||||
$filter->equal('id'); |
||||
|
||||
}); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a show builder. |
||||
* |
||||
* @param mixed $id |
||||
* |
||||
* @return Show |
||||
*/ |
||||
protected function detail($id) |
||||
{ |
||||
return Show::make($id, new Order(), function (Show $show) { |
||||
$show->field('id'); |
||||
$show->field('products_name'); |
||||
$show->field('unique_number'); |
||||
$show->field('orders_num'); |
||||
$show->field('amounts_price'); |
||||
$show->field('price'); |
||||
$show->field('transaction_id'); |
||||
$show->field('pay_type'); |
||||
$show->field('pay_time'); |
||||
$show->field('create_time'); |
||||
$show->field('update_time'); |
||||
$show->field('status'); |
||||
$show->field('annual_session'); |
||||
$show->field('payment_data'); |
||||
$show->field('source'); |
||||
$show->field('source_orders_num'); |
||||
$show->field('dormitory_price'); |
||||
$show->field('source_pay_time'); |
||||
$show->field('msg'); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a form builder. |
||||
* |
||||
* @return Form |
||||
*/ |
||||
protected function form() |
||||
{ |
||||
return Form::make(new Order(), function (Form $form) { |
||||
$form->display('id'); |
||||
$form->text('products_name'); |
||||
$form->text('unique_number'); |
||||
$form->text('orders_num'); |
||||
$form->text('amounts_price'); |
||||
$form->text('price'); |
||||
$form->text('transaction_id'); |
||||
$form->text('pay_type'); |
||||
$form->text('pay_time'); |
||||
$form->text('create_time'); |
||||
$form->text('update_time'); |
||||
$form->text('status'); |
||||
$form->text('annual_session'); |
||||
$form->text('payment_data'); |
||||
$form->text('source'); |
||||
$form->text('source_orders_num'); |
||||
$form->text('dormitory_price'); |
||||
$form->text('source_pay_time'); |
||||
$form->text('msg'); |
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,113 @@
@@ -0,0 +1,113 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Controllers; |
||||
|
||||
use App\Models\Relationship; |
||||
use Dcat\Admin\Form; |
||||
use Dcat\Admin\Grid; |
||||
use Dcat\Admin\Show; |
||||
use Dcat\Admin\Http\Controllers\AdminController; |
||||
|
||||
class RelationshipController extends AdminController |
||||
{ |
||||
/** |
||||
* Make a grid builder. |
||||
* |
||||
* @return Grid |
||||
*/ |
||||
protected function grid() |
||||
{ |
||||
return Grid::make(new Relationship(), function (Grid $grid) { |
||||
//开启边框模式 |
||||
$grid->withBorder(); |
||||
// 开启字段选择器功能 |
||||
$grid->showColumnSelector(); |
||||
|
||||
$grid->column('id')->sortable(); |
||||
$grid->column('name'); |
||||
$grid->column('status')->select([1=>"正常", 2=>"禁用"]); |
||||
$grid->column('create_time')->display(function (){ |
||||
if(!empty($this->create_time)){ |
||||
return date("Y-m-d H:i:s", $this->create_time); |
||||
} |
||||
})->sortable(); |
||||
$grid->column('update_time')->display(function (){ |
||||
if(!empty($this->update_time)){ |
||||
return date("Y-m-d H:i:s", $this->update_time); |
||||
} |
||||
}); |
||||
|
||||
$grid->filter(function (Grid\Filter $filter) { |
||||
$filter->equal('name'); |
||||
$filter->equal('status')->select([1 => "正常", 2 => "禁用"]); |
||||
}); |
||||
|
||||
// 禁用详情按钮 |
||||
$grid->disableViewButton(); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a show builder. |
||||
* |
||||
* @param mixed $id |
||||
* |
||||
* @return Show |
||||
*/ |
||||
protected function detail($id) |
||||
{ |
||||
return Show::make($id, new Relationship(), function (Show $show) { |
||||
$show->field('id'); |
||||
$show->field('name'); |
||||
$show->field('status'); |
||||
$show->field('create_time'); |
||||
$show->field('update_time'); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a form builder. |
||||
* |
||||
* @return Form |
||||
*/ |
||||
protected function form() |
||||
{ |
||||
return Form::make(new Relationship(), function (Form $form) { |
||||
$form->display('id'); |
||||
$form->text('name')->required(); |
||||
$form->select('status')->options([1 => '正常', 2 => '禁用'])->required(); |
||||
$form->hidden("create_time"); |
||||
$form->hidden("update_time"); |
||||
|
||||
// 去除删除按钮 |
||||
$form->disableDeleteButton(); |
||||
// 去除跳转详情按钮 |
||||
$form->disableViewButton(); |
||||
|
||||
$form->footer(function ($footer) { |
||||
|
||||
// 去掉`查看`checkbox |
||||
$footer->disableViewCheck(); |
||||
|
||||
// 去掉`继续编辑`checkbox |
||||
$footer->disableEditingCheck(); |
||||
|
||||
// 去掉`继续创建`checkbox |
||||
$footer->disableCreatingCheck(); |
||||
|
||||
}); |
||||
|
||||
$form->saving(function (Form $form) { |
||||
|
||||
if ($form->isCreating()) { |
||||
$form->create_time =time(); |
||||
// 删除用户提交的数据 |
||||
$form->deleteInput('update_time'); |
||||
}else{ |
||||
$form->update_time =time(); |
||||
} |
||||
}); |
||||
|
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,132 @@
@@ -0,0 +1,132 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Controllers; |
||||
|
||||
use App\Models\SchoolOpeningTime; |
||||
use Dcat\Admin\Form; |
||||
use Dcat\Admin\Grid; |
||||
use Dcat\Admin\Show; |
||||
use Dcat\Admin\Http\Controllers\AdminController; |
||||
|
||||
class SchoolOpeningTimeController extends AdminController |
||||
{ |
||||
/** |
||||
* Make a grid builder. |
||||
* |
||||
* @return Grid |
||||
*/ |
||||
protected function grid() |
||||
{ |
||||
return Grid::make(new SchoolOpeningTime(), function (Grid $grid) { |
||||
//开启边框模式 |
||||
$grid->withBorder(); |
||||
// 开启字段选择器功能 |
||||
$grid->showColumnSelector(); |
||||
|
||||
$grid->column('id')->sortable(); |
||||
$grid->column('title'); |
||||
$grid->column('type')->display(function () { |
||||
return $this->type == 1 ? "网上迎新" : "线下迎新"; |
||||
}); |
||||
$grid->column('status')->display(function() { |
||||
return $this->status == 1 ? "正常" : "禁用"; |
||||
}); |
||||
$grid->column('start_time'); |
||||
$grid->column('end_time'); |
||||
$grid->column('create_time')->display(function (){ |
||||
if(!empty($this->create_time)){ |
||||
return date("Y-m-d H:i:s", $this->create_time); |
||||
} |
||||
})->sortable(); |
||||
$grid->column('update_time')->display(function (){ |
||||
if(!empty($this->update_time)){ |
||||
return date("Y-m-d H:i:s", $this->update_time); |
||||
} |
||||
}); |
||||
|
||||
$grid->filter(function (Grid\Filter $filter) { |
||||
$filter->equal('status')->select([1 => "正常", 2 => "禁用"]); |
||||
|
||||
}); |
||||
|
||||
// 禁用创建按钮 |
||||
$grid->disableCreateButton(); |
||||
// 禁用删除按钮 |
||||
$grid->disableDeleteButton(); |
||||
//禁用批量操作按钮 |
||||
$grid->disableBatchDelete(); |
||||
|
||||
// 禁用详情按钮 |
||||
$grid->disableViewButton(); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a show builder. |
||||
* |
||||
* @param mixed $id |
||||
* |
||||
* @return Show |
||||
*/ |
||||
protected function detail($id) |
||||
{ |
||||
return Show::make($id, new SchoolOpeningTime(), function (Show $show) { |
||||
$show->field('id'); |
||||
$show->field('title'); |
||||
$show->field('type'); |
||||
$show->field('start_time'); |
||||
$show->field('end_time'); |
||||
$show->field('status'); |
||||
$show->field('create_time'); |
||||
$show->field('update_time'); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a form builder. |
||||
* |
||||
* @return Form |
||||
*/ |
||||
protected function form() |
||||
{ |
||||
return Form::make(new SchoolOpeningTime(), function (Form $form) { |
||||
$form->display('id'); |
||||
$form->text('title')->required(); |
||||
$form->select('type')->options([1 => '网上迎新', 2 => '线下迎新'])->required(); |
||||
$form->datetime('start_time')->required(); |
||||
$form->datetime('end_time')->required(); |
||||
$form->hidden("create_time"); |
||||
$form->hidden("update_time"); |
||||
|
||||
// 去除删除按钮 |
||||
$form->disableDeleteButton(); |
||||
// 去除跳转详情按钮 |
||||
$form->disableViewButton(); |
||||
|
||||
$form->footer(function ($footer) { |
||||
|
||||
// 去掉`查看`checkbox |
||||
$footer->disableViewCheck(); |
||||
|
||||
// 去掉`继续编辑`checkbox |
||||
$footer->disableEditingCheck(); |
||||
|
||||
// 去掉`继续创建`checkbox |
||||
$footer->disableCreatingCheck(); |
||||
|
||||
}); |
||||
|
||||
$form->saving(function (Form $form) { |
||||
|
||||
if ($form->isCreating()) { |
||||
$form->create_time =time(); |
||||
// 删除用户提交的数据 |
||||
$form->deleteInput('update_time'); |
||||
}else{ |
||||
$form->update_time =time(); |
||||
} |
||||
}); |
||||
|
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,118 @@
@@ -0,0 +1,118 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Controllers; |
||||
|
||||
use App\Models\SecondaryCollege; |
||||
use Dcat\Admin\Form; |
||||
use Dcat\Admin\Grid; |
||||
use Dcat\Admin\Show; |
||||
use Dcat\Admin\Http\Controllers\AdminController; |
||||
|
||||
class SecondaryCollegeController extends AdminController |
||||
{ |
||||
/** |
||||
* Make a grid builder. |
||||
* |
||||
* @return Grid |
||||
*/ |
||||
protected function grid() |
||||
{ |
||||
return Grid::make(new SecondaryCollege(), function (Grid $grid) { |
||||
//开启边框模式 |
||||
$grid->withBorder(); |
||||
// 开启字段选择器功能 |
||||
$grid->showColumnSelector(); |
||||
|
||||
$grid->column('id')->sortable(); |
||||
$grid->column('name'); |
||||
$grid->column('status')->select([1=>"正常", 2=>"禁用"]); |
||||
$grid->column('create_time')->display(function (){ |
||||
if(!empty($this->create_time)){ |
||||
return date("Y-m-d H:i:s", $this->create_time); |
||||
} |
||||
})->sortable(); |
||||
$grid->column('update_time')->display(function (){ |
||||
if(!empty($this->update_time)){ |
||||
return date("Y-m-d H:i:s", $this->update_time); |
||||
} |
||||
}); |
||||
|
||||
$grid->filter(function (Grid\Filter $filter) { |
||||
$filter->like('name'); |
||||
$filter->equal('status')->select([1 => "正常", 2 => "禁用"]); |
||||
|
||||
}); |
||||
|
||||
// 禁用删除按钮 |
||||
$grid->disableDeleteButton(); |
||||
//禁用批量操作按钮 |
||||
$grid->disableBatchDelete(); |
||||
|
||||
// 禁用详情按钮 |
||||
$grid->disableViewButton(); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a show builder. |
||||
* |
||||
* @param mixed $id |
||||
* |
||||
* @return Show |
||||
*/ |
||||
protected function detail($id) |
||||
{ |
||||
return Show::make($id, new SecondaryCollege(), function (Show $show) { |
||||
$show->field('id'); |
||||
$show->field('name'); |
||||
$show->field('status'); |
||||
$show->field('update_time'); |
||||
$show->field('create_time'); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a form builder. |
||||
* |
||||
* @return Form |
||||
*/ |
||||
protected function form() |
||||
{ |
||||
return Form::make(new SecondaryCollege(), function (Form $form) { |
||||
$form->display('id'); |
||||
$form->text('name')->required(); |
||||
$form->select('status', '状态')->options([1 => '正常', 2 => '禁用'])->required(); |
||||
$form->hidden("create_time"); |
||||
$form->hidden("update_time"); |
||||
|
||||
// 去除删除按钮 |
||||
$form->disableDeleteButton(); |
||||
// 去除跳转详情按钮 |
||||
$form->disableViewButton(); |
||||
|
||||
$form->footer(function ($footer) { |
||||
|
||||
// 去掉`查看`checkbox |
||||
$footer->disableViewCheck(); |
||||
|
||||
// 去掉`继续编辑`checkbox |
||||
$footer->disableEditingCheck(); |
||||
|
||||
// 去掉`继续创建`checkbox |
||||
$footer->disableCreatingCheck(); |
||||
|
||||
}); |
||||
|
||||
$form->saving(function (Form $form) { |
||||
|
||||
if ($form->isCreating()) { |
||||
$form->create_time =time(); |
||||
// 删除用户提交的数据 |
||||
$form->deleteInput('update_time'); |
||||
}else{ |
||||
$form->update_time =time(); |
||||
} |
||||
}); |
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,116 @@
@@ -0,0 +1,116 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Controllers; |
||||
|
||||
use App\Models\SecurityUser; |
||||
use Dcat\Admin\Form; |
||||
use Dcat\Admin\Grid; |
||||
use Dcat\Admin\Show; |
||||
use Dcat\Admin\Http\Controllers\AdminController; |
||||
|
||||
class SecurityUserController extends AdminController |
||||
{ |
||||
/** |
||||
* Make a grid builder. |
||||
* |
||||
* @return Grid |
||||
*/ |
||||
protected function grid() |
||||
{ |
||||
return Grid::make(new SecurityUser(), function (Grid $grid) { |
||||
$grid->column('id')->sortable(); |
||||
$grid->column('security_name'); |
||||
$grid->column('screct_key'); |
||||
$grid->column('public_key'); |
||||
$grid->column('msg'); |
||||
$grid->column('create_time')->display(function (){ |
||||
if(!empty($this->create_time)){ |
||||
return date("Y-m-d H:i:s", $this->create_time); |
||||
} |
||||
})->sortable(); |
||||
|
||||
$grid->filter(function (Grid\Filter $filter) { |
||||
$filter->equal('id'); |
||||
|
||||
}); |
||||
|
||||
// 禁用删除按钮 |
||||
$grid->disableDeleteButton(); |
||||
//禁用批量操作按钮 |
||||
$grid->disableBatchDelete(); |
||||
// 禁用详情按钮 |
||||
$grid->disableViewButton(); |
||||
// 禁用创建按钮 |
||||
$grid->disableCreateButton(); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a show builder. |
||||
* |
||||
* @param mixed $id |
||||
* |
||||
* @return Show |
||||
*/ |
||||
protected function detail($id) |
||||
{ |
||||
return Show::make($id, new SecurityUser(), function (Show $show) { |
||||
$show->field('id'); |
||||
$show->field('security_name'); |
||||
$show->field('screct_key'); |
||||
$show->field('public_key'); |
||||
$show->field('status'); |
||||
$show->field('msg'); |
||||
$show->field('create_time'); |
||||
$show->field('update_time'); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a form builder. |
||||
* |
||||
* @return Form |
||||
*/ |
||||
protected function form() |
||||
{ |
||||
return Form::make(new SecurityUser(), function (Form $form) { |
||||
$form->display('id'); |
||||
$form->text('security_name'); |
||||
$form->text('screct_key'); |
||||
$form->text('public_key'); |
||||
$form->text('msg'); |
||||
$form->hidden("create_time"); |
||||
$form->hidden("update_time"); |
||||
|
||||
// 去除删除按钮 |
||||
$form->disableDeleteButton(); |
||||
|
||||
// 去除跳转详情按钮 |
||||
$form->disableViewButton(); |
||||
|
||||
$form->footer(function ($footer) { |
||||
|
||||
// 去掉`查看`checkbox |
||||
$footer->disableViewCheck(); |
||||
|
||||
// 去掉`继续编辑`checkbox |
||||
$footer->disableEditingCheck(); |
||||
|
||||
// 去掉`继续创建`checkbox |
||||
$footer->disableCreatingCheck(); |
||||
|
||||
}); |
||||
|
||||
$form->saving(function (Form $form) { |
||||
|
||||
if ($form->isCreating()) { |
||||
$form->create_time =time(); |
||||
// 删除用户提交的数据 |
||||
$form->deleteInput('update_time'); |
||||
}else{ |
||||
$form->update_time =time(); |
||||
} |
||||
}); |
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,472 @@
@@ -0,0 +1,472 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Controllers; |
||||
|
||||
use App\Admin\Metrics\Examples\SelectedDormitoryNewTotal; |
||||
use App\Admin\Metrics\Examples\SelectedDormitoryTotal; |
||||
use App\Admin\Repositories\MultipleWorld; |
||||
use App\Models\AllocationDormitoryBed; |
||||
use App\Models\CompletedStep; |
||||
use App\Models\Config; |
||||
use App\Models\Order; |
||||
use App\Models\PaymentList; |
||||
use App\Models\ReportFormInfo; |
||||
use App\Models\SecondaryCollege; |
||||
use App\Models\SelectedDormitory; |
||||
use App\Models\Speciality; |
||||
use App\Models\UsersMember; |
||||
use Dcat\Admin\Form; |
||||
use Dcat\Admin\Grid; |
||||
use Dcat\Admin\Layout\Content; |
||||
use Dcat\Admin\Layout\Row; |
||||
use Dcat\Admin\Show; |
||||
use Dcat\Admin\Http\Controllers\AdminController; |
||||
use Dcat\Admin\Support\JavaScript; |
||||
use Dcat\Admin\Widgets\Metrics\Card; |
||||
use Dcat\Admin\Widgets\Table; |
||||
use Illuminate\Support\Facades\DB; |
||||
use Illuminate\Support\MessageBag; |
||||
|
||||
class SelectedDormitoryController extends AdminController |
||||
{ |
||||
public function index(Content $content) |
||||
{ |
||||
return $content |
||||
->header('分配宿舍') |
||||
->description('数据统计') |
||||
->body(function (Row $row) { |
||||
$row->column(6, new SelectedDormitoryTotal()); |
||||
$row->column(6, new SelectedDormitoryNewTotal()); |
||||
}) |
||||
->body($this->grid()); |
||||
} |
||||
|
||||
/** |
||||
* Make a grid builder. |
||||
* |
||||
* @return Grid |
||||
*/ |
||||
protected function grid() |
||||
{ |
||||
return Grid::make(new SelectedDormitory(), function (Grid $grid) { |
||||
//开启边框模式 |
||||
$grid->withBorder(); |
||||
// 开启字段选择器功能 |
||||
$grid->showColumnSelector(); |
||||
|
||||
$grid->column('id')->sortable(); |
||||
$grid->column('annual_session'); |
||||
$grid->column('idcard')->display(function($info){ |
||||
$info = UsersMember::query()->where("unique_number", $this->unique_number)->first(); |
||||
if(!empty($info)){ |
||||
return $info->idcard; |
||||
} |
||||
})->help("不显示时代表未找到该用户"); |
||||
$grid->column('mobile')->display(function($info){ |
||||
$info = UsersMember::query()->where("unique_number", $this->unique_number)->first(); |
||||
if(!empty($info)){ |
||||
return $info->mobile; |
||||
} |
||||
})->help("不显示时代表未找到该用户"); |
||||
$grid->column('user_name')->display(function(){ |
||||
$info = UsersMember::query()->where("unique_number", $this->unique_number)->first(); |
||||
if(!empty($info)){ |
||||
$str = ''; |
||||
if($info->is_test == 2){ |
||||
$str = "(测试)"; |
||||
} |
||||
return $info->name.$str; |
||||
} |
||||
})->help("不显示时代表未找到该用户"); |
||||
$grid->column('sex', __('性别'))->display(function(){ |
||||
$info = UsersMember::query()->where("unique_number", $this->unique_number)->first(); |
||||
if(empty($info)){ |
||||
return "不存在此账号"; |
||||
} |
||||
if($info->sex == 1){ |
||||
return "男"; |
||||
} |
||||
if($info->sex == 2){ |
||||
return "女"; |
||||
} |
||||
return "未知"; |
||||
}); |
||||
$grid->column('speciality_id')->display(function(){ |
||||
$info = UsersMember::query()->where("unique_number", $this->unique_number)->first(); |
||||
if(!empty($info)){ |
||||
$speciality = Speciality::query()->where("id", $info->speciality_id)->first(); |
||||
if(!empty($speciality)){ |
||||
$college = SecondaryCollege::query()->where("id", $speciality->secondary_college_id)->first(); |
||||
if(!empty($college)){ |
||||
return $speciality->speciality_name."({$college->name})"; |
||||
} |
||||
} |
||||
} |
||||
}); |
||||
$grid->column('is_pay')->display(function(){ |
||||
$info = Order::query()->where([ |
||||
"unique_number" => $this->unique_number, |
||||
"status" => Order::STATUS_PAID, |
||||
"parent_id" => Order::PARENT_YES, |
||||
"annual_session" => $this->annual_session, |
||||
"selected_dormitory_id" => $this->allocation_dormitory_id |
||||
])->first(); |
||||
|
||||
if(empty($info)){ |
||||
return "未支付"; |
||||
} |
||||
return "已支付"; |
||||
}); |
||||
$grid->column('dormitory_price')->display(function(){ |
||||
$years = date("Y", time()); |
||||
$timeIdCode = "2({$years})"; |
||||
$info = PaymentList::query()->where([ |
||||
"unique_number" => $this->unique_number, |
||||
"annual_session" => $this->annual_session, |
||||
"project_code" => $timeIdCode |
||||
])->first(); |
||||
|
||||
if(!empty($info)){ |
||||
return $info->standard."(欠费:{$info->amount})"; |
||||
} |
||||
|
||||
})->help("所选宿舍标准金额,欠费则代表还需缴纳该费用"); |
||||
|
||||
$grid->column('allocation_dormitory_id')->modal("床位详情", function($modal){ |
||||
$modal->xl(); |
||||
$list = SelectedDormitory::getBedInfoById($this->allocation_dormitory_id); |
||||
return Table::make($list["lable"], $list["value"]); |
||||
})->help("对应的是录入床位的详细信息"); |
||||
$grid->column('allocation_dormitory_name')->help("学生在迎新系统上确认该床位时才会显示"); |
||||
$grid->column('status')->select([1 => "正常", 2 => "禁用"])->help("状态为正常时才是正常在使用的床位"); |
||||
|
||||
|
||||
$grid->filter(function (Grid\Filter $filter) { |
||||
$filter->equal('allocation_dormitory_id', '床位id'); |
||||
$filter->where("unique_number", function ($query) { |
||||
$unique_number = ""; |
||||
$userInfo = UsersMember::query()->where('mobile', $this->input)->orWhere('idcard', $this->input)->orWhere('name', $this->input)->first(['unique_number']); |
||||
if(!empty($userInfo)){ |
||||
$unique_number = $userInfo->unique_number; |
||||
} |
||||
$query->where('unique_number', $unique_number); |
||||
}, '手机号/身份证/姓名'); |
||||
$filter->equal('status', '状态')->select([1 => "正常", 2 => "禁用"]); |
||||
|
||||
}); |
||||
$grid->actions(function (Grid\Displayers\Actions $actions) { |
||||
// append一个操作 |
||||
$actions->append('<a href=""><i class="fa fa-eye"></i> 退学禁用</a>'); |
||||
|
||||
}); |
||||
|
||||
// 禁用创建按钮 |
||||
$grid->disableCreateButton(); |
||||
// 禁用删除按钮 |
||||
$grid->disableDeleteButton(); |
||||
//禁用批量操作按钮 |
||||
$grid->disableBatchDelete(); |
||||
// 禁用详情按钮 |
||||
$grid->disableViewButton(); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a show builder. |
||||
* |
||||
* @param mixed $id |
||||
* |
||||
* @return Show |
||||
*/ |
||||
protected function detail($id) |
||||
{ |
||||
return Show::make($id, new SelectedDormitory(), function (Show $show) { |
||||
$show->field('id'); |
||||
$show->field('allocation_dormitory_id'); |
||||
$show->field('annual_session'); |
||||
$show->field('unique_number'); |
||||
$show->field('allocation_dormitory_name'); |
||||
$show->field('status'); |
||||
$show->field('create_time'); |
||||
$show->field('update_time'); |
||||
}); |
||||
} |
||||
|
||||
protected function form() |
||||
{ |
||||
return Form::make(new SelectedDormitory(), function(Form $form){ |
||||
//检测是否为新增 |
||||
if ($form->isCreating()) { |
||||
admin_error('操作异常', '不允许新增分配信息'); |
||||
} |
||||
|
||||
//检测当前分配宿舍信息是否为禁用状态 |
||||
if($form->model()->status == 2){ |
||||
admin_error('操作异常', '不允许修改禁用的床位(修改会导致数据错乱)'); |
||||
} |
||||
|
||||
$form->block(6, function(Form\BlockForm $form){ |
||||
// 设置标题 |
||||
$form->title('已分配宿舍详情'); |
||||
|
||||
//取出当前年份 |
||||
$config = Config::query()->where([ |
||||
"unique_identification" => "annual_session" |
||||
])->first(); |
||||
//取出床位详细信息 |
||||
$allocationDormitoryId = $form->model()->allocation_dormitory_id; |
||||
$bedInfo = AllocationDormitoryBed::query()->where([ |
||||
"id" => $allocationDormitoryId, |
||||
// "status" => AllocationDormitoryBed::STATUS_YES, |
||||
"annual_session" => $config->data, |
||||
])->first(); |
||||
|
||||
if(empty($bedInfo)){ |
||||
// 中断后续逻辑 |
||||
return $form->response()->error('找不到该床位信息或已被删除'); |
||||
} |
||||
|
||||
$form->select('sex', '性别') |
||||
->options(config("app.url")."/api/getSex?sex=".$bedInfo->sex) |
||||
->value($bedInfo->sex) |
||||
->disable(); |
||||
|
||||
$form->select('speciality_id', '专业') |
||||
->options(config("app.url")."/api/getSpeciality") |
||||
->value($bedInfo->speciality_id) |
||||
->disable(); |
||||
|
||||
$form->select('dormitory_type', "宿舍类型") |
||||
->options(config("app.url")."/api/getDormitoryType?dormitory_type=".$bedInfo->dormitory_type) |
||||
->value($bedInfo->dormitory_type) |
||||
->disable(); |
||||
|
||||
$form->select('multiple_worlds', "几人间") |
||||
->options(config("app.url")."/api/getMultipleWorlds?multiple_worlds=".$bedInfo->multiple_worlds) |
||||
->value($bedInfo->multiple_worlds) |
||||
->disable(); |
||||
|
||||
$form->select("living_area", "生活区") |
||||
->options(config("app.url")."/api/getLiving?living_quarters=".$bedInfo->living_area) |
||||
->value($bedInfo->living_area) |
||||
->disable(); |
||||
|
||||
$form->select("building_id", "楼栋") |
||||
->options(config("app.url")."/api/getBuilding?building_id=".$bedInfo->building_id) |
||||
->value($bedInfo->building_id) |
||||
->disable(); |
||||
|
||||
$form->select("floor_id", "楼层") |
||||
->options(config("app.url")."/api/getFloor?floor_id=".$bedInfo->floor_id) |
||||
->value($bedInfo->floor_id) |
||||
->disable(); |
||||
|
||||
$form->select("dormitory_number", "宿舍号") |
||||
->options(config("app.url")."/api/getDormitoryNumber?dormitory_number=".$bedInfo->dormitory_number) |
||||
->value($bedInfo->dormitory_number) |
||||
->disable(); |
||||
|
||||
$form->select("bed_id", "床位") |
||||
->options(config("app.url")."/api/getBed?bed_id=".$bedInfo->bed_id) |
||||
->value($bedInfo->bed_id) |
||||
->disable(); |
||||
|
||||
}); |
||||
|
||||
$form->block(6, function(Form\BlockForm $form){ |
||||
// 设置标题 |
||||
$form->title('重新分配宿舍'); |
||||
//取出用户信息 |
||||
$userInfo = UsersMember::query()->where([ |
||||
"unique_number" => $form->model()->unique_number, |
||||
])->first(); |
||||
|
||||
$form->select('sex_new', '性别') |
||||
->options(config("app.url")."/api/getSex?sex=".$userInfo->sex) |
||||
->value($userInfo->sex) |
||||
->load("speciality_id_new", config("app.url")."/api/getSpecialityLoad?sex=".$userInfo->sex) |
||||
->required(); |
||||
|
||||
$form->select('speciality_id_new', '专业') |
||||
->load("dormitory_type_new", config("app.url")."/api/getDormitoryTypeLoad?sex=".$userInfo->sex) |
||||
->required(); |
||||
|
||||
$form->select('dormitory_type_new', "宿舍类型") |
||||
->load("multiple_worlds_new", config("app.url")."/api/getMultiplWorldsLoad") |
||||
->required(); |
||||
|
||||
$form->select('multiple_worlds_new', "几人间") |
||||
->load("living_area_new", config("app.url")."/api/getLivingAreaLoad") |
||||
->required(); |
||||
|
||||
$form->select('living_area_new', "生活区") |
||||
->load("building_id_new", config("app.url")."/api/getBuildingLoad") |
||||
->required(); |
||||
|
||||
$form->select("building_id_new", "楼栋") |
||||
->load("floor_id_new", config("app.url")."/api/getFloorLoad") |
||||
->required(); |
||||
|
||||
$form->select("floor_id_new", "楼层") |
||||
->load("dormitory_number_new", config("app.url")."/api/getDormitoryNumberLoad") |
||||
->required(); |
||||
|
||||
$form->select("dormitory_number_new", "宿舍号") |
||||
->load("bed_id_new", config("app.url")."/api/getBedLoad") |
||||
->required(); |
||||
|
||||
$form->select("bed_id_new", "床位")->required(); |
||||
|
||||
// 显示底部提交按钮 |
||||
$form->showFooter(); |
||||
|
||||
}); |
||||
|
||||
//设置不提交保存 |
||||
$form->ignore([ |
||||
"sex", |
||||
"speciality_id", |
||||
"dormitory_type", |
||||
"multiple_worlds", |
||||
"living_area", |
||||
"building_id", |
||||
"floor_id", |
||||
"dormitory_number", |
||||
"bed_id", |
||||
"sex_new", |
||||
"speciality_id_new", |
||||
"dormitory_type_new", |
||||
"multiple_worlds_new", |
||||
"living_area_new", |
||||
"building_id_new", |
||||
"floor_id_new", |
||||
"dormitory_number_new", |
||||
"bed_id_new", |
||||
]); |
||||
|
||||
$form->submitted(function (Form $form) { |
||||
// 获取用户提交参数 |
||||
$bed_id_new = json_decode($form->bed_id_new, true); |
||||
$dormitory_type_new = json_decode($form->dormitory_type_new, true); |
||||
$id = request()->route()->parameters()["selected_dormitory"]; |
||||
|
||||
//取出当前年份 |
||||
$config = Config::query()->where([ |
||||
"unique_identification" => "annual_session" |
||||
])->first(); |
||||
|
||||
//取出当前id的数据 |
||||
$thisSelectInfo = SelectedDormitory::query()->where([ |
||||
"id" => $id, |
||||
"status" => SelectedDormitory::STATUS_YES |
||||
])->first(); |
||||
if(empty($thisSelectInfo)){ |
||||
// 中断后续逻辑 |
||||
return $form->response()->error('查询不到当前信息,请重试~'); |
||||
} |
||||
|
||||
//组装查询条件 |
||||
$bedInfo = [ |
||||
"dormitory_type" => $bed_id_new["dormitory_type"], |
||||
"multiple_worlds" => $bed_id_new["multiple_worlds"], |
||||
"living_area" => $bed_id_new["living_area"], |
||||
"building_id" => $bed_id_new["building"], |
||||
"floor_id" => $bed_id_new["floor"], |
||||
"dormitory_number" => $bed_id_new["dormitory_number"], |
||||
"bed_id" => $bed_id_new["id"], |
||||
"speciality_id" => $dormitory_type_new["speciality_id"], |
||||
"sex" => $dormitory_type_new["sex"], |
||||
"annual_session" => $config->data, |
||||
"status" => AllocationDormitoryBed::STATUS_YES |
||||
]; |
||||
|
||||
|
||||
$checkBedInfo = AllocationDormitoryBed::query()->where($bedInfo)->first(); |
||||
if(empty($checkBedInfo)){ |
||||
// 中断后续逻辑 |
||||
return $form->response()->error('查询不到该床位,请重试~'); |
||||
} |
||||
|
||||
//检测是否被选 |
||||
$checkSelect = SelectedDormitory::query()->where([ |
||||
"allocation_dormitory_id" => $checkBedInfo->id, |
||||
"status" => SelectedDormitory::STATUS_YES |
||||
])->first(); |
||||
if(!empty($checkSelect)){ |
||||
// 中断后续逻辑 |
||||
return $form->response()->error('该床位已被选,请重试~'); |
||||
} |
||||
|
||||
//检测订单是否支付 |
||||
$orderInfo = Order::query()->where([ |
||||
"unique_number" => $thisSelectInfo->unique_number, |
||||
"status" => Order::STATUS_PAID, |
||||
"annual_session" => $config->data, |
||||
"parent_id" => Order::PARENT_YES, |
||||
])->first(); |
||||
|
||||
if(empty($orderInfo)){ |
||||
// 中断后续逻辑 |
||||
return $form->response()->error('当前用户未缴费,请重试~'); |
||||
} |
||||
|
||||
//取出宿舍标准金额 |
||||
$checkMultiplWorldInfo = \App\Models\MultipleWorld::query()->where([ |
||||
"id" => $bedInfo["multiple_worlds"], |
||||
"dormitory_type_id" => $bedInfo["dormitory_type"], |
||||
"status" => \App\Models\MultipleWorld::STATUS_YES |
||||
])->first(); |
||||
if(empty($checkMultiplWorldInfo)){ |
||||
// 中断后续逻辑 |
||||
return $form->response()->error('未找到对应几人间价格,请重试~'); |
||||
} |
||||
|
||||
DB::beginTransaction(); |
||||
try { |
||||
//修改父级订单分配宿舍信息 |
||||
$updateOrder = Order::query()->where("id", $orderInfo->id)->update([ |
||||
"selected_dormitory_id" => $checkBedInfo->id, |
||||
"dormitory_price" => $checkMultiplWorldInfo->price, |
||||
"update_time" => time() |
||||
]); |
||||
if(empty($updateOrder)){ |
||||
throw new \Exception("同步订单信息失败"); |
||||
} |
||||
|
||||
//删除用户已选宿舍后面所有步骤 |
||||
CompletedStep::query()->where([ |
||||
"unique_number" => $thisSelectInfo->unique_number, |
||||
])->where("step_id", ">=", 5)->delete(); |
||||
|
||||
//删除已生成报到单 |
||||
ReportFormInfo::query()->where([ |
||||
"unique_number" => $thisSelectInfo->unique_number, |
||||
"annual_session" => $config->data, |
||||
])->delete(); |
||||
|
||||
//同步当前已分配信息 |
||||
$updateSelectInfo = SelectedDormitory::query()->where([ |
||||
"id" => $id, |
||||
"unique_number" => $thisSelectInfo->unique_number |
||||
])->update([ |
||||
"allocation_dormitory_id" => $checkBedInfo->id, |
||||
"status" => SelectedDormitory::STATUS_YES, |
||||
"allocation_dormitory_name" => "", |
||||
"update_time" => time(), |
||||
]); |
||||
if(empty($updateSelectInfo)){ |
||||
throw new \Exception("同步当前已分配宿舍信息失败,请重试~"); |
||||
} |
||||
|
||||
DB::commit(); |
||||
redirect(url('admin/selected_dormitory')); |
||||
}catch (\Exception $e){ |
||||
DB::rollBack(); |
||||
} |
||||
|
||||
}); |
||||
|
||||
}); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,136 @@
@@ -0,0 +1,136 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Controllers; |
||||
|
||||
use App\Models\SecondaryCollege; |
||||
use App\Models\Speciality; |
||||
use Dcat\Admin\Form; |
||||
use Dcat\Admin\Grid; |
||||
use Dcat\Admin\Show; |
||||
use Dcat\Admin\Http\Controllers\AdminController; |
||||
|
||||
class SpecialityController extends AdminController |
||||
{ |
||||
/** |
||||
* Make a grid builder. |
||||
* |
||||
* @return Grid |
||||
*/ |
||||
protected function grid() |
||||
{ |
||||
return Grid::make(new Speciality(), function (Grid $grid) { |
||||
//开启边框模式 |
||||
$grid->withBorder(); |
||||
// 开启字段选择器功能 |
||||
$grid->showColumnSelector(); |
||||
|
||||
$grid->column('id')->sortable(); |
||||
$grid->column('secondary_college_id')->display(function () { |
||||
$secondary_college_id = $this->secondary_college_id; |
||||
if (!empty($secondary_college_id)) { |
||||
$name = SecondaryCollege::query()->where("id", $secondary_college_id)->first("name"); |
||||
if (!empty($name)) { |
||||
return $name->name; |
||||
} |
||||
} |
||||
})->help("二级学院显示为空时则对应的二级学院信息可能已被删除"); |
||||
|
||||
$grid->column('speciality_name'); |
||||
$grid->column('status')->select([1=>"正常", 2=>"禁用"]); |
||||
$grid->column('create_time')->display(function (){ |
||||
if(!empty($this->create_time)){ |
||||
return date("Y-m-d H:i:s", $this->create_time); |
||||
} |
||||
})->sortable(); |
||||
$grid->column('update_time')->display(function (){ |
||||
if(!empty($this->update_time)){ |
||||
return date("Y-m-d H:i:s", $this->update_time); |
||||
} |
||||
}); |
||||
|
||||
|
||||
$grid->filter(function (Grid\Filter $filter) { |
||||
$filter->equal('secondary_college_id')->select(function (){ |
||||
return SecondaryCollege::query()->pluck("name as value", "id"); |
||||
}); |
||||
$filter->equal('status')->select([1 => "正常", 2 => "禁用"]); |
||||
}); |
||||
// 禁用删除按钮 |
||||
$grid->disableDeleteButton(); |
||||
//禁用批量操作按钮 |
||||
$grid->disableBatchDelete(); |
||||
|
||||
// 禁用详情按钮 |
||||
$grid->disableViewButton(); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a show builder. |
||||
* |
||||
* @param mixed $id |
||||
* |
||||
* @return Show |
||||
*/ |
||||
protected function detail($id) |
||||
{ |
||||
return Show::make($id, new Speciality(), function (Show $show) { |
||||
$show->field('id'); |
||||
$show->field('speciality_name'); |
||||
$show->field('status'); |
||||
$show->field('create_time'); |
||||
$show->field('update_time'); |
||||
$show->field('secondary_college_id'); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a form builder. |
||||
* |
||||
* @return Form |
||||
*/ |
||||
protected function form() |
||||
{ |
||||
return Form::make(new Speciality(), function (Form $form) { |
||||
$form->display('id'); |
||||
$form->select('secondary_college_id')->options(function(){ |
||||
return SecondaryCollege::query()->pluck("name as value", "id"); |
||||
})->required(); |
||||
$form->text('speciality_name')->required(); |
||||
$form->select('status', '状态')->options([1 => '正常', 2 => '禁用'])->required(); |
||||
|
||||
$form->hidden("create_time"); |
||||
$form->hidden("update_time"); |
||||
|
||||
// 去除删除按钮 |
||||
$form->disableDeleteButton(); |
||||
// 去除跳转详情按钮 |
||||
$form->disableViewButton(); |
||||
|
||||
$form->footer(function ($footer) { |
||||
|
||||
// 去掉`查看`checkbox |
||||
$footer->disableViewCheck(); |
||||
|
||||
// 去掉`继续编辑`checkbox |
||||
$footer->disableEditingCheck(); |
||||
|
||||
// 去掉`继续创建`checkbox |
||||
$footer->disableCreatingCheck(); |
||||
|
||||
}); |
||||
|
||||
$form->saving(function (Form $form) { |
||||
|
||||
if ($form->isCreating()) { |
||||
$form->create_time =time(); |
||||
// 删除用户提交的数据 |
||||
$form->deleteInput('update_time'); |
||||
}else{ |
||||
$form->update_time =time(); |
||||
} |
||||
}); |
||||
|
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,119 @@
@@ -0,0 +1,119 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Controllers; |
||||
|
||||
use App\Models\Step; |
||||
use Dcat\Admin\Form; |
||||
use Dcat\Admin\Grid; |
||||
use Dcat\Admin\Show; |
||||
use Dcat\Admin\Http\Controllers\AdminController; |
||||
|
||||
class StepController extends AdminController |
||||
{ |
||||
/** |
||||
* Make a grid builder. |
||||
* |
||||
* @return Grid |
||||
*/ |
||||
protected function grid() |
||||
{ |
||||
return Grid::make(new Step(), function (Grid $grid) { |
||||
//开启边框模式 |
||||
$grid->withBorder(); |
||||
// 开启字段选择器功能 |
||||
$grid->showColumnSelector(); |
||||
|
||||
$grid->column('id')->sortable(); |
||||
$grid->column('title'); |
||||
$grid->column('sort'); |
||||
$grid->column('status')->display(function() { |
||||
return $this->status == 1 ? "正常" : "禁用"; |
||||
}); |
||||
$grid->column('create_time')->display(function (){ |
||||
if(!empty($this->create_time)){ |
||||
return date("Y-m-d H:i:s", $this->create_time); |
||||
} |
||||
})->sortable(); |
||||
$grid->column('update_time')->display(function (){ |
||||
if(!empty($this->update_time)){ |
||||
return date("Y-m-d H:i:s", $this->update_time); |
||||
} |
||||
}); |
||||
|
||||
$grid->filter(function (Grid\Filter $filter) { |
||||
$filter->equal('status')->select([1 => "正常", 2 => "禁用"]); |
||||
|
||||
}); |
||||
|
||||
// 禁用创建按钮 |
||||
$grid->disableCreateButton(); |
||||
// 禁用删除按钮 |
||||
$grid->disableDeleteButton(); |
||||
//禁用批量操作按钮 |
||||
$grid->disableBatchDelete(); |
||||
|
||||
// 禁用详情按钮 |
||||
$grid->disableViewButton(); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a show builder. |
||||
* |
||||
* @param mixed $id |
||||
* |
||||
* @return Show |
||||
*/ |
||||
protected function detail($id) |
||||
{ |
||||
return Show::make($id, new Step(), function (Show $show) { |
||||
$show->field('id'); |
||||
$show->field('title'); |
||||
|
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a form builder. |
||||
* |
||||
* @return Form |
||||
*/ |
||||
protected function form() |
||||
{ |
||||
return Form::make(new Step(), function (Form $form) { |
||||
$form->display('id'); |
||||
$form->text('title')->required(); |
||||
$form->hidden("create_time"); |
||||
$form->hidden("update_time"); |
||||
|
||||
// 去除删除按钮 |
||||
$form->disableDeleteButton(); |
||||
// 去除跳转详情按钮 |
||||
$form->disableViewButton(); |
||||
|
||||
$form->footer(function ($footer) { |
||||
|
||||
// 去掉`查看`checkbox |
||||
$footer->disableViewCheck(); |
||||
|
||||
// 去掉`继续编辑`checkbox |
||||
$footer->disableEditingCheck(); |
||||
|
||||
// 去掉`继续创建`checkbox |
||||
$footer->disableCreatingCheck(); |
||||
|
||||
}); |
||||
|
||||
$form->saving(function (Form $form) { |
||||
|
||||
if ($form->isCreating()) { |
||||
$form->create_time =time(); |
||||
// 删除用户提交的数据 |
||||
$form->deleteInput('update_time'); |
||||
}else{ |
||||
$form->update_time =time(); |
||||
} |
||||
}); |
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,189 @@
@@ -0,0 +1,189 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Controllers; |
||||
|
||||
use App\Models\TeacherScanCodeUsers; |
||||
use Dcat\Admin\Form; |
||||
use Dcat\Admin\Grid; |
||||
use Dcat\Admin\Show; |
||||
use Dcat\Admin\Http\Controllers\AdminController; |
||||
|
||||
class TeacherScanCodeUserController extends AdminController |
||||
{ |
||||
/** |
||||
* Make a grid builder. |
||||
* |
||||
* @return Grid |
||||
*/ |
||||
protected function grid() |
||||
{ |
||||
return Grid::make(new TeacherScanCodeUsers(), function (Grid $grid) { |
||||
//开启边框模式 |
||||
$grid->withBorder(); |
||||
// 开启字段选择器功能 |
||||
$grid->showColumnSelector(); |
||||
|
||||
$grid->column('id')->sortable(); |
||||
$grid->column('name'); |
||||
$grid->column('mobile'); |
||||
$grid->column('belongto')->display(function () { |
||||
switch ($this->belongto) { |
||||
case TeacherScanCodeUsers::BELONGTO_ONE: //招生办 |
||||
return "招生办"; |
||||
break; |
||||
case TeacherScanCodeUsers::BELONGTO_TWO: //二级学院 |
||||
return "二级学院"; |
||||
break; |
||||
case TeacherScanCodeUsers::BELONGTO_THREE: //宿管 |
||||
return "宿管"; |
||||
break; |
||||
} |
||||
|
||||
}); |
||||
$grid->column('open_number_id')->display(function () { |
||||
$open_number_id = $this->open_number_id; |
||||
if (!empty($open_number_id)) { |
||||
if ($open_number_id == $this->id) { |
||||
return $this->name; |
||||
} else { |
||||
$name = TeacherScanCodeUsers::query()->where("id", $open_number_id)->first("name"); |
||||
if(empty($name)){ |
||||
return ""; |
||||
} |
||||
return $name->name; |
||||
} |
||||
} |
||||
return "超级管理员"; |
||||
}); |
||||
$grid->column('status')->select([1=>"正常", 2=>"禁用"]); |
||||
$grid->column('create_time')->display(function (){ |
||||
if(!empty($this->create_time)){ |
||||
return date("Y-m-d H:i:s", $this->create_time); |
||||
} |
||||
})->sortable(); |
||||
$grid->column('update_time')->display(function (){ |
||||
if(!empty($this->update_time)){ |
||||
return date("Y-m-d H:i:s", $this->update_time); |
||||
} |
||||
}); |
||||
|
||||
$grid->filter(function (Grid\Filter $filter) { |
||||
$filter->equal('name'); |
||||
$filter->equal('mobile'); |
||||
$filter->equal('belongto')->select(function (){ |
||||
return [ |
||||
TeacherScanCodeUsers::BELONGTO_ONE => "招生办", |
||||
TeacherScanCodeUsers::BELONGTO_TWO => "二级学院", |
||||
TeacherScanCodeUsers::BELONGTO_THREE => "宿管", |
||||
]; |
||||
}); |
||||
$filter->equal('status')->select([1 => "正常", 2 => "禁用"]); |
||||
}); |
||||
|
||||
// 禁用详情按钮 |
||||
$grid->disableViewButton(); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a show builder. |
||||
* |
||||
* @param mixed $id |
||||
* |
||||
* @return Show |
||||
*/ |
||||
protected function detail($id) |
||||
{ |
||||
return Show::make($id, new TeacherScanCodeUsers(), function (Show $show) { |
||||
$show->field('id'); |
||||
$show->field('name'); |
||||
$show->field('mobile'); |
||||
$show->field('belongto'); |
||||
$show->field('open_number_id'); |
||||
$show->field('status'); |
||||
$show->field('create_time'); |
||||
$show->field('update_time'); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a form builder. |
||||
* |
||||
* @return Form |
||||
*/ |
||||
protected function form() |
||||
{ |
||||
return Form::make(new TeacherScanCodeUsers(), function (Form $form) { |
||||
|
||||
$form->display('id'); |
||||
$form->text('name')->required(); |
||||
$form->text('mobile')->required(); |
||||
$form->password('password')->required(); |
||||
|
||||
$form->select('belongto')->options([ |
||||
TeacherScanCodeUsers::BELONGTO_ONE => "招生办", |
||||
TeacherScanCodeUsers::BELONGTO_TWO => "二级学院", |
||||
TeacherScanCodeUsers::BELONGTO_THREE => "宿管", |
||||
])->required(); |
||||
$form->select('is_authority', '是否允许创建子账号')->options([1 => '否', 2 => '是'])->required()->help("允许创建子账号时则可以在教师端新增该部门下的教师账号"); |
||||
$form->select('open_number_id')->options(function (){ |
||||
|
||||
$result = [ |
||||
"0" => "超级管理员", |
||||
]; |
||||
$list = TeacherScanCodeUsers::query()->where([ |
||||
"status" => TeacherScanCodeUsers::STATUS_SUCCESS, |
||||
"is_authority" => TeacherScanCodeUsers::IS_AUTHORITY_YES, |
||||
])->get()->toArray(); |
||||
if(empty($list)){ |
||||
return $result; |
||||
} |
||||
$belongtoList = [ |
||||
TeacherScanCodeUsers::BELONGTO_ONE => "招生办", |
||||
TeacherScanCodeUsers::BELONGTO_TWO => "二级学院", |
||||
TeacherScanCodeUsers::BELONGTO_THREE => "宿管", |
||||
]; |
||||
|
||||
foreach($list as $item){ |
||||
$result[$item["id"]] = $item["name"]."--{$belongtoList[$item['belongto']]}"; |
||||
} |
||||
return $result; |
||||
}); |
||||
$form->select('status')->options([1 => '正常', 2 => '禁用'])->required(); |
||||
$form->hidden("create_time"); |
||||
$form->hidden("update_time"); |
||||
|
||||
// 去除删除按钮 |
||||
$form->disableDeleteButton(); |
||||
// 去除跳转详情按钮 |
||||
$form->disableViewButton(); |
||||
|
||||
$form->footer(function ($footer) { |
||||
|
||||
// 去掉`查看`checkbox |
||||
$footer->disableViewCheck(); |
||||
|
||||
// 去掉`继续编辑`checkbox |
||||
$footer->disableEditingCheck(); |
||||
|
||||
// 去掉`继续创建`checkbox |
||||
$footer->disableCreatingCheck(); |
||||
|
||||
}); |
||||
|
||||
$form->saving(function (Form $form) { |
||||
if (strlen($form->password) < 32) { |
||||
$form->password = bcrypt($form->password); |
||||
} |
||||
if ($form->isCreating()) { |
||||
$form->create_time =time(); |
||||
// 删除用户提交的数据 |
||||
$form->deleteInput('update_time'); |
||||
}else{ |
||||
$form->update_time =time(); |
||||
} |
||||
}); |
||||
|
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,321 @@
@@ -0,0 +1,321 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Controllers; |
||||
|
||||
|
||||
use App\Admin\Extensions\Exporter\StudentExporter; |
||||
use App\Admin\Metrics\Examples\NewUsers; |
||||
use App\Admin\Metrics\Examples\TotalUsers; |
||||
use App\Admin\Renderable\OnLineStepTable; |
||||
use App\Admin\Renderable\UserFamilyInfoTable; |
||||
use App\Admin\Renderable\UserFamilyMeberTable; |
||||
use App\Admin\Renderable\UserFamilyTable; |
||||
use App\Models\AdmissionNewStudents; |
||||
use App\Models\CompletedOfflineStep; |
||||
use App\Models\CompletedStep; |
||||
use App\Models\OfflineStep; |
||||
use App\Models\SecondaryCollege; |
||||
use App\Models\Speciality; |
||||
use App\Models\Step; |
||||
use App\Models\UsersMember; |
||||
use Dcat\Admin\Form; |
||||
use Dcat\Admin\Grid; |
||||
use Dcat\Admin\Layout\Content; |
||||
use Dcat\Admin\Layout\Row; |
||||
use Dcat\Admin\Show; |
||||
use Dcat\Admin\Http\Controllers\AdminController; |
||||
use Dcat\Admin\Widgets\Table; |
||||
use Illuminate\Support\Facades\DB; |
||||
|
||||
class UsersMemberController extends AdminController |
||||
{ |
||||
|
||||
public function index(Content $content) |
||||
{ |
||||
return $content |
||||
->header('学生管理') |
||||
->description('数据统计') |
||||
->body(function (Row $row) { |
||||
$row->column(6, new TotalUsers()); |
||||
$row->column(6, new NewUsers()); |
||||
}) |
||||
->body($this->grid()); |
||||
} |
||||
|
||||
/** |
||||
* Make a grid builder. |
||||
* |
||||
* @return Grid |
||||
*/ |
||||
protected function grid() |
||||
{ |
||||
return Grid::make(new UsersMember(), function (Grid $grid) { |
||||
//开启边框模式 |
||||
$grid->withBorder(); |
||||
// 开启字段选择器功能 |
||||
$grid->showColumnSelector(); |
||||
//开启导出功能 |
||||
$grid->export(new StudentExporter()); |
||||
|
||||
$grid->column('id')->sortable(); |
||||
$grid->column('mobile'); |
||||
$grid->column('unique_number'); |
||||
$grid->column('name'); |
||||
$grid->column('idcard'); |
||||
$grid->column('sex')->display(function () { |
||||
return $this->sex == 0 ? "未知" : ($this->sex == 1 ? "男" : "女"); |
||||
}); |
||||
$grid->column('secondary_college_id')->display(function () { |
||||
$info = Speciality::query()->where("id", $this->speciality_id)->first(); |
||||
if(!empty($info)){ |
||||
$secondaryInfo = SecondaryCollege::query()->where("id", $info->secondary_college_id)->first(); |
||||
if(!empty($secondaryInfo)){ |
||||
return $secondaryInfo->name; |
||||
} |
||||
} |
||||
|
||||
})->help("未显示学院时请检查是否已经分配专业"); |
||||
$grid->column('speciality_id')->display(function () { |
||||
$info = Speciality::where("id", $this->speciality_id)->first(); |
||||
if(!empty($info)){ |
||||
return $info->speciality_name; |
||||
} |
||||
})->help("未显示专业时请检查是否已经分配专业"); |
||||
$grid->column('status')->select([1=>"正常", 2=>"禁用"]); |
||||
$grid->column('is_test')->display(function (){ |
||||
if($this->is_test == UsersMember::IS_TEST_YES){ |
||||
return "是"; |
||||
} |
||||
})->help("为测试账号时则不受系统开放时间限制");; |
||||
|
||||
$grid->column("family_address")->display('家庭住址')->expand( function (){ |
||||
return UserFamilyTable::make()->payload(["unique_number"=>$this->unique_number]); |
||||
}); |
||||
$grid->column("family_member")->display('家庭成员')->expand( function (){ |
||||
return UserFamilyMeberTable::make()->payload(["unique_number"=>$this->unique_number]); |
||||
}); |
||||
$grid->column("step", "步骤一")->display('线上报到进度')->modal( function (){ |
||||
$step = Step::query()->orderBy("sort", "asc")->get()->toArray(); |
||||
$successStep = CompletedStep::query()->where("unique_number", $this->unique_number)->get()->toArray(); |
||||
$tableData = []; |
||||
if(!empty($successStep)){ |
||||
$successStepIds = array_column($successStep, "step_id"); |
||||
foreach($step as $key => $item){ |
||||
if(in_array($item["id"], $successStepIds)){ |
||||
$img = "<img src='/vendor/dcat-admin/images/success.png' width='20' height='20'>"; |
||||
array_push($tableData, $img); |
||||
} |
||||
} |
||||
} |
||||
if(empty($tableData)){ |
||||
$resultData = []; |
||||
}else{ |
||||
$resultData = [$tableData]; |
||||
} |
||||
return Table::make(array_column($step, "title"), $resultData); |
||||
}); |
||||
$grid->column("offlineStep", "步骤二")->display('线下报到进度')->modal( function (){ |
||||
$step = OfflineStep::query()->orderBy("sort", "asc")->get()->toArray(); |
||||
$successStep = CompletedOfflineStep::query()->where("unique_number", $this->unique_number)->get()->toArray(); |
||||
$tableData = []; |
||||
if(!empty($successStep)){ |
||||
$successStepIds = array_column($successStep, "step_id"); |
||||
foreach($step as $key => $item){ |
||||
if(in_array($item["id"], $successStepIds)){ |
||||
$img = "<img src='/vendor/dcat-admin/images/success.png' width='20' height='20'>"; |
||||
array_push($tableData, $img); |
||||
} |
||||
} |
||||
} |
||||
if(empty($tableData)){ |
||||
$resultData = []; |
||||
}else{ |
||||
$resultData = [$tableData]; |
||||
} |
||||
return Table::make(array_column($step, "title"), $resultData); |
||||
}); |
||||
$grid->column('create_time')->display(function (){ |
||||
if(!empty($this->create_time)){ |
||||
return date("Y-m-d H:i:s", $this->create_time); |
||||
} |
||||
})->sortable(); |
||||
$grid->column('update_time')->display(function (){ |
||||
if(!empty($this->update_time)){ |
||||
return date("Y-m-d H:i:s", $this->update_time); |
||||
} |
||||
}); |
||||
|
||||
|
||||
$grid->filter(function (Grid\Filter $filter) { |
||||
$filter->equal('id'); |
||||
$filter->equal('mobile'); |
||||
$filter->equal('name'); |
||||
$filter->equal('idcard'); |
||||
$filter->equal('status')->select([1 => "正常", 2 => "禁用"]); |
||||
$filter->equal('speciality_id')->select(function (){ |
||||
$list = Speciality::query()->where("status", Speciality::STATUS_YES)->get()->toArray(); |
||||
if(empty($list)){ |
||||
return []; |
||||
} |
||||
$select = []; |
||||
foreach($list as $item){ |
||||
$college = SecondaryCollege::query()->where("id", $item["secondary_college_id"])->first(); |
||||
$select[$item["id"]] = $item["speciality_name"]."({$college->name})"; |
||||
} |
||||
|
||||
return $select; |
||||
}); |
||||
$filter->equal('is_test')->select(function (){ |
||||
return [ |
||||
"1" => "否", |
||||
"2" => "是" |
||||
]; |
||||
}); |
||||
|
||||
$filter->between('create_time')->datetime()->toTimestamp(); |
||||
|
||||
}); |
||||
|
||||
|
||||
// 禁用创建按钮 |
||||
$grid->disableCreateButton(); |
||||
// 禁用删除按钮 |
||||
$grid->disableDeleteButton(); |
||||
//禁用批量操作按钮 |
||||
$grid->disableBatchDelete(); |
||||
// 禁用详情按钮 |
||||
$grid->disableViewButton(); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a show builder. |
||||
* |
||||
* @param mixed $id |
||||
* |
||||
* @return Show |
||||
*/ |
||||
protected function detail($id) |
||||
{ |
||||
return Show::make($id, new UsersMember(), function (Show $show) { |
||||
$show->field('id'); |
||||
$show->field('mobile'); |
||||
$show->field('unique_number'); |
||||
$show->field('name'); |
||||
$show->field('sex'); |
||||
$show->field('avatar'); |
||||
$show->field('status'); |
||||
$show->field('create_time'); |
||||
$show->field('update_time'); |
||||
$show->field('idcard'); |
||||
$show->field('speciality_id'); |
||||
$show->field('is_test'); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a form builder. |
||||
* |
||||
* @return Form |
||||
*/ |
||||
protected function form() |
||||
{ |
||||
return Form::make(new UsersMember(), function (Form $form) { |
||||
$form->display('id'); |
||||
$form->text('name')->required(); |
||||
$form->text('mobile')->required(); |
||||
$form->password("password")->required(); |
||||
$form->select('status')->options([1 => '正常', 2 => '禁用'])->required(); |
||||
$form->select("speciality_id", '专业')->options(function () { |
||||
$list = Speciality::query()->where("status", Speciality::STATUS_YES)->get()->toArray(); |
||||
if(empty($list)){ |
||||
return []; |
||||
} |
||||
$select = []; |
||||
foreach($list as $item){ |
||||
$college = SecondaryCollege::query()->where("id", $item["secondary_college_id"])->first(); |
||||
$select[$item["id"]] = $item["speciality_name"]."({$college->name})"; |
||||
} |
||||
|
||||
return $select; |
||||
})->required(); |
||||
$form->select('is_test')->options([1 => '否', 2 => '是'])->required(); |
||||
|
||||
$form->hidden("idcard"); |
||||
$form->hidden("unique_number_bcrypt"); |
||||
$form->hidden("update_time"); |
||||
|
||||
// 去除删除按钮 |
||||
$form->disableDeleteButton(); |
||||
// 去除跳转详情按钮 |
||||
$form->disableViewButton(); |
||||
|
||||
$form->footer(function ($footer) { |
||||
|
||||
// 去掉`查看`checkbox |
||||
$footer->disableViewCheck(); |
||||
|
||||
// 去掉`继续编辑`checkbox |
||||
$footer->disableEditingCheck(); |
||||
|
||||
// 去掉`继续创建`checkbox |
||||
$footer->disableCreatingCheck(); |
||||
|
||||
}); |
||||
|
||||
|
||||
//保存前回调 |
||||
$form->saving(function (Form $form) { |
||||
if (strlen($form->password) < 32) { |
||||
$form->password = bcrypt($form->password); |
||||
} |
||||
$form->update_time = time(); |
||||
$form->unique_number_bcrypt = bcrypt($form->unique_number . $form->mobile); |
||||
}); |
||||
|
||||
//保存后回调 |
||||
$form->saved(function (Form $form) { |
||||
DB::beginTransaction(); |
||||
try { |
||||
//初始化专业名及二级学院名 |
||||
$specialityName = ""; |
||||
$collegeName = ""; |
||||
|
||||
//取出专业信息 |
||||
$specialityInfo = Speciality::query()->where("id", $form->speciality_id)->first(); |
||||
if(!empty($specialityInfo)){ |
||||
$specialityName = $specialityInfo->speciality_name; |
||||
//取出二级学院名称 |
||||
$college = SecondaryCollege::query()->where("id", $specialityInfo->secondary_college_id)->first(); |
||||
if(!empty($college)){ |
||||
$collegeName = $college->name; |
||||
} |
||||
} |
||||
|
||||
//同步修改录取信息列表里的专业 |
||||
$info = AdmissionNewStudents::query()->where("idCard", $form->idcard)->first(); |
||||
if(!empty($info)){ |
||||
$update = AdmissionNewStudents::query()->where("idCard", $form->idcard)->update([ |
||||
"speciality_id" => $form->speciality_id, |
||||
"admission_college" => $collegeName, |
||||
"admitted_major" => $specialityName, |
||||
"is_test" => $form->is_test, |
||||
"update_time" => time(), |
||||
"name" => $form->name, |
||||
]); |
||||
if(empty($update)){ |
||||
// 抛出异常 |
||||
throw new \Exception('修改学生专业出错'); |
||||
} |
||||
} |
||||
DB::commit(); |
||||
}catch (\Exception $e){ |
||||
DB::rollBack(); |
||||
throw new \Exception('修改学生专业出错'); |
||||
} |
||||
|
||||
}); |
||||
}); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,132 @@
@@ -0,0 +1,132 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Controllers; |
||||
|
||||
use App\Admin\Repositories\WechatAppConfig; |
||||
use Dcat\Admin\Form; |
||||
use Dcat\Admin\Grid; |
||||
use Dcat\Admin\Show; |
||||
use Dcat\Admin\Http\Controllers\AdminController; |
||||
|
||||
class WechatAppConfigController extends AdminController |
||||
{ |
||||
/** |
||||
* Make a grid builder. |
||||
* |
||||
* @return Grid |
||||
*/ |
||||
protected function grid() |
||||
{ |
||||
return Grid::make(new WechatAppConfig(), function (Grid $grid) { |
||||
//开启边框模式 |
||||
$grid->withBorder(); |
||||
// 开启字段选择器功能 |
||||
$grid->showColumnSelector(); |
||||
|
||||
$grid->column('id')->sortable(); |
||||
$grid->column('name'); |
||||
$grid->column('miniapp_id'); |
||||
$grid->column('mch_id'); |
||||
$grid->column('key'); |
||||
$grid->column('notify_url'); |
||||
$grid->column('create_time')->display(function (){ |
||||
if(!empty($this->create_time)){ |
||||
return date("Y-m-d H:i:s", $this->create_time); |
||||
} |
||||
})->sortable(); |
||||
|
||||
$grid->filter(function (Grid\Filter $filter) { |
||||
$filter->equal('id'); |
||||
|
||||
}); |
||||
|
||||
// 禁用删除按钮 |
||||
$grid->disableDeleteButton(); |
||||
//禁用批量操作按钮 |
||||
$grid->disableBatchDelete(); |
||||
// 禁用详情按钮 |
||||
$grid->disableViewButton(); |
||||
// 禁用创建按钮 |
||||
$grid->disableCreateButton(); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a show builder. |
||||
* |
||||
* @param mixed $id |
||||
* |
||||
* @return Show |
||||
*/ |
||||
protected function detail($id) |
||||
{ |
||||
return Show::make($id, new WechatAppConfig(), function (Show $show) { |
||||
$show->field('id'); |
||||
$show->field('name'); |
||||
$show->field('app_id'); |
||||
$show->field('miniapp_id'); |
||||
$show->field('appid'); |
||||
$show->field('mch_id'); |
||||
$show->field('key'); |
||||
$show->field('notify_url'); |
||||
$show->field('cert_pem'); |
||||
$show->field('key_pem'); |
||||
$show->field('status'); |
||||
$show->field('create_time'); |
||||
$show->field('update_time'); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a form builder. |
||||
* |
||||
* @return Form |
||||
*/ |
||||
protected function form() |
||||
{ |
||||
return Form::make(new WechatAppConfig(), function (Form $form) { |
||||
$form->display('id'); |
||||
$form->text('name'); |
||||
$form->text('miniapp_id'); |
||||
$form->text('mch_id'); |
||||
$form->text('key'); |
||||
$form->text('notify_url'); |
||||
$form->textarea('cert_pem'); |
||||
$form->textarea('key_pem'); |
||||
|
||||
$form->hidden("create_time"); |
||||
$form->hidden("update_time"); |
||||
|
||||
// 去除删除按钮 |
||||
$form->disableDeleteButton(); |
||||
|
||||
// 去除跳转详情按钮 |
||||
$form->disableViewButton(); |
||||
|
||||
$form->footer(function ($footer) { |
||||
|
||||
// 去掉`查看`checkbox |
||||
$footer->disableViewCheck(); |
||||
|
||||
// 去掉`继续编辑`checkbox |
||||
$footer->disableEditingCheck(); |
||||
|
||||
// 去掉`继续创建`checkbox |
||||
$footer->disableCreatingCheck(); |
||||
|
||||
}); |
||||
|
||||
$form->saving(function (Form $form) { |
||||
|
||||
if ($form->isCreating()) { |
||||
$form->create_time =time(); |
||||
// 删除用户提交的数据 |
||||
$form->deleteInput('update_time'); |
||||
}else{ |
||||
$form->update_time =time(); |
||||
} |
||||
}); |
||||
|
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,126 @@
@@ -0,0 +1,126 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Controllers; |
||||
|
||||
use App\Models\WechatApp; |
||||
use Dcat\Admin\Form; |
||||
use Dcat\Admin\Grid; |
||||
use Dcat\Admin\Show; |
||||
use Dcat\Admin\Http\Controllers\AdminController; |
||||
|
||||
class WechatAppController extends AdminController |
||||
{ |
||||
/** |
||||
* Make a grid builder. |
||||
* |
||||
* @return Grid |
||||
*/ |
||||
protected function grid() |
||||
{ |
||||
return Grid::make(new WechatApp(), function (Grid $grid) { |
||||
//开启边框模式 |
||||
$grid->withBorder(); |
||||
// 开启字段选择器功能 |
||||
$grid->showColumnSelector(); |
||||
|
||||
$grid->column('id')->sortable(); |
||||
$grid->column('name'); |
||||
$grid->column('app_id'); |
||||
$grid->column('app_secret'); |
||||
$grid->column('desc'); |
||||
$grid->column('create_time')->display(function (){ |
||||
if(!empty($this->create_time)){ |
||||
return date("Y-m-d H:i:s", $this->create_time); |
||||
} |
||||
})->sortable(); |
||||
|
||||
$grid->filter(function (Grid\Filter $filter) { |
||||
$filter->equal('id'); |
||||
|
||||
}); |
||||
|
||||
// 禁用删除按钮 |
||||
$grid->disableDeleteButton(); |
||||
//禁用批量操作按钮 |
||||
$grid->disableBatchDelete(); |
||||
// 禁用详情按钮 |
||||
$grid->disableViewButton(); |
||||
// 禁用创建按钮 |
||||
$grid->disableCreateButton(); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a show builder. |
||||
* |
||||
* @param mixed $id |
||||
* |
||||
* @return Show |
||||
*/ |
||||
protected function detail($id) |
||||
{ |
||||
return Show::make($id, new WechatApp(), function (Show $show) { |
||||
$show->field('id'); |
||||
$show->field('name'); |
||||
$show->field('app_id'); |
||||
$show->field('app_secret'); |
||||
$show->field('desc'); |
||||
$show->field('mch_id'); |
||||
$show->field('key'); |
||||
$show->field('cert_pem'); |
||||
$show->field('key_pem'); |
||||
$show->field('create_time'); |
||||
$show->field('is_delete'); |
||||
$show->field('update_time'); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a form builder. |
||||
* |
||||
* @return Form |
||||
*/ |
||||
protected function form() |
||||
{ |
||||
return Form::make(new WechatApp(), function (Form $form) { |
||||
$form->display('id'); |
||||
$form->text('name'); |
||||
$form->text('app_id'); |
||||
$form->text('app_secret'); |
||||
$form->text('desc'); |
||||
|
||||
$form->hidden("create_time"); |
||||
$form->hidden("update_time"); |
||||
|
||||
// 去除删除按钮 |
||||
$form->disableDeleteButton(); |
||||
|
||||
// 去除跳转详情按钮 |
||||
$form->disableViewButton(); |
||||
|
||||
$form->footer(function ($footer) { |
||||
|
||||
// 去掉`查看`checkbox |
||||
$footer->disableViewCheck(); |
||||
|
||||
// 去掉`继续编辑`checkbox |
||||
$footer->disableEditingCheck(); |
||||
|
||||
// 去掉`继续创建`checkbox |
||||
$footer->disableCreatingCheck(); |
||||
|
||||
}); |
||||
|
||||
$form->saving(function (Form $form) { |
||||
|
||||
if ($form->isCreating()) { |
||||
$form->create_time =time(); |
||||
// 删除用户提交的数据 |
||||
$form->deleteInput('update_time'); |
||||
}else{ |
||||
$form->update_time =time(); |
||||
} |
||||
}); |
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,242 @@
@@ -0,0 +1,242 @@
|
||||
<?php |
||||
|
||||
|
||||
namespace App\Admin\Extensions\Exporter; |
||||
|
||||
|
||||
use App\Models\AllocationDormitoryBed; |
||||
use App\Models\Bed; |
||||
use App\Models\Building; |
||||
use App\Models\Config; |
||||
use App\Models\DormitoryNumber; |
||||
use App\Models\DormitoryType; |
||||
use App\Models\Floor; |
||||
use App\Models\LivingArea; |
||||
use App\Models\MultipleWorld; |
||||
use App\Models\SecondaryCollege; |
||||
use App\Models\SelectedDormitory; |
||||
use App\Models\Speciality; |
||||
use App\Models\UsersMember; |
||||
use Dcat\Admin\Grid\Exporters\AbstractExporter; |
||||
use Maatwebsite\Excel\Concerns\Exportable; |
||||
use Maatwebsite\Excel\Concerns\FromCollection; |
||||
use Maatwebsite\Excel\Concerns\WithHeadings; |
||||
use Maatwebsite\Excel\Concerns\WithMapping; |
||||
|
||||
class ImportBedExporter extends AbstractExporter implements WithMapping, WithHeadings, FromCollection |
||||
{ |
||||
use Exportable; |
||||
protected $fileName = '床位信息'; |
||||
protected $titles = []; |
||||
|
||||
public function __construct() |
||||
{ |
||||
$this->fileName = $this->fileName.'_'.time().'.xlsx';//拼接下载文件名称 |
||||
$this->titles = [ |
||||
"id" => "床位ID", |
||||
"sex" => "性别", |
||||
"dormitory_type" => "宿舍类型", |
||||
"multiple_worlds" => "几人间", |
||||
"living_area" => "生活区", |
||||
"building_id" => "楼栋", |
||||
"floor_id" => "楼层", |
||||
"dormitory_number" => "宿舍号", |
||||
"bed_id" => "床号", |
||||
"college" => "二级学院", |
||||
"speciality" => "专业", |
||||
"annual_session" => "年份", |
||||
"status" => "状态", |
||||
"name" => "姓名", |
||||
"mobile" => "手机号", |
||||
"idcard" => "身份证" |
||||
]; |
||||
parent::__construct(); |
||||
} |
||||
|
||||
public function export() |
||||
{ |
||||
// TODO: Implement export() method. |
||||
$this->download($this->fileName)->prepare(request())->send(); |
||||
exit; |
||||
} |
||||
|
||||
public function collection() |
||||
{ |
||||
// TODO: Implement collection() method. |
||||
|
||||
// return collect($this->buildData()); |
||||
|
||||
//取出床位详细信息 |
||||
// $dormitoryBed = AllocationDormitoryBed::query()->where("id", $id)->first(); |
||||
|
||||
//宿舍类型 |
||||
$dormitoryTypeInfo = DormitoryType::query()->get()->toArray(); |
||||
$dormitoryTypeInfo = array_column($dormitoryTypeInfo, null, "id"); |
||||
|
||||
//多人间 |
||||
$multipleInfo = MultipleWorld::query()->get()->toArray(); |
||||
$multipleInfo = array_column($multipleInfo, null, "id"); |
||||
|
||||
//生活区 |
||||
$livingInfo = LivingArea::query()->get()->toArray(); |
||||
$livingInfo = array_column($livingInfo, null, "id"); |
||||
|
||||
//楼栋 |
||||
$buildingInfo = Building::query()->get()->toArray(); |
||||
$buildingInfo = array_column($buildingInfo, null, "id"); |
||||
|
||||
//楼层 |
||||
$floorInfo = Floor::query()->get()->toArray(); |
||||
$floorInfo = array_column($floorInfo, null, "id"); |
||||
|
||||
//宿舍号 |
||||
$dormitory = DormitoryNumber::query()->get()->toArray(); |
||||
$dormitory = array_column($dormitory, null, "id"); |
||||
|
||||
//床位号 |
||||
$bed = Bed::query()->get()->toArray(); |
||||
$bed = array_column($bed, null, "id"); |
||||
|
||||
//取出专业 |
||||
$specialityInfo = Speciality::query()->get()->toArray(); |
||||
$specialityInfo = array_column($specialityInfo, null, "id"); |
||||
|
||||
//取出二级学院 |
||||
$collegeInfo = SecondaryCollege::query()->get()->toArray(); |
||||
$collegeInfo = array_column($collegeInfo, null, "id"); |
||||
|
||||
$config = Config::query()->where([ |
||||
"unique_identification" => "annual_session" |
||||
])->first(); |
||||
|
||||
//取出当前学年所有正常的床位 |
||||
$selectList = SelectedDormitory::query()->where([ |
||||
"status" => SelectedDormitory::STATUS_YES, |
||||
"annual_session" => $config->data, |
||||
])->get()->toArray(); |
||||
|
||||
$selectListIds = []; |
||||
|
||||
if(!empty($selectList)){ |
||||
$selectListIds = array_column($selectList, null, "allocation_dormitory_id"); |
||||
} |
||||
|
||||
$chunk_list = array_chunk($this->buildData(), 1000); |
||||
$newList = []; |
||||
|
||||
foreach($chunk_list as $value){ |
||||
foreach($value as $item){ |
||||
// $bedInfo = SelectedDormitory::getBedInfoByIdNew($item["id"]); |
||||
|
||||
$mobile = ""; |
||||
$name = ""; |
||||
$idcard = ""; |
||||
|
||||
if(!empty($selectListIds)){ |
||||
if(array_key_exists($item["id"], $selectListIds)){ |
||||
$userInfo = UsersMember::query()->where("unique_number", $selectListIds[$item["id"]]["unique_number"])->first(); |
||||
$mobile = $userInfo->mobile; |
||||
$name = $userInfo->name; |
||||
$idcard = $userInfo->idcard; |
||||
} |
||||
} |
||||
|
||||
$data = [ |
||||
"id" => $item["id"], |
||||
"sex" => $item["sex"] == 1 ? "男" : "女", |
||||
"dormitory" => $dormitoryTypeInfo[$item["dormitory_type"]]["dormitory"], |
||||
"multipleInfo" => $multipleInfo[$item["multiple_worlds"]]["people"], |
||||
"livingInfo" => $livingInfo[$item["living_area"]]["title"], |
||||
"buildingInfo" => $buildingInfo[$item["building_id"]]["building_title"], |
||||
"floorInfo" => $floorInfo[$item["floor_id"]]["floor_title"], |
||||
"dormitoryNumber" => $dormitory[$item["dormitory_number"]]["dormitory_number"], |
||||
"bedNumber" => $bed[$item["bed_id"]]["bed_number"], |
||||
"collegeInfo" => $collegeInfo[$specialityInfo[$item["speciality_id"]]["secondary_college_id"]]["name"], |
||||
"specialityName" => $specialityInfo[$item["speciality_id"]]["speciality_name"], |
||||
"mobile" => $mobile, |
||||
"name" => $name, |
||||
"idcard" => $idcard, |
||||
"status" => $item['status'] == 1 ? "正常" : "禁用", |
||||
"annual_session" => $item["annual_session"], |
||||
]; |
||||
|
||||
array_push($newList, $data); |
||||
} |
||||
} |
||||
|
||||
return collect($newList); |
||||
} |
||||
|
||||
public function headings(): array |
||||
{ |
||||
// TODO: Implement headings() method. |
||||
return $this->titles(); |
||||
} |
||||
|
||||
public function mapOld($row): array |
||||
{ |
||||
|
||||
$bedInfo = SelectedDormitory::getBedInfoByIdNew($row["id"]); |
||||
|
||||
$status = $row['status'] == 1 ? "正常" : "禁用"; |
||||
|
||||
$mobile = ""; |
||||
$name = ""; |
||||
$idcard = ""; |
||||
|
||||
//检测该床位是否被选,被选则取出用户信息 |
||||
$selectInfo = SelectedDormitory::query()->where([ |
||||
"allocation_dormitory_id" => $row["id"], |
||||
"annual_session" => $row["annual_session"], |
||||
"status" => SelectedDormitory::STATUS_YES |
||||
])->first(); |
||||
if(!empty($selectInfo)){ |
||||
$userInfo = UsersMember::query()->where("unique_number", $selectInfo["unique_number"])->first(); |
||||
$mobile = $userInfo->mobile; |
||||
$name = $userInfo->name; |
||||
$idcard = $userInfo->idcard; |
||||
} |
||||
// TODO: Implement map() method. |
||||
return [ |
||||
$row['id'], |
||||
$bedInfo["sex"], |
||||
$bedInfo["dormitory"], |
||||
$bedInfo["multipleInfo"], |
||||
$bedInfo["livingInfo"], |
||||
$bedInfo["buildingInfo"], |
||||
$bedInfo["floorInfo"], |
||||
$bedInfo["dormitoryNumber"], |
||||
$bedInfo["bedNumber"], |
||||
$bedInfo["collegeInfo"], |
||||
$bedInfo["specialityName"], |
||||
$row['annual_session'], |
||||
$status, |
||||
$name, |
||||
$mobile, |
||||
"'".$idcard, |
||||
]; |
||||
} |
||||
|
||||
public function map($row): array |
||||
{ |
||||
// TODO: Implement map() method. |
||||
return [ |
||||
$row['id'], |
||||
$row["sex"], |
||||
$row["dormitory"], |
||||
$row["multipleInfo"], |
||||
$row["livingInfo"], |
||||
$row["buildingInfo"], |
||||
$row["floorInfo"], |
||||
$row["dormitoryNumber"], |
||||
$row["bedNumber"], |
||||
$row["collegeInfo"], |
||||
$row["specialityName"], |
||||
$row['annual_session'], |
||||
$row["status"], |
||||
$row["name"], |
||||
$row["mobile"], |
||||
"'".$row["idcard"], |
||||
]; |
||||
} |
||||
} |
@ -0,0 +1,149 @@
@@ -0,0 +1,149 @@
|
||||
<?php |
||||
|
||||
|
||||
namespace App\Admin\Extensions\Exporter; |
||||
|
||||
|
||||
use App\Models\CompletedOfflineStep; |
||||
use App\Models\Speciality; |
||||
use App\Models\UsersMember; |
||||
use Dcat\Admin\Grid\Exporters\AbstractExporter; |
||||
use Maatwebsite\Excel\Concerns\Exportable; |
||||
use Maatwebsite\Excel\Concerns\FromCollection; |
||||
use Maatwebsite\Excel\Concerns\WithHeadings; |
||||
use Maatwebsite\Excel\Concerns\WithMapping; |
||||
|
||||
class ImportStudentExporter extends AbstractExporter implements WithMapping, WithHeadings, FromCollection |
||||
{ |
||||
use Exportable; |
||||
protected $fileName = '导入学生名单'; |
||||
protected $titles = []; |
||||
|
||||
public function __construct() |
||||
{ |
||||
$this->fileName = $this->fileName.'_'.time().'.xlsx';//拼接下载文件名称 |
||||
$this->titles = [ |
||||
'mobile' => '手机号' , |
||||
'name'=>'姓名', |
||||
'idCard'=>'身份证', |
||||
'sex' => "性别", |
||||
"admission_code" => "录取编码", |
||||
"admission_college" => "二级学院", |
||||
"admitted_major" => "录取专业", |
||||
"resuming_school" => "复学类型", |
||||
"annual_session" => "年份", |
||||
"create_time" => "导入时间", |
||||
"zhaoshengban" => "招生办报到", |
||||
"erjixueyuan" => "二级学院报到", |
||||
"suguan" => "宿管办报到", |
||||
"is_test" => "测试账号" |
||||
]; |
||||
parent::__construct(); |
||||
} |
||||
|
||||
public function export() |
||||
{ |
||||
// TODO: Implement export() method. |
||||
$this->download($this->fileName)->prepare(request())->send(); |
||||
exit; |
||||
} |
||||
|
||||
public function collection() |
||||
{ |
||||
// TODO: Implement collection() method. |
||||
|
||||
// return collect($this->buildData()); |
||||
$chunk_list = array_chunk($this->buildData(), 1000); |
||||
$newList = []; |
||||
|
||||
$userList = UsersMember::query()->get()->toArray(); |
||||
$userList = array_column($userList, null, "idcard"); |
||||
|
||||
foreach($chunk_list as $value){ |
||||
foreach ($value as $item){ |
||||
$resuming_school = "普通学生"; |
||||
if($item["resuming_school"] == 1) $resuming_school = "退伍复学"; |
||||
if($item["resuming_school"] == 2) $resuming_school = "普通复学"; |
||||
$is_test = "否"; |
||||
if($item["is_test"] == 2) $is_test = "是"; |
||||
|
||||
$zhaoshengban = "否"; |
||||
$erjixueyuan = "否"; |
||||
$suguan = "否"; |
||||
|
||||
if(array_key_exists($item["idCard"], $userList)){ |
||||
$step = CompletedOfflineStep::query()->where("unique_number", $userList[$item["idCard"]]["unique_number"])->get()->toArray(); |
||||
if(!empty($step)){ |
||||
$step = array_column($step, null, "step_id"); |
||||
if(array_key_exists(2, $step)) $zhaoshengban = "是"; |
||||
if(array_key_exists(3, $step)) $erjixueyuan = "是"; |
||||
if(array_key_exists(4, $step)) $suguan = "是"; |
||||
} |
||||
} |
||||
|
||||
$arr = [ |
||||
"sex" => $item['sex'] == 1 ? "男" : "女", |
||||
"resuming_school" => $resuming_school, |
||||
"is_test" => $is_test, |
||||
"zhaoshengban" => $zhaoshengban, |
||||
"erjixueyuan" => $erjixueyuan, |
||||
"suguan" => $suguan, |
||||
"mobile" => $item["mobile"], |
||||
"name" => $item["name"], |
||||
"idCard" => $item["idCard"], |
||||
"admission_code" => $item["admission_code"], |
||||
"admission_college" => $item["admission_college"], |
||||
"admitted_major" => $item["admitted_major"], |
||||
"annual_session" => $item["annual_session"], |
||||
"create_time" => date("Y-m-d H:i:s", $item['create_time']), |
||||
]; |
||||
array_push($newList, $arr); |
||||
} |
||||
} |
||||
|
||||
return collect($newList); |
||||
} |
||||
|
||||
public function headings(): array |
||||
{ |
||||
// TODO: Implement headings() method. |
||||
return $this->titles(); |
||||
} |
||||
|
||||
public function map($row): array |
||||
{ |
||||
|
||||
// TODO: Implement map() method. |
||||
return [ |
||||
$row['mobile'], |
||||
$row['name'], |
||||
"'".$row['idCard'].'', |
||||
$row['sex'], |
||||
$row['admission_code'], |
||||
$row['admission_college'], |
||||
$row['admitted_major'], |
||||
$row['resuming_school'], |
||||
$row['annual_session'], |
||||
$row['create_time'], |
||||
$row["zhaoshengban"], |
||||
$row["erjixueyuan"], |
||||
$row["suguan"], |
||||
$row["is_test"], |
||||
]; |
||||
} |
||||
|
||||
public function getSpecialityAndCollegeNameById($id) |
||||
{ |
||||
$nameInfo = Speciality::query()->where("speciality.id", $id)->leftJoin("secondary_college as b", "speciality.secondary_college_id", "=", "b.id")->first(); |
||||
|
||||
if(empty($nameInfo)){ |
||||
return [ |
||||
"name" => "", |
||||
"speciality_name" => "" |
||||
]; |
||||
} |
||||
|
||||
return $nameInfo->toArray(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,90 @@
@@ -0,0 +1,90 @@
|
||||
<?php |
||||
|
||||
|
||||
namespace App\Admin\Extensions\Exporter; |
||||
|
||||
|
||||
use App\Models\Speciality; |
||||
use Dcat\Admin\Grid\Exporters\AbstractExporter; |
||||
use Maatwebsite\Excel\Concerns\Exportable; |
||||
use Maatwebsite\Excel\Concerns\FromCollection; |
||||
use Maatwebsite\Excel\Concerns\WithHeadings; |
||||
use Maatwebsite\Excel\Concerns\WithMapping; |
||||
|
||||
class StudentExporter extends AbstractExporter implements WithMapping, WithHeadings, FromCollection |
||||
{ |
||||
use Exportable; |
||||
protected $fileName = '注册用户'; |
||||
protected $titles = []; |
||||
|
||||
public function __construct() |
||||
{ |
||||
$this->fileName = $this->fileName.'_'.time().'.xlsx';//拼接下载文件名称 |
||||
$this->titles = [ |
||||
'mobile' => '手机号' , |
||||
'name'=>'姓名', |
||||
'idcard'=>'身份证', |
||||
'sex' => "性别", |
||||
"college" => "二级学院", |
||||
"speciality" => "专业", |
||||
"create_time" => "注册时间", |
||||
"is_test" => "是否为测试号" |
||||
]; |
||||
parent::__construct(); |
||||
} |
||||
|
||||
public function export() |
||||
{ |
||||
// TODO: Implement export() method. |
||||
$this->download($this->fileName)->prepare(request())->send(); |
||||
exit; |
||||
} |
||||
|
||||
public function collection() |
||||
{ |
||||
// TODO: Implement collection() method. |
||||
|
||||
return collect($this->buildData()); |
||||
} |
||||
|
||||
public function headings(): array |
||||
{ |
||||
// TODO: Implement headings() method. |
||||
return $this->titles(); |
||||
} |
||||
|
||||
public function map($row): array |
||||
{ |
||||
|
||||
$nameInfo = $this->getSpecialityAndCollegeNameById($row["speciality_id"]); |
||||
|
||||
$sex = $row['sex'] == 1 ? "男" : "女"; |
||||
$test = $row['is_test'] == 1 ? "否" : "是"; |
||||
// TODO: Implement map() method. |
||||
return [ |
||||
$row['mobile'], |
||||
$row['name'], |
||||
"'".$row['idcard'].'', |
||||
$sex, |
||||
$nameInfo["name"], |
||||
$nameInfo["speciality_name"], |
||||
date("Y-m-d H:i:s", $row['create_time']), |
||||
$test |
||||
]; |
||||
} |
||||
|
||||
public function getSpecialityAndCollegeNameById($id) |
||||
{ |
||||
$nameInfo = Speciality::query()->where("speciality.id", $id)->leftJoin("secondary_college as b", "speciality.secondary_college_id", "=", "b.id")->first(); |
||||
|
||||
if(empty($nameInfo)){ |
||||
return [ |
||||
"name" => "", |
||||
"speciality_name" => "" |
||||
]; |
||||
} |
||||
|
||||
return $nameInfo->toArray(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,127 @@
@@ -0,0 +1,127 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Metrics\Examples; |
||||
|
||||
use App\Models\AdmissionNewStudents; |
||||
use App\Models\Config; |
||||
use Dcat\Admin\Widgets\Metrics\Card; |
||||
use Illuminate\Contracts\Support\Renderable; |
||||
use Illuminate\Http\Request; |
||||
|
||||
class AdmissionExcelUsers extends Card |
||||
{ |
||||
/** |
||||
* 卡片底部内容. |
||||
* |
||||
* @var string|Renderable|\Closure |
||||
*/ |
||||
protected $footer; |
||||
|
||||
/** |
||||
* 初始化卡片. |
||||
*/ |
||||
protected function init() |
||||
{ |
||||
parent::init(); |
||||
|
||||
$this->title('导入人数'); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 处理请求. |
||||
* |
||||
* @param Request $request |
||||
* |
||||
* @return void |
||||
*/ |
||||
public function handle(Request $request) |
||||
{ |
||||
|
||||
//取出当前年份 |
||||
$config = Config::query()->where([ |
||||
"unique_identification" => "annual_session" |
||||
])->first(); |
||||
|
||||
//注册总人数 |
||||
$allCount = AdmissionNewStudents::query()->where([ |
||||
"annual_session" => $config->data, |
||||
])->count(); |
||||
|
||||
$this->content($allCount); |
||||
|
||||
if($allCount > 0){ |
||||
$this->up($allCount); |
||||
}else{ |
||||
$this->down($allCount); |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* @param int $percent |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function up($percent) |
||||
{ |
||||
return $this->footer( |
||||
"<i class=\"feather icon-trending-up text-success\"></i> {$percent}人 为当前年份已导入人数" |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* @param int $percent |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function down($percent) |
||||
{ |
||||
return $this->footer( |
||||
"<i class=\"feather icon-trending-down text-danger\"></i> {$percent}人 为当前年份已导入人数" |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* 设置卡片底部内容. |
||||
* |
||||
* @param string|Renderable|\Closure $footer |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function footer($footer) |
||||
{ |
||||
$this->footer = $footer; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* 渲染卡片内容. |
||||
* |
||||
* @return string |
||||
*/ |
||||
public function renderContent() |
||||
{ |
||||
$content = parent::renderContent(); |
||||
|
||||
return <<<HTML |
||||
<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px"> |
||||
<h2 class="ml-1 font-lg-1">{$content}</h2> |
||||
</div> |
||||
<div class="ml-1 mt-1 font-weight-bold text-80"> |
||||
{$this->renderFooter()} |
||||
</div> |
||||
HTML; |
||||
} |
||||
|
||||
/** |
||||
* 渲染卡片底部内容. |
||||
* |
||||
* @return string |
||||
*/ |
||||
public function renderFooter() |
||||
{ |
||||
return $this->toString($this->footer); |
||||
} |
||||
} |
@ -0,0 +1,130 @@
@@ -0,0 +1,130 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Metrics\Examples; |
||||
|
||||
use App\Models\AdmissionNewStudents; |
||||
use App\Models\Config; |
||||
use App\Models\Order; |
||||
use Dcat\Admin\Widgets\Metrics\Card; |
||||
use Illuminate\Contracts\Support\Renderable; |
||||
use Illuminate\Http\Request; |
||||
|
||||
class AdmissionPayUsers extends Card |
||||
{ |
||||
/** |
||||
* 卡片底部内容. |
||||
* |
||||
* @var string|Renderable|\Closure |
||||
*/ |
||||
protected $footer; |
||||
|
||||
/** |
||||
* 初始化卡片. |
||||
*/ |
||||
protected function init() |
||||
{ |
||||
parent::init(); |
||||
|
||||
$this->title('缴费人数'); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 处理请求. |
||||
* |
||||
* @param Request $request |
||||
* |
||||
* @return void |
||||
*/ |
||||
public function handle(Request $request) |
||||
{ |
||||
|
||||
//取出当前年份 |
||||
$config = Config::query()->where([ |
||||
"unique_identification" => "annual_session" |
||||
])->first(); |
||||
|
||||
//缴费总人数 |
||||
$allCount = Order::query() |
||||
->where([ |
||||
"annual_session" => $config->data, |
||||
"status" => Order::STATUS_PAID, |
||||
])->distinct("unique_number")->count(); |
||||
|
||||
$this->content($allCount); |
||||
|
||||
if($allCount > 0){ |
||||
$this->up($allCount); |
||||
}else{ |
||||
$this->down($allCount); |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* @param int $percent |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function up($percent) |
||||
{ |
||||
return $this->footer( |
||||
"<i class=\"feather icon-trending-up text-success\"></i> {$percent}人 为当前年份已缴费人数" |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* @param int $percent |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function down($percent) |
||||
{ |
||||
return $this->footer( |
||||
"<i class=\"feather icon-trending-down text-danger\"></i> {$percent}人 为当前年份已缴费人数" |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* 设置卡片底部内容. |
||||
* |
||||
* @param string|Renderable|\Closure $footer |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function footer($footer) |
||||
{ |
||||
$this->footer = $footer; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* 渲染卡片内容. |
||||
* |
||||
* @return string |
||||
*/ |
||||
public function renderContent() |
||||
{ |
||||
$content = parent::renderContent(); |
||||
|
||||
return <<<HTML |
||||
<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px"> |
||||
<h2 class="ml-1 font-lg-1">{$content}</h2> |
||||
</div> |
||||
<div class="ml-1 mt-1 font-weight-bold text-80"> |
||||
{$this->renderFooter()} |
||||
</div> |
||||
HTML; |
||||
} |
||||
|
||||
/** |
||||
* 渲染卡片底部内容. |
||||
* |
||||
* @return string |
||||
*/ |
||||
public function renderFooter() |
||||
{ |
||||
return $this->toString($this->footer); |
||||
} |
||||
} |
@ -0,0 +1,128 @@
@@ -0,0 +1,128 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Metrics\Examples; |
||||
|
||||
use App\Models\AdmissionNewStudents; |
||||
use App\Models\Config; |
||||
use Dcat\Admin\Widgets\Metrics\Card; |
||||
use Illuminate\Contracts\Support\Renderable; |
||||
use Illuminate\Http\Request; |
||||
|
||||
class AdmissionRegisterUsers extends Card |
||||
{ |
||||
/** |
||||
* 卡片底部内容. |
||||
* |
||||
* @var string|Renderable|\Closure |
||||
*/ |
||||
protected $footer; |
||||
|
||||
/** |
||||
* 初始化卡片. |
||||
*/ |
||||
protected function init() |
||||
{ |
||||
parent::init(); |
||||
|
||||
$this->title('注册人数'); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 处理请求. |
||||
* |
||||
* @param Request $request |
||||
* |
||||
* @return void |
||||
*/ |
||||
public function handle(Request $request) |
||||
{ |
||||
|
||||
//取出当前年份 |
||||
$config = Config::query()->where([ |
||||
"unique_identification" => "annual_session" |
||||
])->first(); |
||||
|
||||
//注册总人数 |
||||
$allCount = AdmissionNewStudents::query()->where([ |
||||
"annual_session" => $config->data, |
||||
"is_register" => AdmissionNewStudents::REGISTER_YES, |
||||
])->count(); |
||||
|
||||
$this->content($allCount); |
||||
|
||||
if($allCount > 0){ |
||||
$this->up($allCount); |
||||
}else{ |
||||
$this->down($allCount); |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* @param int $percent |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function up($percent) |
||||
{ |
||||
return $this->footer( |
||||
"<i class=\"feather icon-trending-up text-success\"></i> {$percent}人 为当前年份已注册人数" |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* @param int $percent |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function down($percent) |
||||
{ |
||||
return $this->footer( |
||||
"<i class=\"feather icon-trending-down text-danger\"></i> {$percent}人 为当前年份已注册人数" |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* 设置卡片底部内容. |
||||
* |
||||
* @param string|Renderable|\Closure $footer |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function footer($footer) |
||||
{ |
||||
$this->footer = $footer; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* 渲染卡片内容. |
||||
* |
||||
* @return string |
||||
*/ |
||||
public function renderContent() |
||||
{ |
||||
$content = parent::renderContent(); |
||||
|
||||
return <<<HTML |
||||
<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px"> |
||||
<h2 class="ml-1 font-lg-1">{$content}</h2> |
||||
</div> |
||||
<div class="ml-1 mt-1 font-weight-bold text-80"> |
||||
{$this->renderFooter()} |
||||
</div> |
||||
HTML; |
||||
} |
||||
|
||||
/** |
||||
* 渲染卡片底部内容. |
||||
* |
||||
* @return string |
||||
*/ |
||||
public function renderFooter() |
||||
{ |
||||
return $this->toString($this->footer); |
||||
} |
||||
} |
@ -0,0 +1,128 @@
@@ -0,0 +1,128 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Metrics\Examples; |
||||
|
||||
use App\Models\AdmissionNewStudents; |
||||
use App\Models\CompletedOfflineStep; |
||||
use App\Models\Config; |
||||
use App\Models\Order; |
||||
use Dcat\Admin\Widgets\Metrics\Card; |
||||
use Illuminate\Contracts\Support\Renderable; |
||||
use Illuminate\Http\Request; |
||||
|
||||
class AdmissionStepUsers extends Card |
||||
{ |
||||
/** |
||||
* 卡片底部内容. |
||||
* |
||||
* @var string|Renderable|\Closure |
||||
*/ |
||||
protected $footer; |
||||
|
||||
/** |
||||
* 初始化卡片. |
||||
*/ |
||||
protected function init() |
||||
{ |
||||
parent::init(); |
||||
|
||||
$this->title('报到人数'); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 处理请求. |
||||
* |
||||
* @param Request $request |
||||
* |
||||
* @return void |
||||
*/ |
||||
public function handle(Request $request) |
||||
{ |
||||
|
||||
//取出当前年份 |
||||
/*$config = Config::query()->where([ |
||||
"unique_identification" => "annual_session" |
||||
])->first();*/ |
||||
|
||||
//报到总人数 |
||||
$allCount = CompletedOfflineStep::query() |
||||
->distinct("unique_number")->count(); |
||||
|
||||
$this->content($allCount); |
||||
|
||||
if($allCount > 0){ |
||||
$this->up($allCount); |
||||
}else{ |
||||
$this->down($allCount); |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* @param int $percent |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function up($percent) |
||||
{ |
||||
return $this->footer( |
||||
"<i class=\"feather icon-trending-up text-success\"></i> {$percent}人 为当前年份已报到人数" |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* @param int $percent |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function down($percent) |
||||
{ |
||||
return $this->footer( |
||||
"<i class=\"feather icon-trending-down text-danger\"></i> {$percent}人 为当前年份已报到人数" |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* 设置卡片底部内容. |
||||
* |
||||
* @param string|Renderable|\Closure $footer |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function footer($footer) |
||||
{ |
||||
$this->footer = $footer; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* 渲染卡片内容. |
||||
* |
||||
* @return string |
||||
*/ |
||||
public function renderContent() |
||||
{ |
||||
$content = parent::renderContent(); |
||||
|
||||
return <<<HTML |
||||
<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px"> |
||||
<h2 class="ml-1 font-lg-1">{$content}</h2> |
||||
</div> |
||||
<div class="ml-1 mt-1 font-weight-bold text-80"> |
||||
{$this->renderFooter()} |
||||
</div> |
||||
HTML; |
||||
} |
||||
|
||||
/** |
||||
* 渲染卡片底部内容. |
||||
* |
||||
* @return string |
||||
*/ |
||||
public function renderFooter() |
||||
{ |
||||
return $this->toString($this->footer); |
||||
} |
||||
} |
@ -0,0 +1,129 @@
@@ -0,0 +1,129 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Metrics\Examples; |
||||
|
||||
use App\Models\AdmissionNewStudents; |
||||
use App\Models\AllocationDormitoryBed; |
||||
use App\Models\Config; |
||||
use Dcat\Admin\Widgets\Metrics\Card; |
||||
use Illuminate\Contracts\Support\Renderable; |
||||
use Illuminate\Http\Request; |
||||
|
||||
class AllocationExcelBed extends Card |
||||
{ |
||||
/** |
||||
* 卡片底部内容. |
||||
* |
||||
* @var string|Renderable|\Closure |
||||
*/ |
||||
protected $footer; |
||||
|
||||
/** |
||||
* 初始化卡片. |
||||
*/ |
||||
protected function init() |
||||
{ |
||||
parent::init(); |
||||
|
||||
$this->title('导入床位数'); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 处理请求. |
||||
* |
||||
* @param Request $request |
||||
* |
||||
* @return void |
||||
*/ |
||||
public function handle(Request $request) |
||||
{ |
||||
|
||||
//取出当前年份 |
||||
$config = Config::query()->where([ |
||||
"unique_identification" => "annual_session" |
||||
])->first(); |
||||
|
||||
//注册总人数 |
||||
$allCount = AllocationDormitoryBed::query()->where([ |
||||
"annual_session" => $config->data, |
||||
"status" => AllocationDormitoryBed::STATUS_YES |
||||
])->count(); |
||||
|
||||
$this->content($allCount); |
||||
|
||||
if($allCount > 0){ |
||||
$this->up($allCount); |
||||
}else{ |
||||
$this->down($allCount); |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* @param int $percent |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function up($percent) |
||||
{ |
||||
return $this->footer( |
||||
"<i class=\"feather icon-trending-up text-success\"></i> {$percent}个 为当前年份已导入床位数(不包含禁用床位)" |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* @param int $percent |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function down($percent) |
||||
{ |
||||
return $this->footer( |
||||
"<i class=\"feather icon-trending-down text-danger\"></i> {$percent}个 为当前年份已导入床位数(不包含禁用床位)" |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* 设置卡片底部内容. |
||||
* |
||||
* @param string|Renderable|\Closure $footer |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function footer($footer) |
||||
{ |
||||
$this->footer = $footer; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* 渲染卡片内容. |
||||
* |
||||
* @return string |
||||
*/ |
||||
public function renderContent() |
||||
{ |
||||
$content = parent::renderContent(); |
||||
|
||||
return <<<HTML |
||||
<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px"> |
||||
<h2 class="ml-1 font-lg-1">{$content}</h2> |
||||
</div> |
||||
<div class="ml-1 mt-1 font-weight-bold text-80"> |
||||
{$this->renderFooter()} |
||||
</div> |
||||
HTML; |
||||
} |
||||
|
||||
/** |
||||
* 渲染卡片底部内容. |
||||
* |
||||
* @return string |
||||
*/ |
||||
public function renderFooter() |
||||
{ |
||||
return $this->toString($this->footer); |
||||
} |
||||
} |
@ -0,0 +1,140 @@
@@ -0,0 +1,140 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Metrics\Examples; |
||||
|
||||
use App\Models\AdmissionNewStudents; |
||||
use App\Models\AllocationDormitoryBed; |
||||
use App\Models\Config; |
||||
use App\Models\SelectedDormitory; |
||||
use Dcat\Admin\Widgets\Metrics\Card; |
||||
use Illuminate\Contracts\Support\Renderable; |
||||
use Illuminate\Http\Request; |
||||
|
||||
class AllocationExcelBedNotSelect extends Card |
||||
{ |
||||
/** |
||||
* 卡片底部内容. |
||||
* |
||||
* @var string|Renderable|\Closure |
||||
*/ |
||||
protected $footer; |
||||
|
||||
/** |
||||
* 初始化卡片. |
||||
*/ |
||||
protected function init() |
||||
{ |
||||
parent::init(); |
||||
|
||||
$this->title('待分配床位数'); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 处理请求. |
||||
* |
||||
* @param Request $request |
||||
* |
||||
* @return void |
||||
*/ |
||||
public function handle(Request $request) |
||||
{ |
||||
|
||||
//取出当前年份 |
||||
$config = Config::query()->where([ |
||||
"unique_identification" => "annual_session" |
||||
])->first(); |
||||
|
||||
//注册总人数 |
||||
$allCount = SelectedDormitory::query()->where([ |
||||
"annual_session" => $config->data, |
||||
"status" => SelectedDormitory::STATUS_YES |
||||
])->get()->toArray(); |
||||
|
||||
$ids = []; |
||||
if(!empty($allCount)){ |
||||
$ids = array_column($allCount, "allocation_dormitory_id"); |
||||
} |
||||
|
||||
$allCount = AllocationDormitoryBed::query()->where([ |
||||
"annual_session" => $config->data, |
||||
"status" => AllocationDormitoryBed::STATUS_YES |
||||
])->whereNotIn("id", $ids)->count(); |
||||
|
||||
$this->content($allCount); |
||||
|
||||
if($allCount > 0){ |
||||
$this->up($allCount); |
||||
}else{ |
||||
$this->down($allCount); |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* @param int $percent |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function up($percent) |
||||
{ |
||||
return $this->footer( |
||||
"<i class=\"feather icon-trending-up text-success\"></i> {$percent}个 为当前年份待分配床位数" |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* @param int $percent |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function down($percent) |
||||
{ |
||||
return $this->footer( |
||||
"<i class=\"feather icon-trending-down text-danger\"></i> {$percent}个 为当前年份待分配床位数" |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* 设置卡片底部内容. |
||||
* |
||||
* @param string|Renderable|\Closure $footer |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function footer($footer) |
||||
{ |
||||
$this->footer = $footer; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* 渲染卡片内容. |
||||
* |
||||
* @return string |
||||
*/ |
||||
public function renderContent() |
||||
{ |
||||
$content = parent::renderContent(); |
||||
|
||||
return <<<HTML |
||||
<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px"> |
||||
<h2 class="ml-1 font-lg-1">{$content}</h2> |
||||
</div> |
||||
<div class="ml-1 mt-1 font-weight-bold text-80"> |
||||
{$this->renderFooter()} |
||||
</div> |
||||
HTML; |
||||
} |
||||
|
||||
/** |
||||
* 渲染卡片底部内容. |
||||
* |
||||
* @return string |
||||
*/ |
||||
public function renderFooter() |
||||
{ |
||||
return $this->toString($this->footer); |
||||
} |
||||
} |
@ -0,0 +1,130 @@
@@ -0,0 +1,130 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Metrics\Examples; |
||||
|
||||
use App\Models\AdmissionNewStudents; |
||||
use App\Models\AllocationDormitoryBed; |
||||
use App\Models\Config; |
||||
use App\Models\SelectedDormitory; |
||||
use Dcat\Admin\Widgets\Metrics\Card; |
||||
use Illuminate\Contracts\Support\Renderable; |
||||
use Illuminate\Http\Request; |
||||
|
||||
class AllocationExcelBedSelect extends Card |
||||
{ |
||||
/** |
||||
* 卡片底部内容. |
||||
* |
||||
* @var string|Renderable|\Closure |
||||
*/ |
||||
protected $footer; |
||||
|
||||
/** |
||||
* 初始化卡片. |
||||
*/ |
||||
protected function init() |
||||
{ |
||||
parent::init(); |
||||
|
||||
$this->title('已分配床位数'); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 处理请求. |
||||
* |
||||
* @param Request $request |
||||
* |
||||
* @return void |
||||
*/ |
||||
public function handle(Request $request) |
||||
{ |
||||
|
||||
//取出当前年份 |
||||
$config = Config::query()->where([ |
||||
"unique_identification" => "annual_session" |
||||
])->first(); |
||||
|
||||
//注册总人数 |
||||
$allCount = SelectedDormitory::query()->where([ |
||||
"annual_session" => $config->data, |
||||
"status" => SelectedDormitory::STATUS_YES |
||||
])->count(); |
||||
|
||||
$this->content($allCount); |
||||
|
||||
if($allCount > 0){ |
||||
$this->up($allCount); |
||||
}else{ |
||||
$this->down($allCount); |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* @param int $percent |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function up($percent) |
||||
{ |
||||
return $this->footer( |
||||
"<i class=\"feather icon-trending-up text-success\"></i> {$percent}个 为当前年份已分配床位数" |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* @param int $percent |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function down($percent) |
||||
{ |
||||
return $this->footer( |
||||
"<i class=\"feather icon-trending-down text-danger\"></i> {$percent}个 为当前年份已分配床位数" |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* 设置卡片底部内容. |
||||
* |
||||
* @param string|Renderable|\Closure $footer |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function footer($footer) |
||||
{ |
||||
$this->footer = $footer; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* 渲染卡片内容. |
||||
* |
||||
* @return string |
||||
*/ |
||||
public function renderContent() |
||||
{ |
||||
$content = parent::renderContent(); |
||||
|
||||
return <<<HTML |
||||
<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px"> |
||||
<h2 class="ml-1 font-lg-1">{$content}</h2> |
||||
</div> |
||||
<div class="ml-1 mt-1 font-weight-bold text-80"> |
||||
{$this->renderFooter()} |
||||
</div> |
||||
HTML; |
||||
} |
||||
|
||||
/** |
||||
* 渲染卡片底部内容. |
||||
* |
||||
* @return string |
||||
*/ |
||||
public function renderFooter() |
||||
{ |
||||
return $this->toString($this->footer); |
||||
} |
||||
} |
@ -0,0 +1,100 @@
@@ -0,0 +1,100 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Metrics\Examples; |
||||
|
||||
use Dcat\Admin\Admin; |
||||
use Dcat\Admin\Widgets\Metrics\Donut; |
||||
|
||||
class NewDevices extends Donut |
||||
{ |
||||
protected $labels = ['Desktop', 'Mobile']; |
||||
|
||||
/** |
||||
* 初始化卡片内容 |
||||
*/ |
||||
protected function init() |
||||
{ |
||||
parent::init(); |
||||
|
||||
$color = Admin::color(); |
||||
$colors = [$color->primary(), $color->alpha('blue2', 0.5)]; |
||||
|
||||
$this->title('New Devices'); |
||||
$this->subTitle('Last 30 days'); |
||||
$this->chartLabels($this->labels); |
||||
// 设置图表颜色 |
||||
$this->chartColors($colors); |
||||
} |
||||
|
||||
/** |
||||
* 渲染模板 |
||||
* |
||||
* @return string |
||||
*/ |
||||
public function render() |
||||
{ |
||||
$this->fill(); |
||||
|
||||
return parent::render(); |
||||
} |
||||
|
||||
/** |
||||
* 写入数据. |
||||
* |
||||
* @return void |
||||
*/ |
||||
public function fill() |
||||
{ |
||||
$this->withContent(44.9, 28.6); |
||||
|
||||
// 图表数据 |
||||
$this->withChart([44.9, 28.6]); |
||||
} |
||||
|
||||
/** |
||||
* 设置图表数据. |
||||
* |
||||
* @param array $data |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function withChart(array $data) |
||||
{ |
||||
return $this->chart([ |
||||
'series' => $data |
||||
]); |
||||
} |
||||
|
||||
/** |
||||
* 设置卡片头部内容. |
||||
* |
||||
* @param mixed $desktop |
||||
* @param mixed $mobile |
||||
* |
||||
* @return $this |
||||
*/ |
||||
protected function withContent($desktop, $mobile) |
||||
{ |
||||
$blue = Admin::color()->alpha('blue2', 0.5); |
||||
|
||||
$style = 'margin-bottom: 8px'; |
||||
$labelWidth = 120; |
||||
|
||||
return $this->content( |
||||
<<<HTML |
||||
<div class="d-flex pl-1 pr-1 pt-1" style="{$style}"> |
||||
<div style="width: {$labelWidth}px"> |
||||
<i class="fa fa-circle text-primary"></i> {$this->labels[0]} |
||||
</div> |
||||
<div>{$desktop}</div> |
||||
</div> |
||||
<div class="d-flex pl-1 pr-1" style="{$style}"> |
||||
<div style="width: {$labelWidth}px"> |
||||
<i class="fa fa-circle" style="color: $blue"></i> {$this->labels[1]} |
||||
</div> |
||||
<div>{$mobile}</div> |
||||
</div> |
||||
HTML |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,119 @@
@@ -0,0 +1,119 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Metrics\Examples; |
||||
|
||||
use App\Admin\Traits\DatepickerTrait; |
||||
use App\Models\UsersMember; |
||||
use Dcat\Admin\Widgets\Metrics\Line; |
||||
use Illuminate\Http\Request; |
||||
|
||||
class NewUsers extends Line |
||||
{ |
||||
use DatepickerTrait; |
||||
|
||||
/** |
||||
* 初始化卡片内容 |
||||
* |
||||
* @return void |
||||
*/ |
||||
protected function init() |
||||
{ |
||||
parent::init(); |
||||
|
||||
$this->title('该时间内注册'); |
||||
|
||||
#日期选择开始 |
||||
$id = $this->id(); |
||||
$this->datepicker($id) |
||||
->click("#{$id} .datepicker .btn-primary") |
||||
->addVariables([ |
||||
'datepicker' => [ |
||||
'start' => date('Y-m-d', strtotime('-7 days')), |
||||
'end' => date('Y-m-d', time()), |
||||
] |
||||
]); |
||||
#日期选择结束 |
||||
} |
||||
|
||||
/** |
||||
* 处理请求 |
||||
* |
||||
* @param Request $request |
||||
* |
||||
* @return mixed|void |
||||
*/ |
||||
public function handle(Request $request) |
||||
{ |
||||
$start = $request->get('started'); |
||||
$end = $request->get('ended'); |
||||
|
||||
if(empty($start) && empty($end)){ |
||||
$start = date("Y-m-d 00:00:00", strtotime('-7 days')); |
||||
$end = date("Y-m-d 23:59:59", time()); |
||||
//取出今日注册量 |
||||
$todayNum = UsersMember::query()->whereBetween("create_time", [strtotime($start), strtotime($end)])->count(); |
||||
$this->withContent($todayNum.'人'); |
||||
|
||||
$chart = []; |
||||
$dayCount = getDateRange($start, $end); |
||||
foreach($dayCount as $item){ |
||||
$thisDayCount = UsersMember::query()->whereBetween("create_time", [strtotime($item." 00:00:00"), strtotime($item." 23:59:59")])->count(); |
||||
$chart[] = $thisDayCount; |
||||
} |
||||
$this->withChart($chart); |
||||
|
||||
}else{ |
||||
//指定时间段内注册量 |
||||
$start = $start." 00:00:00"; |
||||
$end = $end." 23:59:59"; |
||||
$num = UsersMember::query()->whereBetween("create_time", [strtotime($start), strtotime($end)])->count(); |
||||
$this->withContent($num."人"); |
||||
|
||||
$chart = []; |
||||
$dayCount = getDateRange($start, $end); |
||||
foreach($dayCount as $item){ |
||||
$thisDayCount = UsersMember::query()->whereBetween("create_time", [strtotime($item." 00:00:00"), strtotime($item." 23:59:59")])->count(); |
||||
$chart[] = $thisDayCount; |
||||
} |
||||
$this->withChart($chart); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 设置图表数据. |
||||
* |
||||
* @param array $data |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function withChart(array $data) |
||||
{ |
||||
return $this->chart([ |
||||
'series' => [ |
||||
[ |
||||
'name' => $this->title, |
||||
'data' => $data, |
||||
], |
||||
], |
||||
]); |
||||
} |
||||
|
||||
/** |
||||
* 设置卡片内容. |
||||
* |
||||
* @param string $content |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function withContent($content) |
||||
{ |
||||
return $this->content( |
||||
<<<HTML |
||||
<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px"> |
||||
<h2 class="ml-1 font-lg-1">{$content}</h2> |
||||
<span class="mb-0 mr-1 text-80">{$this->title}</span> |
||||
</div> |
||||
HTML |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,114 @@
@@ -0,0 +1,114 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Metrics\Examples; |
||||
|
||||
use Dcat\Admin\Widgets\Metrics\Round; |
||||
use Illuminate\Http\Request; |
||||
|
||||
class ProductOrders extends Round |
||||
{ |
||||
/** |
||||
* 初始化卡片内容 |
||||
*/ |
||||
protected function init() |
||||
{ |
||||
parent::init(); |
||||
|
||||
$this->title('Product Orders'); |
||||
$this->chartLabels(['Finished', 'Pending', 'Rejected']); |
||||
$this->dropdown([ |
||||
'7' => 'Last 7 Days', |
||||
'28' => 'Last 28 Days', |
||||
'30' => 'Last Month', |
||||
'365' => 'Last Year', |
||||
]); |
||||
} |
||||
|
||||
/** |
||||
* 处理请求 |
||||
* |
||||
* @param Request $request |
||||
* |
||||
* @return mixed|void |
||||
*/ |
||||
public function handle(Request $request) |
||||
{ |
||||
switch ($request->get('option')) { |
||||
case '365': |
||||
case '30': |
||||
case '28': |
||||
case '7': |
||||
default: |
||||
// 卡片内容 |
||||
$this->withContent(23043, 14658, 4758); |
||||
|
||||
// 图表数据 |
||||
$this->withChart([70, 52, 26]); |
||||
|
||||
// 总数 |
||||
$this->chartTotal('Total', 344); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 设置图表数据. |
||||
* |
||||
* @param array $data |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function withChart(array $data) |
||||
{ |
||||
return $this->chart([ |
||||
'series' => $data, |
||||
]); |
||||
} |
||||
|
||||
/** |
||||
* 卡片内容. |
||||
* |
||||
* @param int $finished |
||||
* @param int $pending |
||||
* @param int $rejected |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function withContent($finished, $pending, $rejected) |
||||
{ |
||||
return $this->content( |
||||
<<<HTML |
||||
<div class="col-12 d-flex flex-column flex-wrap text-center" style="max-width: 220px"> |
||||
<div class="chart-info d-flex justify-content-between mb-1 mt-2" > |
||||
<div class="series-info d-flex align-items-center"> |
||||
<i class="fa fa-circle-o text-bold-700 text-primary"></i> |
||||
<span class="text-bold-600 ml-50">Finished</span> |
||||
</div> |
||||
<div class="product-result"> |
||||
<span>{$finished}</span> |
||||
</div> |
||||
</div> |
||||
|
||||
<div class="chart-info d-flex justify-content-between mb-1"> |
||||
<div class="series-info d-flex align-items-center"> |
||||
<i class="fa fa-circle-o text-bold-700 text-warning"></i> |
||||
<span class="text-bold-600 ml-50">Pending</span> |
||||
</div> |
||||
<div class="product-result"> |
||||
<span>{$pending}</span> |
||||
</div> |
||||
</div> |
||||
|
||||
<div class="chart-info d-flex justify-content-between mb-1"> |
||||
<div class="series-info d-flex align-items-center"> |
||||
<i class="fa fa-circle-o text-bold-700 text-danger"></i> |
||||
<span class="text-bold-600 ml-50">Rejected</span> |
||||
</div> |
||||
<div class="product-result"> |
||||
<span>{$rejected}</span> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
HTML |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,137 @@
@@ -0,0 +1,137 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Metrics\Examples; |
||||
|
||||
use App\Admin\Traits\DatepickerTrait; |
||||
use App\Models\Config; |
||||
use App\Models\SelectedDormitory; |
||||
use Dcat\Admin\Widgets\Metrics\Line; |
||||
use Illuminate\Http\Request; |
||||
|
||||
class SelectedDormitoryNewTotal extends Line |
||||
{ |
||||
use DatepickerTrait; |
||||
|
||||
/** |
||||
* 初始化卡片内容 |
||||
* |
||||
* @return void |
||||
*/ |
||||
protected function init() |
||||
{ |
||||
parent::init(); |
||||
|
||||
$this->title('该时间内分配(当前年份)'); |
||||
|
||||
#日期选择开始 |
||||
$id = $this->id(); |
||||
$this->datepicker($id) |
||||
->click("#{$id} .datepicker .btn-primary") |
||||
->addVariables([ |
||||
'datepicker' => [ |
||||
'start' => date('Y-m-d', strtotime('-7 days')), |
||||
'end' => date('Y-m-d', time()), |
||||
] |
||||
]); |
||||
#日期选择结束 |
||||
} |
||||
|
||||
/** |
||||
* 处理请求 |
||||
* |
||||
* @param Request $request |
||||
* |
||||
* @return mixed|void |
||||
*/ |
||||
public function handle(Request $request) |
||||
{ |
||||
$start = $request->get('started'); |
||||
$end = $request->get('ended'); |
||||
|
||||
//取出当前年份 |
||||
$config = Config::query()->where([ |
||||
"unique_identification" => "annual_session" |
||||
])->first(); |
||||
|
||||
if(empty($start) && empty($end)){ |
||||
$start = date("Y-m-d 00:00:00", strtotime('-7 days')); |
||||
$end = date("Y-m-d 23:59:59", time()); |
||||
//取出今日分配数 |
||||
$todayNum = SelectedDormitory::query()->where([ |
||||
"annual_session" => $config->data, |
||||
"status" => SelectedDormitory::STATUS_YES |
||||
])->whereBetween("create_time", [strtotime($start), strtotime($end)])->count(); |
||||
$this->withContent($todayNum.'人'); |
||||
|
||||
$chart = []; |
||||
$dayCount = getDateRange($start, $end); |
||||
foreach($dayCount as $item){ |
||||
$thisDayCount = SelectedDormitory::query()->where([ |
||||
"annual_session" => $config->data, |
||||
"status" => SelectedDormitory::STATUS_YES |
||||
])->whereBetween("create_time", [strtotime($item." 00:00:00"), strtotime($item." 23:59:59")])->count(); |
||||
$chart[] = $thisDayCount; |
||||
} |
||||
$this->withChart($chart); |
||||
|
||||
}else{ |
||||
//指定时间段内注册量 |
||||
$start = $start." 00:00:00"; |
||||
$end = $end." 23:59:59"; |
||||
$num = SelectedDormitory::query()->where([ |
||||
"annual_session" => $config->data, |
||||
"status" => SelectedDormitory::STATUS_YES |
||||
])->whereBetween("create_time", [strtotime($start), strtotime($end)])->count(); |
||||
$this->withContent($num."人"); |
||||
|
||||
$chart = []; |
||||
$dayCount = getDateRange($start, $end); |
||||
foreach($dayCount as $item){ |
||||
$thisDayCount = SelectedDormitory::query()->where([ |
||||
"annual_session" => $config->data, |
||||
"status" => SelectedDormitory::STATUS_YES |
||||
])->whereBetween("create_time", [strtotime($item." 00:00:00"), strtotime($item." 23:59:59")])->count(); |
||||
$chart[] = $thisDayCount; |
||||
} |
||||
$this->withChart($chart); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 设置图表数据. |
||||
* |
||||
* @param array $data |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function withChart(array $data) |
||||
{ |
||||
return $this->chart([ |
||||
'series' => [ |
||||
[ |
||||
'name' => $this->title, |
||||
'data' => $data, |
||||
], |
||||
], |
||||
]); |
||||
} |
||||
|
||||
/** |
||||
* 设置卡片内容. |
||||
* |
||||
* @param string $content |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function withContent($content) |
||||
{ |
||||
return $this->content( |
||||
<<<HTML |
||||
<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px"> |
||||
<h2 class="ml-1 font-lg-1">{$content}</h2> |
||||
<span class="mb-0 mr-1 text-80">{$this->title}</span> |
||||
</div> |
||||
HTML |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,128 @@
@@ -0,0 +1,128 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Metrics\Examples; |
||||
|
||||
use App\Models\Config; |
||||
use App\Models\SelectedDormitory; |
||||
use Dcat\Admin\Widgets\Metrics\Card; |
||||
use Illuminate\Contracts\Support\Renderable; |
||||
use Illuminate\Http\Request; |
||||
|
||||
class SelectedDormitoryTotal extends Card |
||||
{ |
||||
/** |
||||
* 卡片底部内容. |
||||
* |
||||
* @var string|Renderable|\Closure |
||||
*/ |
||||
protected $footer; |
||||
|
||||
/** |
||||
* 初始化卡片. |
||||
*/ |
||||
protected function init() |
||||
{ |
||||
parent::init(); |
||||
|
||||
$this->title('已分配'); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 处理请求. |
||||
* |
||||
* @param Request $request |
||||
* |
||||
* @return void |
||||
*/ |
||||
public function handle(Request $request) |
||||
{ |
||||
|
||||
//取出当前年份 |
||||
$config = Config::query()->where([ |
||||
"unique_identification" => "annual_session" |
||||
])->first(); |
||||
|
||||
//当前年份已分配宿舍总数 |
||||
$allCount = SelectedDormitory::query()->where([ |
||||
"annual_session" => $config->data, |
||||
"status" => SelectedDormitory::STATUS_YES |
||||
])->count(); |
||||
|
||||
$this->content($allCount); |
||||
|
||||
if($allCount > 0){ |
||||
$this->up($allCount); |
||||
}else{ |
||||
$this->down($allCount); |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* @param int $percent |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function up($percent) |
||||
{ |
||||
return $this->footer( |
||||
"<i class=\"feather icon-trending-up text-success\"></i> {$percent}人 为当前年份已分配床位数" |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* @param int $percent |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function down($percent) |
||||
{ |
||||
return $this->footer( |
||||
"<i class=\"feather icon-trending-down text-danger\"></i> {$percent}人 为当前年份已分配床位数" |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* 设置卡片底部内容. |
||||
* |
||||
* @param string|Renderable|\Closure $footer |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function footer($footer) |
||||
{ |
||||
$this->footer = $footer; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* 渲染卡片内容. |
||||
* |
||||
* @return string |
||||
*/ |
||||
public function renderContent() |
||||
{ |
||||
$content = parent::renderContent(); |
||||
|
||||
return <<<HTML |
||||
<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px"> |
||||
<h2 class="ml-1 font-lg-1">{$content}</h2> |
||||
</div> |
||||
<div class="ml-1 mt-1 font-weight-bold text-80"> |
||||
{$this->renderFooter()} |
||||
</div> |
||||
HTML; |
||||
} |
||||
|
||||
/** |
||||
* 渲染卡片底部内容. |
||||
* |
||||
* @return string |
||||
*/ |
||||
public function renderFooter() |
||||
{ |
||||
return $this->toString($this->footer); |
||||
} |
||||
} |
@ -0,0 +1,117 @@
@@ -0,0 +1,117 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Metrics\Examples; |
||||
|
||||
use Dcat\Admin\Admin; |
||||
use Dcat\Admin\Widgets\Metrics\Bar; |
||||
use Illuminate\Http\Request; |
||||
|
||||
class Sessions extends Bar |
||||
{ |
||||
/** |
||||
* 初始化卡片内容 |
||||
*/ |
||||
protected function init() |
||||
{ |
||||
parent::init(); |
||||
|
||||
$color = Admin::color(); |
||||
|
||||
$dark35 = $color->dark35(); |
||||
|
||||
// 卡片内容宽度 |
||||
$this->contentWidth(5, 7); |
||||
// 标题 |
||||
$this->title('Avg Sessions'); |
||||
// 设置下拉选项 |
||||
$this->dropdown([ |
||||
'7' => 'Last 7 Days', |
||||
'28' => 'Last 28 Days', |
||||
'30' => 'Last Month', |
||||
'365' => 'Last Year', |
||||
]); |
||||
// 设置图表颜色 |
||||
$this->chartColors([ |
||||
$dark35, |
||||
$dark35, |
||||
$color->primary(), |
||||
$dark35, |
||||
$dark35, |
||||
$dark35 |
||||
]); |
||||
} |
||||
|
||||
/** |
||||
* 处理请求 |
||||
* |
||||
* @param Request $request |
||||
* |
||||
* @return mixed|void |
||||
*/ |
||||
public function handle(Request $request) |
||||
{ |
||||
switch ($request->get('option')) { |
||||
case '7': |
||||
default: |
||||
// 卡片内容 |
||||
$this->withContent('2.7k', '+5.2%'); |
||||
|
||||
// 图表数据 |
||||
$this->withChart([ |
||||
[ |
||||
'name' => 'Sessions', |
||||
'data' => [75, 125, 225, 175, 125, 75, 25], |
||||
], |
||||
]); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 设置图表数据. |
||||
* |
||||
* @param array $data |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function withChart(array $data) |
||||
{ |
||||
return $this->chart([ |
||||
'series' => $data, |
||||
]); |
||||
} |
||||
|
||||
/** |
||||
* 设置卡片内容. |
||||
* |
||||
* @param string $title |
||||
* @param string $value |
||||
* @param string $style |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function withContent($title, $value, $style = 'success') |
||||
{ |
||||
// 根据选项显示 |
||||
$label = strtolower( |
||||
$this->dropdown[request()->option] ?? 'last 7 days' |
||||
); |
||||
|
||||
$minHeight = '183px'; |
||||
|
||||
return $this->content( |
||||
<<<HTML |
||||
<div class="d-flex p-1 flex-column justify-content-between" style="padding-top: 0;width: 100%;height: 100%;min-height: {$minHeight}"> |
||||
<div class="text-left"> |
||||
<h1 class="font-lg-2 mt-2 mb-0">{$title}</h1> |
||||
<h5 class="font-medium-2" style="margin-top: 10px;"> |
||||
<span class="text-{$style}">{$value} </span> |
||||
<span>vs {$label}</span> |
||||
</h5> |
||||
</div> |
||||
|
||||
<a href="#" class="btn btn-primary shadow waves-effect waves-light">View Details <i class="feather icon-chevrons-right"></i></a> |
||||
</div> |
||||
HTML |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,116 @@
@@ -0,0 +1,116 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Metrics\Examples; |
||||
|
||||
use Dcat\Admin\Widgets\Metrics\RadialBar; |
||||
use Illuminate\Http\Request; |
||||
|
||||
class Tickets extends RadialBar |
||||
{ |
||||
/** |
||||
* 初始化卡片内容 |
||||
*/ |
||||
protected function init() |
||||
{ |
||||
parent::init(); |
||||
|
||||
$this->title('Tickets'); |
||||
$this->height(400); |
||||
$this->chartHeight(300); |
||||
$this->chartLabels('Completed Tickets'); |
||||
$this->dropdown([ |
||||
'7' => 'Last 7 Days', |
||||
'28' => 'Last 28 Days', |
||||
'30' => 'Last Month', |
||||
'365' => 'Last Year', |
||||
]); |
||||
} |
||||
|
||||
/** |
||||
* 处理请求 |
||||
* |
||||
* @param Request $request |
||||
* |
||||
* @return mixed|void |
||||
*/ |
||||
public function handle(Request $request) |
||||
{ |
||||
switch ($request->get('option')) { |
||||
case '365': |
||||
case '30': |
||||
case '28': |
||||
case '7': |
||||
default: |
||||
// 卡片内容 |
||||
$this->withContent(162); |
||||
// 卡片底部 |
||||
$this->withFooter(29, 63, '1d'); |
||||
// 图表数据 |
||||
$this->withChart(83); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 设置图表数据. |
||||
* |
||||
* @param int $data |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function withChart(int $data) |
||||
{ |
||||
return $this->chart([ |
||||
'series' => [$data], |
||||
]); |
||||
} |
||||
|
||||
/** |
||||
* 卡片内容 |
||||
* |
||||
* @param string $content |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function withContent($content) |
||||
{ |
||||
return $this->content( |
||||
<<<HTML |
||||
<div class="d-flex flex-column flex-wrap text-center"> |
||||
<h1 class="font-lg-2 mt-2 mb-0">{$content}</h1> |
||||
<small>Tickets</small> |
||||
</div> |
||||
HTML |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* 卡片底部内容. |
||||
* |
||||
* @param string $new |
||||
* @param string $open |
||||
* @param string $response |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function withFooter($new, $open, $response) |
||||
{ |
||||
return $this->footer( |
||||
<<<HTML |
||||
<div class="d-flex justify-content-between p-1" style="padding-top: 0!important;"> |
||||
<div class="text-center"> |
||||
<p>New Tickets</p> |
||||
<span class="font-lg-1">{$new}</span> |
||||
</div> |
||||
<div class="text-center"> |
||||
<p>Open Tickets</p> |
||||
<span class="font-lg-1">{$open}</span> |
||||
</div> |
||||
<div class="text-center"> |
||||
<p>Response Time</p> |
||||
<span class="font-lg-1">{$response}</span> |
||||
</div> |
||||
</div> |
||||
HTML |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,124 @@
@@ -0,0 +1,124 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Metrics\Examples; |
||||
|
||||
use App\Models\UsersMember; |
||||
use Dcat\Admin\Widgets\Metrics\Card; |
||||
use Illuminate\Contracts\Support\Renderable; |
||||
use Illuminate\Http\Request; |
||||
|
||||
class TotalUsers extends Card |
||||
{ |
||||
/** |
||||
* 卡片底部内容. |
||||
* |
||||
* @var string|Renderable|\Closure |
||||
*/ |
||||
protected $footer; |
||||
|
||||
/** |
||||
* 初始化卡片. |
||||
*/ |
||||
protected function init() |
||||
{ |
||||
parent::init(); |
||||
|
||||
$this->title('总注册'); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 处理请求. |
||||
* |
||||
* @param Request $request |
||||
* |
||||
* @return void |
||||
*/ |
||||
public function handle(Request $request) |
||||
{ |
||||
|
||||
//注册总人数 |
||||
$allCount = UsersMember::query()->count(); |
||||
$this->content($allCount); |
||||
|
||||
//取出开始到前一天的注册人数 |
||||
$today = date("Y-m-d"); |
||||
$yesterday = date("Y-m-d 23:59:59", strtotime("-1 day", strtotime($today))); |
||||
$yeserCount = UsersMember::query()->whereBetween("create_time", [0, strtotime($yesterday)])->count(); |
||||
|
||||
$num = $allCount - $yeserCount; |
||||
if($num > 0 ){ |
||||
$this->up($num); |
||||
}else{ |
||||
$this->down($num); |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* @param int $percent |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function up($percent) |
||||
{ |
||||
return $this->footer( |
||||
"<i class=\"feather icon-trending-up text-success\"></i> {$percent}人 比昨天多注册" |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* @param int $percent |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function down($percent) |
||||
{ |
||||
return $this->footer( |
||||
"<i class=\"feather icon-trending-down text-danger\"></i> {$percent}人 比昨天少注册" |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* 设置卡片底部内容. |
||||
* |
||||
* @param string|Renderable|\Closure $footer |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function footer($footer) |
||||
{ |
||||
$this->footer = $footer; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* 渲染卡片内容. |
||||
* |
||||
* @return string |
||||
*/ |
||||
public function renderContent() |
||||
{ |
||||
$content = parent::renderContent(); |
||||
|
||||
return <<<HTML |
||||
<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px"> |
||||
<h2 class="ml-1 font-lg-1">{$content}</h2> |
||||
</div> |
||||
<div class="ml-1 mt-1 font-weight-bold text-80"> |
||||
{$this->renderFooter()} |
||||
</div> |
||||
HTML; |
||||
} |
||||
|
||||
/** |
||||
* 渲染卡片底部内容. |
||||
* |
||||
* @return string |
||||
*/ |
||||
public function renderFooter() |
||||
{ |
||||
return $this->toString($this->footer); |
||||
} |
||||
} |
@ -0,0 +1,40 @@
@@ -0,0 +1,40 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Renderable; |
||||
|
||||
use App\Models\BasicFamilyInformation; |
||||
use Dcat\Admin\Grid; |
||||
use Dcat\Admin\Grid\LazyRenderable; |
||||
|
||||
|
||||
class UserFamilyMeberTable extends LazyRenderable |
||||
{ |
||||
|
||||
public function grid(): Grid |
||||
{ |
||||
|
||||
return Grid::make(new BasicFamilyInformation(), function (Grid $grid) { |
||||
|
||||
# 接收参数 |
||||
$unique_number = $this->payload['unique_number'] ?? null; |
||||
if (!empty($unique_number)) { |
||||
$grid->model()->where('unique_number', $unique_number); |
||||
} |
||||
|
||||
$grid->column('name'); |
||||
$grid->column('mobile'); |
||||
$grid->column('relationship', "关系"); |
||||
|
||||
//禁用批量操作按钮 |
||||
$grid->disableBatchDelete(); |
||||
//禁用创建按钮 |
||||
$grid->disableCreateButton(); |
||||
//禁用操作按钮 |
||||
$grid->disableActions(); |
||||
//禁用刷新按钮 |
||||
$grid->disableRefreshButton(); |
||||
|
||||
$grid->paginate(10); |
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,42 @@
@@ -0,0 +1,42 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Renderable; |
||||
|
||||
use App\Models\UserBasicInfo; |
||||
use Dcat\Admin\Grid; |
||||
use Dcat\Admin\Grid\LazyRenderable; |
||||
|
||||
|
||||
class UserFamilyTable extends LazyRenderable |
||||
{ |
||||
|
||||
public function grid(): Grid |
||||
{ |
||||
|
||||
return Grid::make(new UserBasicInfo(), function (Grid $grid) { |
||||
|
||||
# 接收参数 |
||||
$unique_number = $this->payload['unique_number'] ?? null; |
||||
if (!empty($unique_number)) { |
||||
$grid->model()->where('unique_number', $unique_number); |
||||
} |
||||
|
||||
$grid->column('email'); |
||||
$grid->column('postal_code', "邮编"); |
||||
$grid->column('native',"籍贯"); |
||||
$grid->column('province_city_area', "省市区"); |
||||
$grid->column('address', "详细地址"); |
||||
|
||||
//禁用批量操作按钮 |
||||
$grid->disableBatchDelete(); |
||||
//禁用创建按钮 |
||||
$grid->disableCreateButton(); |
||||
//禁用操作按钮 |
||||
$grid->disableActions(); |
||||
//禁用刷新按钮 |
||||
$grid->disableRefreshButton(); |
||||
|
||||
$grid->paginate(10); |
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Repositories; |
||||
|
||||
use App\Models\Bed as Model; |
||||
use Dcat\Admin\Repositories\EloquentRepository; |
||||
|
||||
class Bed extends EloquentRepository |
||||
{ |
||||
/** |
||||
* Model. |
||||
* |
||||
* @var string |
||||
*/ |
||||
protected $eloquentClass = Model::class; |
||||
} |
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Repositories; |
||||
|
||||
use App\Models\Building as Model; |
||||
use Dcat\Admin\Repositories\EloquentRepository; |
||||
|
||||
class Building extends EloquentRepository |
||||
{ |
||||
/** |
||||
* Model. |
||||
* |
||||
* @var string |
||||
*/ |
||||
protected $eloquentClass = Model::class; |
||||
} |
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Repositories; |
||||
|
||||
use App\Models\DormitoryNumber as Model; |
||||
use Dcat\Admin\Repositories\EloquentRepository; |
||||
|
||||
class DormitoryNumber extends EloquentRepository |
||||
{ |
||||
/** |
||||
* Model. |
||||
* |
||||
* @var string |
||||
*/ |
||||
protected $eloquentClass = Model::class; |
||||
} |
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Repositories; |
||||
|
||||
use App\Models\DormitoryType as Model; |
||||
use Dcat\Admin\Repositories\EloquentRepository; |
||||
|
||||
class DormitoryType extends EloquentRepository |
||||
{ |
||||
/** |
||||
* Model. |
||||
* |
||||
* @var string |
||||
*/ |
||||
protected $eloquentClass = Model::class; |
||||
} |
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Repositories; |
||||
|
||||
use App\Models\Floor as Model; |
||||
use Dcat\Admin\Repositories\EloquentRepository; |
||||
|
||||
class Floor extends EloquentRepository |
||||
{ |
||||
/** |
||||
* Model. |
||||
* |
||||
* @var string |
||||
*/ |
||||
protected $eloquentClass = Model::class; |
||||
} |
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Repositories; |
||||
|
||||
use App\Models\LivingArea as Model; |
||||
use Dcat\Admin\Repositories\EloquentRepository; |
||||
|
||||
class LivingArea extends EloquentRepository |
||||
{ |
||||
/** |
||||
* Model. |
||||
* |
||||
* @var string |
||||
*/ |
||||
protected $eloquentClass = Model::class; |
||||
} |
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Repositories; |
||||
|
||||
use App\Models\MultipleWorld as Model; |
||||
use Dcat\Admin\Repositories\EloquentRepository; |
||||
|
||||
class MultipleWorld extends EloquentRepository |
||||
{ |
||||
/** |
||||
* Model. |
||||
* |
||||
* @var string |
||||
*/ |
||||
protected $eloquentClass = Model::class; |
||||
} |
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Repositories; |
||||
|
||||
use App\Models\User as Model; |
||||
use Dcat\Admin\Repositories\EloquentRepository; |
||||
|
||||
class User extends EloquentRepository |
||||
{ |
||||
/** |
||||
* Model. |
||||
* |
||||
* @var string |
||||
*/ |
||||
protected $eloquentClass = Model::class; |
||||
} |
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Repositories; |
||||
|
||||
use App\Models\WechatAppConfig as Model; |
||||
use Dcat\Admin\Repositories\EloquentRepository; |
||||
|
||||
class WechatAppConfig extends EloquentRepository |
||||
{ |
||||
/** |
||||
* Model. |
||||
* |
||||
* @var string |
||||
*/ |
||||
protected $eloquentClass = Model::class; |
||||
} |
@ -0,0 +1,56 @@
@@ -0,0 +1,56 @@
|
||||
<?php |
||||
namespace App\Admin\Traits; |
||||
|
||||
trait DatepickerTrait |
||||
{ |
||||
|
||||
protected $id = ''; |
||||
|
||||
/** |
||||
* 引入 |
||||
* @param $formID |
||||
* @return $this |
||||
*/ |
||||
public function datepicker($formID) |
||||
{ |
||||
$this->id = $formID; |
||||
|
||||
$this->file(); |
||||
$this->script(); |
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* 所需要的css js |
||||
*/ |
||||
protected function file() |
||||
{ |
||||
admin_css('/vendor/dcat-admin/dcat/plugins/bootstrap-datetimepicker/bootstrap-datetimepicker.css'); |
||||
admin_js('/vendor/dcat-admin/dcat/plugins/moment/moment-with-locales.min.js'); |
||||
admin_js('/vendor/dcat-admin/dcat/plugins/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js'); |
||||
} |
||||
|
||||
/** |
||||
* 绑定时间选择器点击事件 |
||||
*/ |
||||
protected function script() |
||||
{ |
||||
admin_script( <<<JS |
||||
Dcat.init('#{$this->id} .datepicker .field_started', function (self, id) { var options = {"format":"YYYY-MM-DD","locale":"zh_CN"}; |
||||
var last = $('#{$this->id} .datepicker .field_ended'); |
||||
|
||||
self.datetimepicker(options); |
||||
last.datetimepicker($.extend(options, {useCurrent: false})); |
||||
self.on("dp.change", function (e) { |
||||
last.data("DateTimePicker").minDate(e.date); |
||||
$("#{$this->id} .datepicker .btn-primary").data('started', $(this).val()) |
||||
}); |
||||
last.on("dp.change", function (e) { |
||||
self.data("DateTimePicker").maxDate(e.date); |
||||
$("#{$this->id} .datepicker .btn-primary").data('ended', $(this).val()) |
||||
}); |
||||
}); |
||||
JS); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,26 @@
@@ -0,0 +1,26 @@
|
||||
<?php |
||||
|
||||
use Dcat\Admin\Admin; |
||||
use Dcat\Admin\Grid; |
||||
use Dcat\Admin\Form; |
||||
use Dcat\Admin\Grid\Filter; |
||||
use Dcat\Admin\Show; |
||||
|
||||
/** |
||||
* Dcat-admin - admin builder based on Laravel. |
||||
* @author jqh <https://github.com/jqhph> |
||||
* |
||||
* Bootstraper for Admin. |
||||
* |
||||
* Here you can remove builtin form field: |
||||
* |
||||
* extend custom field: |
||||
* Dcat\Admin\Form::extend('php', PHPEditor::class); |
||||
* Dcat\Admin\Grid\Column::extend('php', PHPEditor::class); |
||||
* Dcat\Admin\Grid\Filter::extend('php', PHPEditor::class); |
||||
* |
||||
* Or require js and css assets: |
||||
* Admin::css('/packages/prettydocs/css/styles.css'); |
||||
* Admin::js('/packages/prettydocs/js/main.js'); |
||||
* |
||||
*/ |
@ -0,0 +1,40 @@
@@ -0,0 +1,40 @@
|
||||
<?php |
||||
|
||||
use Illuminate\Routing\Router; |
||||
use Illuminate\Support\Facades\Route; |
||||
use Dcat\Admin\Admin; |
||||
|
||||
Admin::routes(); |
||||
|
||||
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("/user", "UsersMemberController"); |
||||
$router->resource("/teacher_scan_code_users", "TeacherScanCodeUserController"); |
||||
$router->resource("/admission_new_students", "AdmissionNewStudentController"); |
||||
$router->resource("/relationship", "RelationshipController"); |
||||
$router->resource("/admission_guide", "AdmissionGuideController"); |
||||
$router->resource("/school_opening_time", "SchoolOpeningTimeController"); |
||||
$router->resource("/offline_step", "OfflineStepController"); |
||||
$router->resource("/step", "StepController"); |
||||
$router->resource("/secondary_college", "SecondaryCollegeController"); |
||||
$router->resource("/speciality", "SpecialityController"); |
||||
$router->resource("/selected_dormitory", "SelectedDormitoryController"); |
||||
$router->resource("/allocation_dormitory_bed", "AllocationDormitoryBedController"); |
||||
$router->resource("/dormitory_type", "DormitoryTypeController"); |
||||
$router->resource("/multiple_worlds", "MultipleWorldController"); |
||||
$router->resource("/living_area", "LivingAreaController"); |
||||
$router->resource("/building", "BuildingController"); |
||||
$router->resource("/floor", "FloorController"); |
||||
$router->resource("/dormitory_number", "DormitoryNumberController"); |
||||
$router->resource("/bed", "BedController"); |
||||
$router->resource("/order", "OrderController"); |
||||
$router->resource("/wechat_app", "WechatAppController"); |
||||
$router->resource("/wechat_app_config", "WechatAppConfigController"); |
||||
$router->resource("/security_user", "SecurityUserController"); |
||||
}); |
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
<?php |
||||
|
||||
namespace App\Console; |
||||
|
||||
use Illuminate\Console\Scheduling\Schedule; |
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel; |
||||
|
||||
class Kernel extends ConsoleKernel |
||||
{ |
||||
/** |
||||
* Define the application's command schedule. |
||||
* |
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule |
||||
* @return void |
||||
*/ |
||||
protected function schedule(Schedule $schedule) |
||||
{ |
||||
// $schedule->command('inspire')->hourly(); |
||||
} |
||||
|
||||
/** |
||||
* Register the commands for the application. |
||||
* |
||||
* @return void |
||||
*/ |
||||
protected function commands() |
||||
{ |
||||
$this->load(__DIR__.'/Commands'); |
||||
|
||||
require base_path('routes/console.php'); |
||||
} |
||||
} |
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
<?php |
||||
|
||||
namespace App\Exceptions; |
||||
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; |
||||
use Throwable; |
||||
|
||||
class Handler extends ExceptionHandler |
||||
{ |
||||
/** |
||||
* A list of the exception types that are not reported. |
||||
* |
||||
* @var array<int, class-string<Throwable>> |
||||
*/ |
||||
protected $dontReport = [ |
||||
// |
||||
]; |
||||
|
||||
/** |
||||
* A list of the inputs that are never flashed for validation exceptions. |
||||
* |
||||
* @var array<int, string> |
||||
*/ |
||||
protected $dontFlash = [ |
||||
'current_password', |
||||
'password', |
||||
'password_confirmation', |
||||
]; |
||||
|
||||
/** |
||||
* Register the exception handling callbacks for the application. |
||||
* |
||||
* @return void |
||||
*/ |
||||
public function register() |
||||
{ |
||||
$this->reportable(function (Throwable $e) { |
||||
// |
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,55 @@
@@ -0,0 +1,55 @@
|
||||
<?php |
||||
|
||||
use Illuminate\Support\Facades\Redis as RedisAlias; |
||||
|
||||
/** |
||||
* CURL访问 |
||||
* @param string $url |
||||
* @param string $methon |
||||
* @param array $postData |
||||
*/ |
||||
function getDataByCurl($url, $methon = "GET", $postData = []) |
||||
{ |
||||
//初始化 |
||||
$curl = curl_init(); |
||||
//设置抓取的url |
||||
curl_setopt($curl, CURLOPT_URL, $url); |
||||
//设置头文件的信息作为数据流输出 |
||||
curl_setopt($curl, CURLOPT_HEADER, 1); |
||||
//设置获取的信息以文件流的形式返回,而不是直接输出。 |
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); |
||||
//检测是以GET还是POST方式访问 |
||||
if($methon == "POST"){ |
||||
//设置post方式提交 |
||||
curl_setopt($curl, CURLOPT_POST, 1); |
||||
//设置post数据 |
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); |
||||
} |
||||
//执行命令 |
||||
$data = curl_exec($curl); |
||||
|
||||
//请求成功时去除header数据(如url返回json格式时,去除header可取出完整的Json数据) |
||||
if(curl_getinfo($curl, CURLINFO_HTTP_CODE) == "200"){ |
||||
$headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE); // 获取header长度 |
||||
$data = substr($data, $headerSize); //截掉header |
||||
} |
||||
|
||||
//关闭URL请求 |
||||
curl_close($curl); |
||||
|
||||
return $data; |
||||
} |
||||
|
||||
function getDateRange($start, $end) { |
||||
$dates = []; |
||||
$current = strtotime($start); |
||||
$end = strtotime($end); |
||||
while ($current <= $end) { |
||||
$dates[] = date('Y-m-d', $current); |
||||
$current = strtotime('+1 day', $current); |
||||
} |
||||
return $dates; |
||||
} |
||||
|
||||
|
||||
|
@ -0,0 +1,633 @@
@@ -0,0 +1,633 @@
|
||||
<?php |
||||
|
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use App\Models\AllocationDormitoryBed; |
||||
use App\Models\Bed; |
||||
use App\Models\Building; |
||||
use App\Models\Config; |
||||
use App\Models\DormitoryNumber; |
||||
use App\Models\DormitoryType; |
||||
use App\Models\Floor; |
||||
use App\Models\LivingArea; |
||||
use App\Models\MultipleWorld; |
||||
use App\Models\SecondaryCollege; |
||||
use App\Models\SelectedDormitory; |
||||
use App\Models\Speciality; |
||||
use Illuminate\Http\Request; |
||||
use Illuminate\Support\Facades\DB; |
||||
|
||||
class AllocationDormitoryApi extends Controller |
||||
{ |
||||
/** |
||||
* 获取几人间(床位列表模块) |
||||
* @return array |
||||
*/ |
||||
public function getMultipleWorldsByList(Request $request) |
||||
{ |
||||
$q = $request->input("q"); |
||||
|
||||
$dormitoryType = MultipleWorld::query()->where([ |
||||
"status" => MultipleWorld::STATUS_YES, |
||||
"dormitory_type_id" => $q, |
||||
])->get(["id", "people"])->toArray(); |
||||
|
||||
$result = []; |
||||
foreach($dormitoryType as $item){ |
||||
$result[] = [ |
||||
"id" => $item["id"], |
||||
"text" => $item["people"] |
||||
]; |
||||
} |
||||
return $result; |
||||
} |
||||
|
||||
|
||||
|
||||
/** |
||||
* 返回性别列表 |
||||
* @return array[] |
||||
*/ |
||||
public function getSex(Request $request) |
||||
{ |
||||
$sex = $request->input("sex"); |
||||
$sex = rtrim($sex, "?"); |
||||
|
||||
if($sex == 1){ |
||||
return [ |
||||
[ |
||||
"id" => 1, |
||||
"text" => "男", |
||||
], |
||||
]; |
||||
}else if($sex == 2){ |
||||
return [ |
||||
[ |
||||
"id" => 2, |
||||
"text" => "女", |
||||
], |
||||
]; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 获取专业信息 |
||||
* @param Request $request |
||||
* @return array |
||||
*/ |
||||
public function getSpeciality(Request $request) |
||||
{ |
||||
$where = [ |
||||
"status" => Speciality::STATUS_YES, |
||||
]; |
||||
|
||||
$specialityList = Speciality::query()->where($where)->get(["id", "speciality_name", "secondary_college_id"])->toArray(); |
||||
|
||||
$result = []; |
||||
foreach($specialityList as $item){ |
||||
//二级学院 |
||||
$college = SecondaryCollege::query()->where("id", $item["secondary_college_id"])->first(); |
||||
$str = "(未找到二级学院信息)"; |
||||
if(!empty($college)){ |
||||
$str = "({$college->name})"; |
||||
} |
||||
|
||||
$result[] = [ |
||||
"id" => $item["id"], |
||||
"text" => $item["speciality_name"].$str, |
||||
]; |
||||
} |
||||
|
||||
return $result; |
||||
} |
||||
|
||||
/** |
||||
* 获取宿舍类型 |
||||
* @return array |
||||
*/ |
||||
public function getDormitoryType(Request $request) |
||||
{ |
||||
|
||||
$dormitory_type = rtrim($request->input("dormitory_type"), "?"); |
||||
|
||||
$dormitoryTypeModel = DormitoryType::query()->where([ |
||||
"id" => $dormitory_type |
||||
]); |
||||
|
||||
$dormitoryType = $dormitoryTypeModel->get(["id", "dormitory"])->toArray(); |
||||
|
||||
$result = []; |
||||
foreach($dormitoryType as $item){ |
||||
$result[] = [ |
||||
"id" => $item["id"], |
||||
"text" => $item["dormitory"], |
||||
]; |
||||
} |
||||
return $result; |
||||
} |
||||
|
||||
/** |
||||
* 获取几人间 |
||||
* @return array |
||||
*/ |
||||
public function getMultipleWorlds(Request $request) |
||||
{ |
||||
|
||||
$multiple_worlds = rtrim($request->input("multiple_worlds"), "?"); |
||||
|
||||
$dormitoryTypeModel = MultipleWorld::query()->where([ |
||||
"id" => $multiple_worlds |
||||
]); |
||||
|
||||
$dormitoryType = $dormitoryTypeModel->get(["id", "people"])->toArray(); |
||||
$result = []; |
||||
foreach($dormitoryType as $item){ |
||||
$result[] = [ |
||||
"id" => $item["id"], |
||||
"text" => $item["people"] |
||||
]; |
||||
} |
||||
return $result; |
||||
} |
||||
|
||||
/** |
||||
* 获取生活区 |
||||
* @return array |
||||
*/ |
||||
public function getLiving(Request $request) |
||||
{ |
||||
$living_quarters = rtrim($request->input("living_quarters"), "?"); |
||||
$dormitoryType = LivingArea::query()->where([ |
||||
"id" => $living_quarters |
||||
])->get(["id", "title"])->toArray(); |
||||
|
||||
$result = []; |
||||
foreach($dormitoryType as $item){ |
||||
$result[] = [ |
||||
"id" => $item["id"], |
||||
"text" => $item["title"] |
||||
]; |
||||
} |
||||
return $result; |
||||
} |
||||
|
||||
/** |
||||
* 获取楼栋 |
||||
* @return array |
||||
*/ |
||||
public function getBuilding(Request $request) |
||||
{ |
||||
$building_id = rtrim($request->input("building_id"), "?"); |
||||
$dormitoryType = Building::query()->where([ |
||||
"id" => $building_id |
||||
])->get(["id", "building_title"])->toArray(); |
||||
|
||||
$result = []; |
||||
foreach($dormitoryType as $item){ |
||||
$result[] = [ |
||||
"id" => $item["id"], |
||||
"text" => $item["building_title"] |
||||
]; |
||||
} |
||||
return $result; |
||||
} |
||||
|
||||
/** |
||||
* 获取楼层 |
||||
* @return array |
||||
*/ |
||||
public function getFloor(Request $request) |
||||
{ |
||||
$floor_id = rtrim($request->input("floor_id"), "?"); |
||||
$dormitoryType = Floor::query()->where([ |
||||
"id" => $floor_id |
||||
])->get(["id", "floor_title"])->toArray(); |
||||
|
||||
$result = []; |
||||
foreach($dormitoryType as $item){ |
||||
$result[] = [ |
||||
"id" => $item["id"], |
||||
"text" => $item["floor_title"] |
||||
]; |
||||
} |
||||
return $result; |
||||
} |
||||
|
||||
/** |
||||
* 获取宿舍号 |
||||
* @return array |
||||
*/ |
||||
public function getDormitoryNumber(Request $request) |
||||
{ |
||||
$dormitory_number = rtrim($request->input("dormitory_number"), "?"); |
||||
$dormitoryType = DormitoryNumber::query()->where([ |
||||
"id" => $dormitory_number |
||||
])->get(["id", "dormitory_number"])->toArray(); |
||||
|
||||
$result = []; |
||||
foreach($dormitoryType as $item){ |
||||
$result[] = [ |
||||
"id" => $item["id"], |
||||
"text" => $item["dormitory_number"] |
||||
]; |
||||
} |
||||
return $result; |
||||
} |
||||
|
||||
/** |
||||
* 获取床位号 |
||||
* @return array |
||||
*/ |
||||
public function getBed(Request $request) |
||||
{ |
||||
$bed_id = rtrim($request->input("bed_id"), "?"); |
||||
$dormitoryType = Bed::query()->where([ |
||||
"id" => $bed_id |
||||
])->get(["id", "bed_number"])->toArray(); |
||||
|
||||
$result = []; |
||||
foreach($dormitoryType as $item){ |
||||
$result[] = [ |
||||
"id" => $item["id"], |
||||
"text" => $item["bed_number"] |
||||
]; |
||||
} |
||||
return $result; |
||||
} |
||||
|
||||
/** |
||||
* 获取专业信息(联动) |
||||
* @param Request $request |
||||
* @return array |
||||
*/ |
||||
public function getSpecialityLoad(Request $request) |
||||
{ |
||||
$where = [ |
||||
"status" => Speciality::STATUS_YES, |
||||
]; |
||||
|
||||
$specialityList = Speciality::query()->where($where)->get(["id", "speciality_name", "secondary_college_id"])->toArray(); |
||||
|
||||
$result = []; |
||||
foreach($specialityList as $item){ |
||||
//二级学院 |
||||
$college = SecondaryCollege::query()->where("id", $item["secondary_college_id"])->first(); |
||||
$str = "(未找到二级学院信息)"; |
||||
if(!empty($college)){ |
||||
$str = "({$college->name})"; |
||||
} |
||||
|
||||
$result[] = [ |
||||
"id" => $item["id"], |
||||
"text" => $item["speciality_name"].$str, |
||||
]; |
||||
} |
||||
|
||||
return $result; |
||||
} |
||||
|
||||
/** |
||||
* 获取宿舍类型(联动) |
||||
* @param Request $request |
||||
* @return array |
||||
*/ |
||||
public function getDormitoryTypeLoad(Request $request) |
||||
{ |
||||
$sex = $request->input("sex"); |
||||
$speciality_id = $request->input("q"); |
||||
|
||||
$DormitoryType = DormitoryType::query()->where("status", 1)->get(["id", DB::raw('dormitory as text')])->toarray(); |
||||
$data = []; |
||||
foreach ($DormitoryType as $v) { |
||||
$data[] = [ |
||||
"id" => json_encode([ |
||||
"id" => $v["id"], |
||||
"sex" => $sex, |
||||
"speciality_id" => $speciality_id |
||||
]), |
||||
"text" => $v["text"] |
||||
]; |
||||
} |
||||
return $data; |
||||
} |
||||
|
||||
/** |
||||
* 获取几人间(联动) |
||||
* @param Request $request |
||||
* @return array |
||||
*/ |
||||
public function getMultiplWorldsLoad(Request $request) |
||||
{ |
||||
$dormitory_type = json_decode($request->get("q"), 1); |
||||
if (empty($dormitory_type)) { |
||||
return []; |
||||
} |
||||
$MultipleWorlds = MultipleWorld::query()->where("dormitory_type_id", $dormitory_type["id"])->get(["id", DB::raw('people as text'), "price"])->toarray(); |
||||
$data = []; |
||||
foreach ($MultipleWorlds as $v) { |
||||
$data[] = [ |
||||
"id" => json_encode([ |
||||
"id" => $v["id"], |
||||
"dormitory_type" => $dormitory_type["id"], |
||||
"sex" => $dormitory_type["sex"], |
||||
"speciality_id" => $dormitory_type["speciality_id"], |
||||
]), |
||||
"text" => $v["text"]."({$v['price']}元)" |
||||
]; |
||||
} |
||||
return $data; |
||||
} |
||||
|
||||
/** |
||||
* 获取生活区(联动) |
||||
* @param Request $request |
||||
* @return array |
||||
*/ |
||||
public function getLivingAreaLoad(Request $request) |
||||
{ |
||||
$dormitory_type = json_decode($request->get("q"), 1); |
||||
if (empty($dormitory_type)) { |
||||
return []; |
||||
} |
||||
//取出当前年份 |
||||
$config = Config::query()->where([ |
||||
"unique_identification" => "annual_session" |
||||
])->first(); |
||||
|
||||
$living_area = AllocationDormitoryBed::query() |
||||
->where("multiple_worlds", $dormitory_type["id"]) |
||||
->where("dormitory_type", $dormitory_type["dormitory_type"]) |
||||
->where("sex", $dormitory_type["sex"]) |
||||
->where("speciality_id", $dormitory_type["speciality_id"]) |
||||
->where("annual_session", $config->data) |
||||
->where("status", AllocationDormitoryBed::STATUS_YES) |
||||
->distinct()->get("living_area")->toArray(); |
||||
if (empty($living_area)) { |
||||
return []; |
||||
} |
||||
$LivingArea = LivingArea::query()->whereIn("id", $living_area)->get(["id", DB::raw('title as text')])->toarray(); |
||||
$data = []; |
||||
foreach ($LivingArea as $v) { |
||||
$data[] = [ |
||||
"id" => json_encode([ |
||||
"multiple_worlds" => $dormitory_type["id"], |
||||
"dormitory_type" => $dormitory_type["dormitory_type"], |
||||
"living_area" => $v["id"], |
||||
"sex" => $dormitory_type["sex"], |
||||
"speciality_id" => $dormitory_type["speciality_id"], |
||||
]), |
||||
"text" => $v["text"] |
||||
]; |
||||
} |
||||
|
||||
return $data; |
||||
} |
||||
|
||||
/** |
||||
* 获取楼栋(联动) |
||||
* @param Request $request |
||||
* @return array |
||||
*/ |
||||
public function getBuildingLoad(Request $request) |
||||
{ |
||||
$living_quarters = json_decode($request->get("q"), 1); |
||||
if (empty($living_quarters)) { |
||||
return []; |
||||
} |
||||
//取出当前年份 |
||||
$config = Config::query()->where([ |
||||
"unique_identification" => "annual_session" |
||||
])->first(); |
||||
$building = AllocationDormitoryBed::query() |
||||
->where("living_area", $living_quarters["living_area"]) |
||||
->where("multiple_worlds", $living_quarters["multiple_worlds"]) |
||||
->where("dormitory_type", $living_quarters["dormitory_type"]) |
||||
->where("sex", $living_quarters["sex"]) |
||||
->where("speciality_id", $living_quarters["speciality_id"]) |
||||
->where("annual_session", $config->data) |
||||
->where("status", AllocationDormitoryBed::STATUS_YES) |
||||
->distinct() |
||||
->get("building_id")->toArray(); |
||||
if (empty($building)) { |
||||
return []; |
||||
} |
||||
$Building = Building::query()->whereIn("id", $building)->get(["id", DB::raw('building_title as text')])->toarray(); |
||||
$data = []; |
||||
foreach ($Building as $v) { |
||||
$data[] = [ |
||||
"id" => json_encode([ |
||||
"multiple_worlds" => $living_quarters["multiple_worlds"], |
||||
"dormitory_type" => $living_quarters["dormitory_type"], |
||||
"living_area" => $living_quarters["living_area"], |
||||
"building" => $v["id"], |
||||
"sex" => $living_quarters["sex"], |
||||
"speciality_id" => $living_quarters["speciality_id"], |
||||
]), |
||||
"text" => $v["text"] |
||||
]; |
||||
} |
||||
return $data; |
||||
} |
||||
|
||||
/** |
||||
* 获取楼层(联动) |
||||
* @param Request $request |
||||
* @return array |
||||
*/ |
||||
public function getFloorLoad(Request $request) |
||||
{ |
||||
$building = json_decode($request->get("q"), 1); |
||||
if (empty($building)) { |
||||
return []; |
||||
} |
||||
//取出当前年份 |
||||
$config = Config::query()->where([ |
||||
"unique_identification" => "annual_session" |
||||
])->first(); |
||||
$floor_id = AllocationDormitoryBed::query() |
||||
->where("living_area", $building["living_area"]) |
||||
->where("multiple_worlds", $building["multiple_worlds"]) |
||||
->where("dormitory_type", $building["dormitory_type"]) |
||||
->where("building_id", $building["building"]) |
||||
->where("sex", $building["sex"]) |
||||
->where("speciality_id", $building["speciality_id"]) |
||||
->where("annual_session", $config->data) |
||||
->where("status", AllocationDormitoryBed::STATUS_YES) |
||||
->distinct() |
||||
->get("floor_id")->toArray(); |
||||
if (empty($floor_id)) { |
||||
return []; |
||||
} |
||||
$Building = Floor::query()->whereIn("id", $floor_id)->get(["id", DB::raw('floor_title as text')])->toarray(); |
||||
$data = []; |
||||
foreach ($Building as $v) { |
||||
$data[] = [ |
||||
"id" => json_encode([ |
||||
"multiple_worlds" => $building["multiple_worlds"], |
||||
"dormitory_type" => $building["dormitory_type"], |
||||
"living_area" => $building["living_area"], |
||||
"building" => $building["building"], |
||||
"floor" => $v["id"], |
||||
"sex" => $building["sex"], |
||||
"speciality_id" => $building["speciality_id"], |
||||
]), |
||||
"text" => $v["text"] |
||||
]; |
||||
} |
||||
return $data; |
||||
} |
||||
|
||||
/** |
||||
* 获取宿舍号(联动) |
||||
* @param Request $request |
||||
* @return array |
||||
*/ |
||||
public function getDormitoryNumberLoad(Request $request) |
||||
{ |
||||
$floor = json_decode($request->get("q"), 1); |
||||
if (empty($floor)) { |
||||
return []; |
||||
} |
||||
//取出当前年份 |
||||
$config = Config::query()->where([ |
||||
"unique_identification" => "annual_session" |
||||
])->first(); |
||||
$dormitory_number = AllocationDormitoryBed::query() |
||||
->where("living_area", $floor["living_area"]) |
||||
->where("multiple_worlds", $floor["multiple_worlds"]) |
||||
->where("dormitory_type", $floor["dormitory_type"]) |
||||
->where("building_id", $floor["building"]) |
||||
->where("floor_id", $floor["floor"]) |
||||
->where("sex", $floor["sex"]) |
||||
->where("speciality_id", $floor["speciality_id"]) |
||||
->where("annual_session", $config->data) |
||||
->where("status", AllocationDormitoryBed::STATUS_YES) |
||||
->distinct() |
||||
->get("dormitory_number")->toArray(); |
||||
if (empty($dormitory_number)) { |
||||
return []; |
||||
} |
||||
$DormitoryNumber = DormitoryNumber::query()->whereIn("id", $dormitory_number)->get(["id", DB::raw('dormitory_number as text')])->toarray(); |
||||
$data = []; |
||||
foreach ($DormitoryNumber as $v) { |
||||
$data[] = [ |
||||
"id" => json_encode([ |
||||
"multiple_worlds" => $floor["multiple_worlds"], |
||||
"dormitory_type" => $floor["dormitory_type"], |
||||
"living_area" => $floor["living_area"], |
||||
"building" => $floor["building"], |
||||
"floor" => $floor["floor"], |
||||
"dormitory_number" => $v["id"], |
||||
"sex" => $floor["sex"], |
||||
"speciality_id" => $floor["speciality_id"], |
||||
]), |
||||
"text" => $v["text"] |
||||
]; |
||||
} |
||||
return $data; |
||||
} |
||||
|
||||
/** |
||||
* 获取床号(联动) |
||||
* @param Request $request |
||||
* @return array |
||||
*/ |
||||
public function getBedLoad(Request $request) |
||||
{ |
||||
$dormitory_number = json_decode($request->get("q"), 1); |
||||
if (empty($dormitory_number)) { |
||||
return []; |
||||
} |
||||
//取出当前年份 |
||||
$config = Config::query()->where([ |
||||
"unique_identification" => "annual_session" |
||||
])->first(); |
||||
$bed = AllocationDormitoryBed::query() |
||||
->where("living_area", $dormitory_number["living_area"]) |
||||
->where("multiple_worlds", $dormitory_number["multiple_worlds"]) |
||||
->where("dormitory_type", $dormitory_number["dormitory_type"]) |
||||
->where("building_id", $dormitory_number["building"]) |
||||
->where("floor_id", $dormitory_number["floor"]) |
||||
->where("dormitory_number", $dormitory_number["dormitory_number"]) |
||||
->where("sex", $dormitory_number["sex"]) |
||||
->where("speciality_id", $dormitory_number["speciality_id"]) |
||||
->where("annual_session", $config->data) |
||||
->where("status", AllocationDormitoryBed::STATUS_YES) |
||||
->distinct() |
||||
->get("bed_id")->toArray(); |
||||
if (empty($bed)) { |
||||
return []; |
||||
} |
||||
$DormitoryNumber = Bed::query()->whereIn("id", $bed)->get(["id", DB::raw('bed_number as text')])->toarray(); |
||||
|
||||
$data = []; |
||||
foreach ($DormitoryNumber as $v) { |
||||
|
||||
//检测当前床位是否被选择 |
||||
$bedInfo = AllocationDormitoryBed::query() |
||||
->where("living_area", $dormitory_number["living_area"]) |
||||
->where("multiple_worlds", $dormitory_number["multiple_worlds"]) |
||||
->where("dormitory_type", $dormitory_number["dormitory_type"]) |
||||
->where("building_id", $dormitory_number["building"]) |
||||
->where("floor_id", $dormitory_number["floor"]) |
||||
->where("dormitory_number", $dormitory_number["dormitory_number"]) |
||||
->where("bed_id", $v["id"]) |
||||
->first(); |
||||
if (empty($bedInfo)) { |
||||
$data[] = [ |
||||
"id" => json_encode([ |
||||
"multiple_worlds" => $dormitory_number["multiple_worlds"], |
||||
"dormitory_type" => $dormitory_number["dormitory_type"], |
||||
"living_area" => $dormitory_number["living_area"], |
||||
"building" => $dormitory_number["building"], |
||||
"floor" => $dormitory_number["floor"], |
||||
"dormitory_number" => $dormitory_number["dormitory_number"], |
||||
"id" => $v["id"], |
||||
"sex" => $dormitory_number["sex"], |
||||
"speciality_id" => $dormitory_number["speciality_id"], |
||||
]), |
||||
"text" => $v["text"] . "(以上条件下未分配床位)" |
||||
]; |
||||
continue; |
||||
} |
||||
|
||||
$selectedInfo = SelectedDormitory::query()->where([ |
||||
"allocation_dormitory_id" => $bedInfo->id, |
||||
"status" => SelectedDormitory::STATUS_YES |
||||
])->first(); |
||||
|
||||
if (empty($selectedInfo)) { |
||||
$data[] = [ |
||||
"id" => json_encode([ |
||||
"multiple_worlds" => $dormitory_number["multiple_worlds"], |
||||
"dormitory_type" => $dormitory_number["dormitory_type"], |
||||
"living_area" => $dormitory_number["living_area"], |
||||
"building" => $dormitory_number["building"], |
||||
"floor" => $dormitory_number["floor"], |
||||
"dormitory_number" => $dormitory_number["dormitory_number"], |
||||
"id" => $v["id"] |
||||
]), |
||||
"text" => $v["text"] . "(可分配)" |
||||
]; |
||||
} else { |
||||
$data[] = [ |
||||
"id" => json_encode([ |
||||
"multiple_worlds" => $dormitory_number["multiple_worlds"], |
||||
"dormitory_type" => $dormitory_number["dormitory_type"], |
||||
"living_area" => $dormitory_number["living_area"], |
||||
"building" => $dormitory_number["building"], |
||||
"floor" => $dormitory_number["floor"], |
||||
"dormitory_number" => $dormitory_number["dormitory_number"], |
||||
"id" => $v["id"] |
||||
]), |
||||
"text" => $v["text"] . "(不可分配)" |
||||
]; |
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
return $data; |
||||
} |
||||
} |
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests; |
||||
use Illuminate\Foundation\Bus\DispatchesJobs; |
||||
use Illuminate\Foundation\Validation\ValidatesRequests; |
||||
use Illuminate\Routing\Controller as BaseController; |
||||
|
||||
class Controller extends BaseController |
||||
{ |
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests; |
||||
} |
@ -0,0 +1,67 @@
@@ -0,0 +1,67 @@
|
||||
<?php |
||||
|
||||
namespace App\Http; |
||||
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel; |
||||
|
||||
class Kernel extends HttpKernel |
||||
{ |
||||
/** |
||||
* The application's global HTTP middleware stack. |
||||
* |
||||
* These middleware are run during every request to your application. |
||||
* |
||||
* @var array<int, class-string|string> |
||||
*/ |
||||
protected $middleware = [ |
||||
// \App\Http\Middleware\TrustHosts::class, |
||||
\App\Http\Middleware\TrustProxies::class, |
||||
\Fruitcake\Cors\HandleCors::class, |
||||
\App\Http\Middleware\PreventRequestsDuringMaintenance::class, |
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, |
||||
\App\Http\Middleware\TrimStrings::class, |
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, |
||||
]; |
||||
|
||||
/** |
||||
* The application's route middleware groups. |
||||
* |
||||
* @var array<string, array<int, class-string|string>> |
||||
*/ |
||||
protected $middlewareGroups = [ |
||||
'web' => [ |
||||
\App\Http\Middleware\EncryptCookies::class, |
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, |
||||
\Illuminate\Session\Middleware\StartSession::class, |
||||
// \Illuminate\Session\Middleware\AuthenticateSession::class, |
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class, |
||||
\App\Http\Middleware\VerifyCsrfToken::class, |
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class, |
||||
], |
||||
|
||||
'api' => [ |
||||
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class, |
||||
'throttle:api', |
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class, |
||||
], |
||||
]; |
||||
|
||||
/** |
||||
* The application's route middleware. |
||||
* |
||||
* These middleware may be assigned to groups or used individually. |
||||
* |
||||
* @var array<string, class-string|string> |
||||
*/ |
||||
protected $routeMiddleware = [ |
||||
'auth' => \App\Http\Middleware\Authenticate::class, |
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, |
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, |
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class, |
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, |
||||
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, |
||||
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, |
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, |
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, |
||||
]; |
||||
} |
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Middleware; |
||||
|
||||
use Illuminate\Auth\Middleware\Authenticate as Middleware; |
||||
|
||||
class Authenticate extends Middleware |
||||
{ |
||||
/** |
||||
* Get the path the user should be redirected to when they are not authenticated. |
||||
* |
||||
* @param \Illuminate\Http\Request $request |
||||
* @return string|null |
||||
*/ |
||||
protected function redirectTo($request) |
||||
{ |
||||
if (! $request->expectsJson()) { |
||||
return route('login'); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Middleware; |
||||
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware; |
||||
|
||||
class EncryptCookies extends Middleware |
||||
{ |
||||
/** |
||||
* The names of the cookies that should not be encrypted. |
||||
* |
||||
* @var array<int, string> |
||||
*/ |
||||
protected $except = [ |
||||
// |
||||
]; |
||||
} |
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Middleware; |
||||
|
||||
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware; |
||||
|
||||
class PreventRequestsDuringMaintenance extends Middleware |
||||
{ |
||||
/** |
||||
* The URIs that should be reachable while maintenance mode is enabled. |
||||
* |
||||
* @var array<int, string> |
||||
*/ |
||||
protected $except = [ |
||||
// |
||||
]; |
||||
} |
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Middleware; |
||||
|
||||
use App\Providers\RouteServiceProvider; |
||||
use Closure; |
||||
use Illuminate\Http\Request; |
||||
use Illuminate\Support\Facades\Auth; |
||||
|
||||
class RedirectIfAuthenticated |
||||
{ |
||||
/** |
||||
* Handle an incoming request. |
||||
* |
||||
* @param \Illuminate\Http\Request $request |
||||
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next |
||||
* @param string|null ...$guards |
||||
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse |
||||
*/ |
||||
public function handle(Request $request, Closure $next, ...$guards) |
||||
{ |
||||
$guards = empty($guards) ? [null] : $guards; |
||||
|
||||
foreach ($guards as $guard) { |
||||
if (Auth::guard($guard)->check()) { |
||||
return redirect(RouteServiceProvider::HOME); |
||||
} |
||||
} |
||||
|
||||
return $next($request); |
||||
} |
||||
} |
@ -0,0 +1,19 @@
@@ -0,0 +1,19 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Middleware; |
||||
|
||||
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware; |
||||
|
||||
class TrimStrings extends Middleware |
||||
{ |
||||
/** |
||||
* The names of the attributes that should not be trimmed. |
||||
* |
||||
* @var array<int, string> |
||||
*/ |
||||
protected $except = [ |
||||
'current_password', |
||||
'password', |
||||
'password_confirmation', |
||||
]; |
||||
} |
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Middleware; |
||||
|
||||
use Illuminate\Http\Middleware\TrustHosts as Middleware; |
||||
|
||||
class TrustHosts extends Middleware |
||||
{ |
||||
/** |
||||
* Get the host patterns that should be trusted. |
||||
* |
||||
* @return array<int, string|null> |
||||
*/ |
||||
public function hosts() |
||||
{ |
||||
return [ |
||||
$this->allSubdomainsOfApplicationUrl(), |
||||
]; |
||||
} |
||||
} |
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Middleware; |
||||
|
||||
use Illuminate\Http\Middleware\TrustProxies as Middleware; |
||||
use Illuminate\Http\Request; |
||||
|
||||
class TrustProxies extends Middleware |
||||
{ |
||||
/** |
||||
* The trusted proxies for this application. |
||||
* |
||||
* @var array<int, string>|string|null |
||||
*/ |
||||
protected $proxies; |
||||
|
||||
/** |
||||
* The headers that should be used to detect proxies. |
||||
* |
||||
* @var int |
||||
*/ |
||||
protected $headers = |
||||
Request::HEADER_X_FORWARDED_FOR | |
||||
Request::HEADER_X_FORWARDED_HOST | |
||||
Request::HEADER_X_FORWARDED_PORT | |
||||
Request::HEADER_X_FORWARDED_PROTO | |
||||
Request::HEADER_X_FORWARDED_AWS_ELB; |
||||
} |
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Middleware; |
||||
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware; |
||||
|
||||
class VerifyCsrfToken extends Middleware |
||||
{ |
||||
/** |
||||
* The URIs that should be excluded from CSRF verification. |
||||
* |
||||
* @var array<int, string> |
||||
*/ |
||||
protected $except = [ |
||||
// |
||||
]; |
||||
} |
@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
|
||||
<?php |
||||
|
||||
|
||||
namespace App\Imports; |
||||
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets; |
||||
|
||||
class BedDataExcel implements WithMultipleSheets |
||||
{ |
||||
private $round; |
||||
|
||||
public function __construct(int $round) |
||||
{ |
||||
$this->round = $round; |
||||
} |
||||
|
||||
public function sheets(): array |
||||
{ |
||||
return [ |
||||
new BedFirstSheetImport($this->round), |
||||
]; |
||||
|
||||
} |
||||
} |
@ -0,0 +1,240 @@
@@ -0,0 +1,240 @@
|
||||
<?php |
||||
|
||||
namespace App\Imports; |
||||
use App\Models\AllocationDormitoryBed; |
||||
use App\Models\Bed; |
||||
use App\Models\Building; |
||||
use App\Models\Config; |
||||
use App\Models\DormitoryNumber; |
||||
use App\Models\DormitoryType; |
||||
use App\Models\Floor; |
||||
use App\Models\LivingArea; |
||||
use App\Models\MultipleWorld; |
||||
use App\Models\SecondaryCollege; |
||||
use App\Models\Speciality; |
||||
use Illuminate\Support\Collection; |
||||
use Illuminate\Database\Eloquent\Model; |
||||
use Maatwebsite\Excel\Concerns\ToModel; |
||||
use Maatwebsite\Excel\Concerns\ToCollection; |
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow; |
||||
use Maatwebsite\Excel\Concerns\WithBatchInserts; |
||||
use Maatwebsite\Excel\Concerns\WithChunkReading; |
||||
use Maatwebsite\Excel\Imports\HeadingRowFormatter; |
||||
use Illuminate\Support\Facades\DB; |
||||
|
||||
HeadingRowFormatter:: |
||||
default('none'); |
||||
|
||||
class BedFirstSheetImport implements ToCollection, WithBatchInserts, WithChunkReading, WithHeadingRow, ToModel |
||||
{ |
||||
private $round; |
||||
|
||||
public function __construct(int $round) |
||||
{ |
||||
$this->round = $round; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* @param array $row |
||||
* |
||||
* @return Model|Model[]|null |
||||
*/ |
||||
public function model(array $row) |
||||
{ |
||||
|
||||
//写导入的逻辑关系 |
||||
// $user = Orderuser::where('phone', '=', $row['电话'])->where('name', '=',$row['姓名'])->first(); |
||||
|
||||
// dd($row); |
||||
// // 数据库对应的字段 |
||||
return null; |
||||
} |
||||
|
||||
public function collection(Collection $rows) |
||||
{ |
||||
//导入的表格所有数据都在此处显示 |
||||
$list = $rows->toArray(); |
||||
if(empty($list)){ |
||||
throw new \Exception("请勿上传空文件"); |
||||
} |
||||
|
||||
//取出当前年份 |
||||
$config = Config::query()->where([ |
||||
"unique_identification" => "annual_session" |
||||
])->first(); |
||||
if(empty($config)){ |
||||
throw new \Exception("相关配置信息不能为空"); |
||||
} |
||||
|
||||
//取出所有二级学院 |
||||
$secondaryCollegeList = SecondaryCollege::query()->where([ |
||||
"status" => SecondaryCollege::STATUS_YES |
||||
])->get()->toArray(); |
||||
if(empty($secondaryCollegeList)){ |
||||
throw new \Exception("识别失败,二级学院信息为空"); |
||||
} |
||||
|
||||
//以学院名作为键 |
||||
$secondaryCollegeList = array_column($secondaryCollegeList, null, "name"); |
||||
|
||||
//宿舍类型 |
||||
$dormitoryTypeList = DormitoryType::query()->where([ |
||||
"status" => DormitoryType::STATUS_YES |
||||
])->get()->toArray(); |
||||
if(empty($dormitoryTypeList)){ |
||||
throw new \Exception("识别失败,宿舍类型信息为空"); |
||||
} |
||||
$dormitoryTypeList = array_column($dormitoryTypeList, null, "dormitory"); |
||||
|
||||
//生活区 |
||||
$livingAreaList = LivingArea::query()->where([ |
||||
"status" => LivingArea::STATUS_YES |
||||
])->get()->toArray(); |
||||
if(empty($livingAreaList)){ |
||||
throw new \Exception("识别失败,生活区信息为空"); |
||||
} |
||||
$livingAreaList = array_column($livingAreaList, null, "title"); |
||||
|
||||
//楼栋 |
||||
$buildingList = Building::query()->where([ |
||||
"status" => Building::STATUS_YES |
||||
])->get()->toArray(); |
||||
if(empty($buildingList)){ |
||||
throw new \Exception("识别失败,楼栋信息为空"); |
||||
} |
||||
$buildingList = array_column($buildingList, null, "building_title"); |
||||
|
||||
//楼层 |
||||
$floorList = Floor::query()->where([ |
||||
"status" => Floor::STATUS_YES |
||||
])->get()->toArray(); |
||||
if(empty($floorList)){ |
||||
throw new \Exception("识别失败,楼层信息为空"); |
||||
} |
||||
$floorList = array_column($floorList, null, "floor_title"); |
||||
|
||||
//宿舍号 |
||||
$dormitoryNumberList = DormitoryNumber::query()->where([ |
||||
"status" => DormitoryNumber::STATUS_YES |
||||
])->get()->toArray(); |
||||
if(empty($dormitoryNumberList)){ |
||||
throw new \Exception("识别失败,宿舍号信息为空"); |
||||
} |
||||
$dormitoryNumberList = array_column($dormitoryNumberList, null, "dormitory_number"); |
||||
|
||||
//床位 |
||||
$bedList = Bed::query()->where([ |
||||
"status" => Bed::STATUS_YES |
||||
])->get()->toArray(); |
||||
if(empty($bedList)){ |
||||
throw new \Exception("识别失败,床位信息为空"); |
||||
} |
||||
$bedList = array_column($bedList, null, "bed_number"); |
||||
|
||||
//入库 |
||||
$insertData = []; |
||||
|
||||
foreach($list as $key => $item){ |
||||
$arr = [ |
||||
"create_time" => time(), |
||||
"annual_session" => $config->data |
||||
]; |
||||
|
||||
//检测性别 |
||||
if(trim($item["男女生宿舍"]) == "男"){ |
||||
$arr["sex"] = 1; |
||||
}else if(trim($item["男女生宿舍"]) == "女"){ |
||||
$arr["sex"] = 2; |
||||
} |
||||
|
||||
//初识化专业id |
||||
$speciality_id = 0; |
||||
|
||||
//取出指定学院下面的专业 |
||||
$specialityInfo = Speciality::query()->where([ |
||||
"secondary_college_id" => $secondaryCollegeList[trim($item["二级学院"])]["id"], |
||||
"speciality_name" => trim($item["专业名称"]), |
||||
"status" => Speciality::STATUS_YES |
||||
])->first(); |
||||
if(!empty($specialityInfo)){ |
||||
$speciality_id = $specialityInfo->id; |
||||
} |
||||
|
||||
//专业ID为空时提示 |
||||
if(empty($speciality_id)){ |
||||
throw new \Exception("识别失败,请检查二级学院或专业名称是否和后台录入的一致"); |
||||
} |
||||
//专业id |
||||
$arr["speciality_id"] = $speciality_id; |
||||
|
||||
//宿舍类型id |
||||
$arr["dormitory_type"] = $dormitoryTypeList[trim($item["宿舍类型"])]["id"]; |
||||
|
||||
//多人间 |
||||
$multipleWorlds = MultipleWorld::query()->where([ |
||||
"dormitory_type_id" => $dormitoryTypeList[trim($item["宿舍类型"])]["id"], |
||||
"people" => trim($item["多人间"]), |
||||
"status" => MultipleWorld::STATUS_YES |
||||
])->first(); |
||||
if(empty($multipleWorlds)){ |
||||
throw new \Exception("识别失败,多人间信息为空"); |
||||
} |
||||
|
||||
//多人间id |
||||
$arr["multiple_worlds"] = $multipleWorlds->id; |
||||
|
||||
//生活区id |
||||
$arr["living_area"] = $livingAreaList[trim($item["生活区"])]["id"]; |
||||
|
||||
|
||||
//楼栋id |
||||
$arr["building_id"] = $buildingList[trim($item["楼栋"])]["id"]; |
||||
|
||||
|
||||
//楼层id |
||||
$arr["floor_id"] = $floorList[trim($item["楼层"])]["id"]; |
||||
|
||||
|
||||
//宿舍号id |
||||
$arr["dormitory_number"] = $dormitoryNumberList[trim($item["宿舍号"])]["id"]; |
||||
|
||||
//床位id |
||||
$arr["bed_id"] = $bedList[trim($item["床位号"])]["id"]; |
||||
|
||||
array_push($insertData, $arr); |
||||
} |
||||
|
||||
DB::beginTransaction(); |
||||
try { |
||||
|
||||
$chunk_list = array_chunk($insertData, 1000); |
||||
|
||||
foreach ($chunk_list as $new_list) { |
||||
$add = AllocationDormitoryBed::query()->insert($new_list); |
||||
if($add != count($insertData)){ |
||||
throw new \Exception("导入数据失败,请重试"); |
||||
} |
||||
} |
||||
|
||||
DB::commit(); |
||||
}catch (\Exception $e){ |
||||
DB::rollBack(); |
||||
throw new \Exception("导入数据失败,请重试"); |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
//批量导入1000条 |
||||
public function batchSize(): int |
||||
{ |
||||
return 1000; |
||||
} |
||||
|
||||
//以1000条数据基准切割数据 |
||||
public function chunkSize(): int |
||||
{ |
||||
return 1000; |
||||
} |
||||
} |
@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
|
||||
<?php |
||||
|
||||
|
||||
namespace App\Imports; |
||||
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets; |
||||
|
||||
class DataExcel implements WithMultipleSheets |
||||
{ |
||||
private $round; |
||||
|
||||
public function __construct(int $round) |
||||
{ |
||||
$this->round = $round; |
||||
} |
||||
|
||||
public function sheets(): array |
||||
{ |
||||
return [ |
||||
new FirstSheetImport($this->round), |
||||
]; |
||||
|
||||
} |
||||
} |
@ -0,0 +1,158 @@
@@ -0,0 +1,158 @@
|
||||
<?php |
||||
|
||||
namespace App\Imports; |
||||
use App\Models\AdmissionNewStudents; |
||||
use App\Models\Config; |
||||
use App\Models\SecondaryCollege; |
||||
use App\Models\Speciality; |
||||
use Illuminate\Support\Collection; |
||||
use Illuminate\Database\Eloquent\Model; |
||||
use Maatwebsite\Excel\Concerns\ToModel; |
||||
use Maatwebsite\Excel\Concerns\ToCollection; |
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow; |
||||
use Maatwebsite\Excel\Concerns\WithBatchInserts; |
||||
use Maatwebsite\Excel\Concerns\WithChunkReading; |
||||
use Maatwebsite\Excel\Imports\HeadingRowFormatter; |
||||
use Illuminate\Support\Facades\DB; |
||||
use Throwable; |
||||
HeadingRowFormatter:: |
||||
default('none'); |
||||
|
||||
class FirstSheetImport implements ToCollection, WithBatchInserts, WithChunkReading, WithHeadingRow, ToModel |
||||
{ |
||||
private $round; |
||||
|
||||
public function __construct(int $round) |
||||
{ |
||||
$this->round = $round; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* @param array $row |
||||
* |
||||
* @return Model|Model[]|null |
||||
*/ |
||||
public function model(array $row) |
||||
{ |
||||
|
||||
//写导入的逻辑关系 |
||||
// $user = Orderuser::where('phone', '=', $row['电话'])->where('name', '=',$row['姓名'])->first(); |
||||
|
||||
// dd($row); |
||||
// // 数据库对应的字段 |
||||
return null; |
||||
} |
||||
|
||||
public function collection(Collection $rows) |
||||
{ |
||||
//导入的表格所有数据都在此处显示 |
||||
$list = $rows->toArray(); |
||||
if(empty($list)){ |
||||
throw new \Exception("请勿上传空文件"); |
||||
} |
||||
|
||||
//取出当前年份 |
||||
$config = Config::query()->where([ |
||||
"unique_identification" => "annual_session" |
||||
])->first(); |
||||
if(empty($config)){ |
||||
throw new \Exception("相关配置信息不能为空"); |
||||
} |
||||
|
||||
//入库 |
||||
$insertData = []; |
||||
|
||||
foreach($list as $key => $item){ |
||||
$arr = [ |
||||
"mobile" => trim($item["手机号"]), |
||||
"name" => trim($item["姓名"]), |
||||
"idCard" => trim($item["身份证"]), |
||||
"admission_college" => trim($item["录取学院"]), |
||||
"admitted_major" => trim($item["录取专业"]), |
||||
"create_time" => time(), |
||||
"annual_session" => $config->data |
||||
]; |
||||
//检测性别 |
||||
if(trim($item["性别"]) == "男"){ |
||||
$arr["sex"] = 1; |
||||
}else if(trim($item["性别"]) == "女"){ |
||||
$arr["sex"] = 2; |
||||
} |
||||
|
||||
if(!empty($item["复学类型"])){ |
||||
if(trim($item["复学类型"]) == "退伍复学"){ |
||||
$arr["resuming_school"] = 1; |
||||
}else if(trim($item["复学类型"]) == "普通复学"){ |
||||
$arr["resuming_school"] = 2; |
||||
} |
||||
} |
||||
|
||||
//检测专业 |
||||
//取出所有二级学院 |
||||
$secondaryCollegeList = SecondaryCollege::query()->where([ |
||||
"status" => SecondaryCollege::STATUS_YES |
||||
])->get()->toArray(); |
||||
if(empty($secondaryCollegeList)){ |
||||
throw new \Exception("识别失败,二级学院信息为空"); |
||||
} |
||||
|
||||
//以学院名作为键 |
||||
$secondaryCollegeList = array_column($secondaryCollegeList, null, "name"); |
||||
|
||||
//初识化专业id |
||||
$speciality_id = 0; |
||||
|
||||
//取出指定学院下面的专业 |
||||
$specialityInfo = Speciality::query()->where([ |
||||
"secondary_college_id" => $secondaryCollegeList[trim($item["录取学院"])]["id"], |
||||
"speciality_name" => trim($item["录取专业"]), |
||||
"status" => Speciality::STATUS_YES |
||||
])->first(); |
||||
if(!empty($specialityInfo)){ |
||||
$speciality_id = $specialityInfo->id; |
||||
} |
||||
|
||||
//专业ID为空时提示 |
||||
if(empty($speciality_id)){ |
||||
throw new \Exception("识别失败,请检查二级学院或专业名称是否和后台录入的一致"); |
||||
} |
||||
|
||||
$arr["speciality_id"] = $speciality_id; |
||||
|
||||
array_push($insertData, $arr); |
||||
} |
||||
|
||||
DB::beginTransaction(); |
||||
try { |
||||
|
||||
$chunk_list = array_chunk($insertData, 1000); |
||||
|
||||
foreach ($chunk_list as $new_list) { |
||||
$add = AdmissionNewStudents::query()->insert($new_list); |
||||
if($add != count($insertData)){ |
||||
throw new \Exception("导入数据失败,请重试"); |
||||
} |
||||
} |
||||
|
||||
DB::commit(); |
||||
}catch (\Exception $e){ |
||||
DB::rollBack(); |
||||
throw new \Exception("导入数据失败,请重试"); |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
//批量导入1000条 |
||||
public function batchSize(): int |
||||
{ |
||||
return 1000; |
||||
} |
||||
|
||||
//以1000条数据基准切割数据 |
||||
public function chunkSize(): int |
||||
{ |
||||
return 1000; |
||||
} |
||||
} |
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Dcat\Admin\Traits\HasDateTimeFormatter; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class AdmissionGuide extends Model |
||||
{ |
||||
use HasDateTimeFormatter; |
||||
protected $table = 'admission_guide'; |
||||
public $timestamps = false; |
||||
|
||||
} |
@ -0,0 +1,22 @@
@@ -0,0 +1,22 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Dcat\Admin\Traits\HasDateTimeFormatter; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class AdmissionNewStudents extends Model |
||||
{ |
||||
use HasDateTimeFormatter; |
||||
protected $table = 'admission_new_students'; |
||||
public $timestamps = false; |
||||
|
||||
const REGISTER_YES = 2; //已注册 |
||||
const REGISTER_NO = 1; //未注册 |
||||
|
||||
//复学类型:0普通学生 1退伍复学 2普通复学 |
||||
const RESUMING_SCHOOL_ZERO = 0; |
||||
const RESUMING_SCHOOL_ONE = 1; |
||||
const RESUMING_SCHOOL_TWO = 2; |
||||
} |
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Dcat\Admin\Traits\HasDateTimeFormatter; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class AllocationDormitoryBed extends Model |
||||
{ |
||||
use HasDateTimeFormatter; |
||||
protected $table = 'allocation_dormitory_bed'; |
||||
public $timestamps = false; |
||||
|
||||
const STATUS_YES = 1; //正常 |
||||
const STATUS_NO = 2; //禁用 |
||||
} |
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Dcat\Admin\Traits\HasDateTimeFormatter; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class BasicFamilyInformation extends Model |
||||
{ |
||||
use HasDateTimeFormatter; |
||||
protected $table = 'basic_family_information'; |
||||
public $timestamps = false; |
||||
|
||||
} |
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Dcat\Admin\Traits\HasDateTimeFormatter; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class Bed extends Model |
||||
{ |
||||
use HasDateTimeFormatter; |
||||
protected $table = 'bed'; |
||||
public $timestamps = false; |
||||
|
||||
const STATUS_YES = 1; |
||||
const STATUS_NO = 2; |
||||
} |
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Dcat\Admin\Traits\HasDateTimeFormatter; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class Building extends Model |
||||
{ |
||||
use HasDateTimeFormatter; |
||||
protected $table = 'building'; |
||||
public $timestamps = false; |
||||
|
||||
const STATUS_YES = 1; |
||||
const STATUS_NO = 2; |
||||
} |
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Dcat\Admin\Traits\HasDateTimeFormatter; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class CompletedOfflineStep extends Model |
||||
{ |
||||
use HasDateTimeFormatter; |
||||
protected $table = 'completed_offline_step'; |
||||
public $timestamps = false; |
||||
|
||||
} |
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Dcat\Admin\Traits\HasDateTimeFormatter; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class CompletedStep extends Model |
||||
{ |
||||
use HasDateTimeFormatter; |
||||
protected $table = 'completed_step'; |
||||
public $timestamps = false; |
||||
|
||||
} |
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Dcat\Admin\Traits\HasDateTimeFormatter; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class Config extends Model |
||||
{ |
||||
use HasDateTimeFormatter; |
||||
protected $table = 'config'; |
||||
public $timestamps = false; |
||||
|
||||
} |
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Dcat\Admin\Traits\HasDateTimeFormatter; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class DormitoryNumber extends Model |
||||
{ |
||||
use HasDateTimeFormatter; |
||||
protected $table = 'dormitory_number'; |
||||
public $timestamps = false; |
||||
|
||||
const STATUS_YES = 1; |
||||
const STATUS_NO = 2; |
||||
} |
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Dcat\Admin\Traits\HasDateTimeFormatter; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class DormitoryType extends Model |
||||
{ |
||||
use HasDateTimeFormatter; |
||||
protected $table = 'dormitory_type'; |
||||
public $timestamps = false; |
||||
|
||||
const STATUS_YES = 1; |
||||
const STATUS_NO = 2; |
||||
|
||||
} |
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Dcat\Admin\Traits\HasDateTimeFormatter; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class Floor extends Model |
||||
{ |
||||
use HasDateTimeFormatter; |
||||
protected $table = 'floor'; |
||||
public $timestamps = false; |
||||
|
||||
const STATUS_YES = 1; |
||||
const STATUS_NO = 2; |
||||
} |
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Dcat\Admin\Traits\HasDateTimeFormatter; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class LivingArea extends Model |
||||
{ |
||||
use HasDateTimeFormatter; |
||||
protected $table = 'living_area'; |
||||
public $timestamps = false; |
||||
|
||||
const STATUS_YES = 1; |
||||
const STATUS_NO = 2; |
||||
} |
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Dcat\Admin\Traits\HasDateTimeFormatter; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class MultipleWorld extends Model |
||||
{ |
||||
use HasDateTimeFormatter; |
||||
protected $table = 'multiple_worlds'; |
||||
public $timestamps = false; |
||||
|
||||
const STATUS_YES = 1; |
||||
const STATUS_NO = 2; |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue