예제 #1
0
 /**
  * @param Gallery $gallery
  * @return Gallery
  */
 public static function create($gallery)
 {
     // Set Attributes
     $user = Yii::$app->user->getIdentity();
     $gallery->createdBy = $user->id;
     // Create Gallery
     $gallery->save();
     // Return Gallery
     return $gallery;
 }
예제 #2
0
 public function actionCreate($type = null)
 {
     $model = new Gallery();
     $model->type = $type;
     $model->setScenario('create');
     if ($model->load(Yii::$app->request->post(), 'Gallery') && $model->validate()) {
         if (GalleryService::create($model)) {
             $this->redirect($this->returnUrl);
         }
     }
     return $this->render('@cmsgears/module-core/admin/views/gallery/create', ['model' => $model]);
 }
예제 #3
0
 public static function getPagination($config = [])
 {
     $sort = new Sort(['attributes' => ['owner' => ['asc' => ['createdBy' => SORT_ASC], 'desc' => ['createdBy' => SORT_DESC], 'default' => SORT_DESC, 'label' => 'owner'], 'name' => ['asc' => ['name' => SORT_ASC], 'desc' => ['name' => SORT_DESC], 'default' => SORT_DESC, 'label' => 'name'], 'slug' => ['asc' => ['slug' => SORT_ASC], 'desc' => ['slug' => SORT_DESC], 'default' => SORT_DESC, 'label' => 'slug'], 'title' => ['asc' => ['title' => SORT_ASC], 'desc' => ['title' => SORT_DESC], 'default' => SORT_DESC, 'label' => 'title']]]);
     if (!isset($config['query'])) {
         $config['query'] = Gallery::findWithOwner();
     }
     if (!isset($config['sort'])) {
         $config['sort'] = $sort;
     }
     if (!isset($config['search-col'])) {
         $config['search-col'] = 'name';
     }
     return self::getDataProvider(new Gallery(), $config);
 }