Example #1
0
 /**
  * Get all MediaGroups
  *
  * @return Response
  */
 public function get_read_multiple($module_id = null)
 {
     $dal = DAL::model(new Module())->slug();
     if (!$dal->find($module_id)) {
         return $dal->response();
     }
     $module_id = $dal->model->first()->id;
     return $this->dal->options(Input::all())->filter(array('module_id' => $module_id))->read_multiple()->response();
 }
Example #2
0
 public function __construct()
 {
     $this->dal = DAL::model(new Page())->language_model(new PageLang())->options(array('sort_by' => 'created_at'))->settings(array('relating' => array('page_lang' => array('id', 'language_id', 'active', 'url', 'slug', 'meta_title', 'meta_keywords', 'meta_description', 'menu', 'content', 'created_at', 'updated_at', 'created_at')), 'sortable' => array('page_lang' => array('meta_title', 'menu', 'content', 'created_at', 'updated_at')), 'searchable' => array('page_lang' => array('meta_title', 'menu', 'content')), 'filterable' => array('pages' => array('order'), 'page_lang' => array('slug'))))->multilanguage()->slug('url');
 }
Example #3
0
 public function __construct()
 {
     $this->dal = DAL::model(new Module())->settings(array('sortable' => array('modules' => array('name'))))->slug();
 }
Example #4
0
 public function __construct()
 {
     $this->dal = DAL::model(new Account())->options(array('sort_by' => 'created_at'))->settings(array('sortable' => array('accounts' => array('name', 'email', 'created_at', 'updated_at')), 'searchable' => array('accounts' => array('name', 'email'))))->slug('name');
 }
Example #5
0
 public function __construct()
 {
     $this->dal = DAL::model(new Asset())->options(array('sort_by' => 'created_at'))->settings(array('sortable' => array('assets' => array('created_at'), 'asset_lang' => array('name', 'description')), 'searchable' => array('asset_lang' => array('name', 'description'))))->multilanguage();
 }
Example #6
0
 public function __construct()
 {
     $this->dal = DAL::model(new Layout())->versioned()->slug('name');
 }
Example #7
0
 public function update($id)
 {
     if (!$this->find($id)) {
         return $this;
     }
     $this->model = $this->model->first();
     if ($this->versioned && !$this->multilanguage) {
         $latest_version = DB::table($this->table)->where_id($this->model->get_key())->max('version');
         $this->model->version = is_null($latest_version) ? 0 : $latest_version + 1;
         $this->model->exists = false;
     }
     if ($this->multilanguage) {
         if ($this->parent) {
             $this->input[$this->parent->language_table_foreign_key] = $this->parent->model->id;
             return $this->create();
         }
         $lang_input = array();
         foreach ($this->input['lang'] as $id => $input) {
             $input['language_id'] = $id;
             $input[$this->language_table_foreign_key] = $this->id;
             $lang_input[] = $input;
         }
         unset($this->input['lang']);
         $dal = DAL::model($this->language_model)->parent($this)->versioned($this->versioned)->input($lang_input)->update_multiple();
         if (!$dal->code == 200) {
             $this->data = $dal->data;
             $this->code = $dal->code;
             return $this;
         }
     } elseif (!is_null($this->slug) || isset($this->parent) && !is_null($this->parent)) {
         $key = isset($this->parent) && !is_null($this->parent) ? $this->parent->slug : $this->slug;
         $this->input['slug'] = Str::slug($this->input[$key]);
     }
     // Fill the model
     $this->model->fill($this->input);
     // Try to save
     if ($this->model->save() === false) {
         $this->code = 400;
         $this->data = (array) $this->model->errors->messages;
     }
     $this->sync();
     return $this;
 }
Example #8
0
 public function __construct()
 {
     $this->dal = DAL::model(new Role())->settings(array('sortable' => array('role_lang' => array('name'))))->multilanguage();
 }
Example #9
0
 public function __construct()
 {
     $this->dal = DAL::model(new Language())->settings(array('sortable' => array('languages' => array('name'))));
 }