123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- <?php
- namespace App\Admin\Controllers\Pets;
- use App\Admin\Actions\Grid\PetsCommentsPassAction;
- use App\Admin\Repositories\Pets\WxPetsComment;
- use App\Wen\Utils\Settings;
- use Dcat\Admin\Form;
- use Dcat\Admin\Grid;
- use Dcat\Admin\Show;
- use Dcat\Admin\Http\Controllers\AdminController;
- class WxPetsCommentController extends AdminController
- {
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- return Grid::make(new WxPetsComment(), function (Grid $grid) {
- $grid->model()->orderBy('id', 'desc');
- $grid->column('id')->sortable();
- $grid->column('users', '头像')->display(function ($v) {
- return '<img src="' . ($this->user['user_avatar'] ?? Settings::get('img_default', 'https://img.mini.minisns.cn/icons/dafault.png')) . '" style="border-radius:50px;width:30px;" />';
- })->width('50px');
- $grid->column('user')->display(function ($v) {
- if($v && $v['user_name']){
- return '<a target="_blank" href="'.admin_url('users?id='.$v['id']).'">'.$v['user_name'].'</a>' ?? '用户已删除';
- }
- return '用户已删除';
- })->width('100px');
- $grid->column('pet_adoption_id');
- $grid->column('comment_id');
- $grid->column('comment_agent_id');
- $grid->column('comment_agent_name');
- $grid->column('comment_content')->limit(40);
- $grid->column('comment_img_url')->image('', 60, 60);
- // $grid->column('longitude');
- // $grid->column('latitude');
- // $grid->column('ip');
- // $grid->column('country');
- // $grid->column('province');
- // $grid->column('city');
- // $grid->column('district');
- $grid->column('comment_state', '状态')->using([0 => '待审核', 1 => '审核通过', 2 => '驳回'])->label([
- 0 => 'red',
- 1 => 'green',
- 2 => 'default'
- ]);
- // $grid->column('created_at');
- $grid->column('updated_at')->sortable();
- $grid->filter(function (Grid\Filter $filter) {
- $filter->equal('id');
- });
- $grid->batchActions(function ($batch) {
- $batch->add(new PetsCommentsPassAction());
- });
- });
- }
- /**
- * Make a show builder.
- *
- * @param mixed $id
- *
- * @return Show
- */
- protected function detail($id)
- {
- return Show::make($id, new WxPetsComment(), function (Show $show) {
- $show->field('id');
- $show->field('user_id');
- $show->field('pet_adoption_id');
- $show->field('comment_id');
- $show->field('comment_agent_id');
- $show->field('comment_agent_name');
- $show->field('comment_content');
- $show->field('comment_img_url');
- $show->field('longitude');
- $show->field('latitude');
- $show->field('ip');
- $show->field('country');
- $show->field('province');
- $show->field('city');
- $show->field('district');
- $show->field('comment_state');
- $show->field('created_at');
- $show->field('updated_at');
- });
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form()
- {
- return Form::make(new WxPetsComment(), function (Form $form) {
- $form->display('id');
- $form->text('user_id');
- $form->text('pet_adoption_id');
- $form->text('comment_id');
- $form->text('comment_agent_id');
- $form->text('comment_agent_name');
- $form->text('comment_content');
- $form->text('comment_img_url');
- $form->text('longitude');
- $form->text('latitude');
- $form->text('ip');
- $form->text('country');
- $form->text('province');
- $form->text('city');
- $form->text('district');
- $form->text('comment_state');
- $form->display('created_at');
- $form->display('updated_at');
- $form->deleting(function (Form $form){
- global $__MINI_GLOBAL_TENANT_ID__;
- if($__MINI_GLOBAL_TENANT_ID__ > 0){
- return $form->response()->error('权限不足,不可以删除其他分站对象');
- }
- });
- });
- }
- }
|