Exemple #1
0
 public function __construct(Model $model, $base = 'tag')
 {
     parent::__construct($model, $base);
     $this->breadcrumb2Icon = 'tag';
     $this->fields = array_except($this->model->getFields(), ['id']);
     $this->view->share();
 }
Exemple #2
0
 public function __construct(Model $model, $base = 'permalink')
 {
     parent::__construct($model, $base);
     $edited = ['title' => 'title', 'postable_type' => 'type', 'postable_id' => 'id'];
     $this->breadcrumb2Icon = 'link';
     $this->fields = array_merge(array_except($this->model->getFields(), ['id']), $edited);
     $this->withoutAddButton = true;
     $this->view->share();
 }
Exemple #3
0
 public function __construct(Model $model, $base = 'base')
 {
     parent::__construct($model, $base);
     $this->bodyClass = 'skin-blue sidebar-mini sidebar-collapse';
     $this->breadcrumb1 = title_case(trans('livecms::livecms.home'));
     $this->breadcrumb1Icon = 'home fa-lg';
     $this->breadcrumb2 = title_case(trans('livecms::livecms.' . $this->base));
     // $this->breadcrumb2Url   = route($this->baseClass.'.index');
     $this->view->share();
 }
Exemple #4
0
 protected function afterSaving($request)
 {
     $siteName = $this->setting->firstOrNew(['site_id' => $this->model->id, 'publicable' => true, 'key' => 'site_name']);
     $siteName->value = $this->model->site;
     $siteName->save();
     $siteInitial = $this->setting->firstOrNew(['site_id' => $this->model->id, 'publicable' => true, 'key' => 'site_initial']);
     $siteInitial->value = $this->getInitial($this->model->site);
     $siteInitial->save();
     $this->model->users->each(function ($user, $key) {
         $user->roles()->detach($this->role);
     });
     if ($this->emails) {
         foreach ($this->emails as $email) {
             $username = $email;
             $this->makeAdmin($email, $username);
         }
     } else {
         $username = $email = $request->get('email');
         $this->makeAdmin($email, $username);
     }
     return parent::afterSaving($request);
 }
Exemple #5
0
 protected function afterSaving($request)
 {
     if (!in_array('LiveCMS\\Models\\Contracts\\UserOnlyInterface', class_implements($this->model))) {
         if ($request->has('permalink')) {
             $permalink = $this->model->permalink;
             if ($permalink == null) {
                 $permalink = new Permalink();
                 $permalink->postable()->associate($this->model);
             }
             $permalink->permalink = $request->get('permalink');
             $permalink->save();
         } else {
             if ($this->model->permalink) {
                 $this->model->permalink->delete();
             }
         }
     }
     if ($request->hasFile('picture') && $request->file('picture')->isValid()) {
         $object = $this->model;
         Upload::setFilenameMaker(function ($file, $object) {
             $title = $object->title ? $object->title : $object->name;
             return str_limit(str_slug($title . ' ' . date('YmdHis')), 200) . '.' . $file->getClientOriginalExtension();
         }, $object);
         Upload::model($object);
         $this->model->save();
     }
     if (empty($this->model->status)) {
         $status = Model::STATUS_DRAFT;
         $this->model->update(compact('status'));
     }
     return parent::afterSaving($request);
 }
Exemple #6
0
 protected function afterSaving($request)
 {
     if ($makeAdmin = $request->has('unban')) {
         $author = $this->role->where('role', Role::AUTHOR)->first()->id;
         $this->model->roles()->detach();
         $this->model->roles()->attach($author);
         return parent::afterSaving($request);
     }
     if ($makeAdmin = $request->has('admin_yes') || $request->has('admin_no')) {
         if ($makeAdmin) {
             $admin = $this->role->where('role', Role::ADMIN)->first()->id;
             $this->model->roles()->detach();
             $this->model->roles()->attach($admin);
         } else {
             $author = $this->role->where('role', Role::AUTHOR)->first()->id;
             $this->model->roles()->detach();
             $this->model->roles()->attach($author);
         }
         return parent::afterSaving($request);
     }
     if ($request->isMethod('post')) {
         $role = $this->role->where('role', Role::AUTHOR)->first()->id;
         $this->model->roles()->attach($role);
         return parent::afterSaving($request);
     }
     return parent::afterSaving($request);
 }