function traitEntityItemDelete() { $this->traitEntity_assertReason($this->model, 'delete'); $data = ['vendor' => (string) static::getVendor(), 'entity' => \Str::snake($this->getEntity())]; if ($this->model->deleted_at) { // $this->model->restore(); // dd(); $data['state'] = -1; $data['message'] = static::translateAction('item|delete.success.hard', ['model' => $this->model]); $data['models'][] = ['id' => $this->model->id]; $this->model->forceDelete(); } else { $this->model->delete(); $data['state'] = 0; $data['message'] = static::translateAction('item|delete.success.soft', ['model' => $this->model]); $row_types = ManagerRowType::get(ManagerRowType::makeKey(static::getVendor(), static::getEntity())); $rows = []; foreach ($row_types as $row_type) { $rows[$row_type] = (string) Accessor::factory($this->model)->row($row_type); } $data['models'][] = ['id' => $this->model->id, 'model' => $this->model->toArray(), 'rows' => $rows]; } $this->traitAjax_set($data); Event::notify('larakit::model_delete-admin', $data); return $this->traitAjax_response(); }
function traitEntityRestore() { $this->traitEntity_assertReason($this->model, 'restore'); $this->model->restore(); $row_types = ManagerRowType::get(ManagerRowType::makeKey(static::getVendor(), static::getEntity())); $rows = []; foreach ($row_types as $row_type) { $rows[$row_type] = (string) Accessor::factory($this->model)->row($row_type); } $data = ['models' => [['model' => $this->model->toArray(), 'rows' => $rows, 'id' => $this->model->id]], 'vendor' => (string) static::getVendor(), 'entity' => \Str::snake($this->getEntity()), 'message' => sprintf($this->traitEntityItemRestore_success(), $this->model), 'state' => 1]; Event::notify('larakit::model_restore-admin', $data); $this->traitAjax_set($data); return $this->traitAjax_response(); }
function toHtml() { Event::notify('dashboard_' . $this->name); $items = []; krsort($this->items); foreach ($this->items as $_items) { foreach ($_items as $item) { $items[] = $item; } } $this->set('items', $items); $this->set('in_row', $this->in_row); return \View::make($this->tpl(), $this->values)->__toString(); }
protected function downloadFiles(array $files) { $progress = new \Symfony\Component\Console\Helper\ProgressBar($this->output, sizeof($files)); $progress->setFormat('debug'); $progress->start(); $production_url = Webconfig::get('larakit.sync_url'); //'http://bmmaket.bmdemo.ru'; // dd($production_url); $path = public_path(); foreach ($files as $file) { try { $url = trim(Arr::get($file, 'url'), '/'); if ($url) { $thumb = Arr::get($file, 'thumb'); $size = Arr::get($file, 'size'); if (!file_exists(dirname($path . '/' . $url))) { mkdir(dirname($path . '/' . $url), 0777, true); } // $this->info(''); // $this->info('-----------'); // $this->info(trim($production_url, '/') . '/' . $url); // $this->info($path . '/' . $url); // $this->info('-----------'); copy(trim($production_url, '/') . '/' . $url, $path . '/' . $url); $selector = []; $selector[] = 'img[data-entity=' . $thumb->entity() . '][data-vendor=' . $thumb->vendor() . '][data-thumb-size=' . $size . '][data-thumb-name=' . $thumb->getName() . '],'; $selector[] = '.js-list[data-entity=' . $thumb->entity() . '][data-vendor=' . $thumb->vendor() . ']'; $selector[] = '.js-item[data-id=' . $thumb->getId() . ']'; $selector[] = '.js-btn[data-thumb-size=' . $size . '][data-thumb-name=' . $thumb->getName() . ']'; $selector[] = 'img'; $data = ['url' => $thumb->getUrl($size) . '?' . microtime(true), 'selector' => implode(' ', $selector)]; Event::notify('larakit::thumb_size', $data); } // $this->info($url); } catch (\Exception $e) { // $this->error(trim($e->getMessage()) . ':' . $e->getLine()); } $progress->advance(); } $progress->finish(); $this->info(''); }
function traitEntityHasMany_item() { if (\Request::method() == 'POST') { $this->traitEntityHasMany_save(); //переоткроем модель $model_name = $this->getClassModel(); if ($model_name::isSoftDelete()) { $model = $model_name::withTrashed()->with($this->relation)->find(\Route::input('id')); } else { $model = $model_name::with($this->relation)->find(\Route::input('id')); } $row_types = ManagerRowType::get(ManagerRowType::makeKey(static::getVendor(), static::getEntity())); $rows = []; foreach ($row_types as $row_type) { $rows[$row_type] = (string) Accessor::factory($model)->row($row_type); } $data = ['models' => [['rows' => $rows, 'model' => $model->toArray(), 'id' => $model->id]], 'vendor' => (string) static::getVendor(), 'entity' => \Str::snake(static::getEntity()), 'message' => sprintf($this->traitEntityHasMany_successMessage(), $model)]; Event::notify('larakit::model_edit-admin', $data); $this->traitAjax_set($data); return $this->traitAjax_response(); } $this->traitAjax_set('id', $this->model->id)->traitAjax_set('result', 'curtain')->traitAjax_set('vendor', (string) \Str::snake($this->getVendor()))->traitAjax_set('entity', (string) \Str::snake($this->getEntity()))->traitAjax_set('model', $this->model->toArray())->traitAjax_set('header', (string) $this->traitEntityHasMany_header())->traitAjax_set('body', (string) $this->traitEntityHasMany_body())->traitAjax_set('footer', (string) $this->traitEntityHasMany_footer()); return $this->traitAjax_response(); }
function traitEntityBelongsTo_item() { if (\Request::method() == 'POST') { $id = (int) \Input::get('belongs_to'); $this->model->{$this->getRelationKey()} = $id; $this->model->save(); // ->sync($ids); //переоткроем модель $model_name = $this->getClassModel(); /** @var Model $model */ if ($model_name::isSoftDelete()) { $model = $model_name::withTrashed(); } else { $model = $model_name::select(); } //откроем со всеми связями, которые могут потребоваться для шаблона ROW foreach ($model->getModel()->getRelations() as $relation) { $model->with($relation); } $model = $model->find(\Route::input('id')); $row_types = ManagerRowType::get(ManagerRowType::makeKey(static::getVendor(), static::getEntity())); $rows = []; foreach ($row_types as $row_type) { $rows[$row_type] = (string) Accessor::factory($model)->row($row_type); } $data = ['models' => [['rows' => $rows, 'model' => $model->toArray(), 'id' => $model->id]], 'vendor' => (string) static::getVendor(), 'entity' => \Str::snake(static::getEntity()), 'message' => sprintf($this->traitEntityBelongsTo_successMessage(), $model)]; Event::notify('larakit::model_edit-admin', $data); $this->traitAjax_set($data); return $this->traitAjax_response(); } $this->traitAjax_set('id', $this->model->id)->traitAjax_set('result', 'curtain')->traitAjax_set('vendor', static::getVendor())->traitAjax_set('entity', $this->getEntity())->traitAjax_set('model', $this->model->toArray())->traitAjax_set('header', (string) $this->traitEntityBelongsTo_header())->traitAjax_set('body', (string) $this->traitEntityBelongsTo_body())->traitAjax_set('footer', (string) $this->traitEntityBelongsTo_footer()); return $this->traitAjax_response(); }
function traitEntityEditJson_success() { $class_model = get_class($this->model); $model = $class_model::findOrFail($this->model->id); $row_types = ManagerRowType::get(ManagerRowType::makeKey(static::getVendor(), static::getEntity())); $rows = []; foreach ($row_types as $row_type) { $rows[$row_type] = (string) Accessor::factory($model)->row($row_type); } $data = ['models' => [['rows' => $rows, 'model' => $model->toArray(), 'id' => $model->id]], 'vendor' => (string) static::getVendor(), 'entity' => \Str::snake(static::getEntity()), 'message' => sprintf($this->traitEntityEdit_successMessage(), $model)]; Event::notify('larakit::model_edit-admin', $data); $this->traitAjax_set($data); return $this->traitAjax_response(); }