/home/techb158/immovalet.com/platform/plugins/contact/src/Tables
NameSizeModeActions
ContactTable.php50680644editdlrm
Edit: /home/techb158/immovalet.com/platform/plugins/contact/src/Tables/ContactTable.php (5068B)
repository = $contactRepository; if (!Auth::user()->hasAnyPermission(['contacts.edit', 'contacts.destroy'])) { $this->hasOperations = false; $this->hasActions = false; } } /** * {@inheritDoc} */ public function ajax() { $data = $this->table ->eloquent($this->query()) ->editColumn('name', function ($item) { if (!Auth::user()->hasPermission('contacts.edit')) { return $item->name; } return Html::link(route('contacts.edit', $item->id), $item->name); }) ->editColumn('checkbox', function ($item) { return $this->getCheckbox($item->id); }) ->editColumn('created_at', function ($item) { return BaseHelper::formatDate($item->created_at); }) ->editColumn('status', function ($item) { return $item->status->toHtml(); }) ->addColumn('operations', function ($item) { return $this->getOperations('contacts.edit', 'contacts.destroy', $item); }); return $this->toJson($data); } /** * {@inheritDoc} */ public function query() { $query = $this->repository->getModel()->select([ 'id', 'name', 'phone', 'email', 'created_at', 'status', ]); return $this->applyScopes($query); } /** * {@inheritDoc} */ public function columns() { return [ 'id' => [ 'title' => trans('core/base::tables.id'), 'width' => '20px', ], 'name' => [ 'title' => trans('core/base::tables.name'), 'class' => 'text-left', ], 'email' => [ 'title' => trans('plugins/contact::contact.tables.email'), 'class' => 'text-left', ], 'phone' => [ 'title' => trans('plugins/contact::contact.tables.phone'), ], 'created_at' => [ 'title' => trans('core/base::tables.created_at'), 'width' => '100px', ], 'status' => [ 'title' => trans('core/base::tables.status'), 'width' => '100px', ], ]; } /** * {@inheritDoc} */ public function bulkActions(): array { return $this->addDeleteAction(route('contacts.deletes'), 'contacts.destroy', parent::bulkActions()); } /** * {@inheritDoc} */ public function getBulkChanges(): array { return [ 'name' => [ 'title' => trans('core/base::tables.name'), 'type' => 'text', 'validate' => 'required|max:120', ], 'email' => [ 'title' => trans('core/base::tables.email'), 'type' => 'text', 'validate' => 'required|max:120', ], 'phone' => [ 'title' => trans('plugins/contact::contact.sender_phone'), 'type' => 'text', 'validate' => 'required|max:120', ], 'status' => [ 'title' => trans('core/base::tables.status'), 'type' => 'select', 'choices' => ContactStatusEnum::labels(), 'validate' => 'required|' . Rule::in(ContactStatusEnum::values()), ], 'created_at' => [ 'title' => trans('core/base::tables.created_at'), 'type' => 'date', ], ]; } /** * {@inheritDoc} */ public function getDefaultButtons(): array { return [ 'export', 'reload', ]; } }