123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- <?php
- namespace App\Admin\Controllers\Person;
- use App\Models\membersProject;
- use App\Http\Controllers\Controller;
- use Encore\Admin\Controllers\HasResourceActions;
- use Encore\Admin\Form;
- use Encore\Admin\Grid;
- use Encore\Admin\Layout\Content;
- use Encore\Admin\Show;
- class MembersProjectController extends Controller
- {
- use HasResourceActions;
- /**
- * Index interface.
- *
- * @param Content $content
- * @return Content
- */
- public function index(Content $content)
- {
- return $content
- ->header('创业项目')
- ->description(' ')
- ->body($this->grid());
- }
- /**
- * Show interface.
- *
- * @param mixed $id
- * @param Content $content
- * @return Content
- */
- public function show($id, Content $content)
- {
- return $content
- ->header('Detail')
- ->description('description')
- ->body($this->detail($id));
- }
- /**
- * Edit interface.
- *
- * @param mixed $id
- * @param Content $content
- * @return Content
- */
- public function edit($id, Content $content)
- {
- return $content
- ->header('Edit')
- ->description('description')
- ->body($this->form()->edit($id));
- }
- /**
- * Create interface.
- *
- * @param Content $content
- * @return Content
- */
- public function create(Content $content)
- {
- return $content
- ->header('Create')
- ->description('description')
- ->body($this->form());
- }
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- $grid = new Grid(new membersProject);
- $grid->model()->orderBy('id', 'desc');
- $grid->project_title('创业项目');
- $grid->project_intro('项目介绍');
- $grid->link_man('联系人');
- $grid->link_phone('联系电话');
- $grid->link_email('联系邮箱');
- $grid->actions(function ($actions) {
- $actions->disableDelete();//屏蔽删除按钮
- $actions->disableEdit();//屏蔽编辑按钮
- $actions->disableView(false);//屏蔽查看按钮
- });
- $grid->filter(function ($filter) {
- // $filter->equal('id', 'ID');
- $filter->like('project_title', '标题');
- $filter->like('link_man', '联系人');
- $filter->like('link_phone', '联系电话');
- $date3 = date('Y-m-d', strtotime("-3 day"));
- $date7 = date('Y-m-d', strtotime("-7 day"));
- $date30 = date("Y-m-d", strtotime("-1 month"));
- $date180 = date("Y-m-d", strtotime("-6 month"));
- $date360 = date("Y-m-d", strtotime("-1 year"));
- $date_option = array(
- '' => '不限',
- $date3 => '三天内',
- $date7 => '一周内',
- $date30 => '一月内',
- $date180 => '半年内',
- $date360 => '一年内',
- );
- $filter->where(function ($query) {
- $query->where('created_at', '>=', "{$this->input}");
- }, '添加时间', 'created_at')->radio($date_option);
- });
- return $grid;
- }
- /**
- * Make a show builder.
- *
- * @param mixed $id
- * @return Show
- */
- protected function detail($id)
- {
- $show = new Show(membersProject::findOrFail($id));
- $show->link_man('联系人');
- $show->link_phone('联系电话');
- $show->link_email('联系邮箱');
- $show->link_address('联系地址');
- $show->project_title('创业项目');
- $show->project_intro('项目介绍');
- $show->project_info('创业情况');
- $show->project_help('希望获得的帮助');
- $show->uid('用户id');
- $show->created_at('创建时间');
- $show->updated_at('修改时间');
- return $show;
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form()
- {
- $form = new Form(new membersProject);
- $form->display('ID');
- $form->display('Created at');
- $form->display('Updated at');
- return $form;
- }
- }
|