/** * Call model events. */ private function modelevents() { Page::saving(function ($model) { $model->upload($model); }); Page::creating(function ($model) { $model->slug = !empty($model->slug) ? $model->slug : $model->getUniqueSlug($model->name); }); }
/** * Bootstrap the application events. */ public function boot() { Page::saving(function ($model) { $model->upload($model); }); Page::creating(function ($model) { $model->slug = !empty($model->slug) ? $model->slug : $model->getUniqueSlug($model->name); }); $this->loadViewsFrom(__DIR__ . '/../../../../resources/views', 'page'); $this->loadTranslationsFrom(__DIR__ . '/../../../../resources/lang', 'page'); $this->publishResources(); include __DIR__ . '/../Http/routes.php'; }
/** * Remove the specified resource. * * @param int $id * * @return Response */ public function destroy(PageAdminRequest $request, Page $page) { try { $page->delete(); return $this->success(trans('messages.success.deleted', ['Module' => 'Page']), 201); } catch (Exception $e) { return $this->error($e->getMessage()); } }
public function transform(\Lavalite\Page\Models\Page $page) { return ['id' => $page->getRouteKey(), 'slug' => $page->slug, 'url' => $page->slug . '.html', 'name' => $page->name, 'heading' => $page->heading, 'title' => $page->title, 'keyword' => $page->keyword, 'status' => $page->status, 'order' => $page->order]; }
/** * Remove the page. * * @param int $id * * @return Response */ public function destroy(PageAdminWebRequest $request, Page $page) { try { $t = $page->delete(); return response()->json(['message' => trans('messages.success.deleted', ['Module' => trans('page::page.name')]), 'code' => 202, 'redirect' => trans_url('/admin/page/page/0')], 202); } catch (Exception $e) { return response()->json(['message' => $e->getMessage(), 'code' => 400, 'redirect' => trans_url('/admin/page/page/' . $page->getRouteKey())], 400); } }