Example #1
0
 protected function loadItems()
 {
     if (!($category = Category::find($this->property('category')))) {
         return Item::paginate($this->property('itemsPerPage'), $this->property('pageNumber'));
     }
     return $category->items()->paginate($this->property('itemsPerPage'), $this->property('pageNumber'));
 }
Example #2
0
 public function index_onDelete()
 {
     if ($checkedIds = post('checked')) {
         foreach ($checkedIds as $itemId) {
             if (!($table = Item::find($itemId))) {
                 continue;
             }
             $table->delete();
         }
         Flash::success(Lang::get('backend::lang.form.delete_success', ['name' => Lang::get('arrizalamin.portfolio::lang.controller.form.items.title')]));
     }
     return $this->listRefresh();
 }
 public function run()
 {
     // exit when items are found
     if (Item::count()) {
         return false;
     }
     /**
      * Add example category
      */
     $ec = Category::create(['name' => 'Examples', 'slug' => 'examples']);
     /**
      * Add example tag
      */
     $t1 = Tag::create(['name' => 'one']);
     /**
      * Add example item
      */
     $i1 = Item::create(['category_id' => $ec->id, 'title' => 'Proactively disseminate', 'slug' => 'proactively', 'description' => 'Proactively disseminate parallel markets after open-source e-services. Quickly administrate goal-oriented sources through turnkey human capital. Intrinsicly transition installed base schemas with reliable resources. Proactively leverage other\'s compelling mindshare with interoperable applications. Holisticly aggregate transparent metrics through just in time value. Conveniently target pandemic paradigms through leading-edge intellectual capital. Authoritatively create next-generation products rather than reliable platforms. Dramatically predominate robust materials rather than principle-centered innovation. Quickly simplify market positioning niches through equity invested outsourcing. Intrinsicly integrate progressive niche markets.']);
     $i1->tags()->attach($t1->id);
     //TODO: find a way to attach sample images to the items.
 }
 public function onRun()
 {
     $this->portfolio = Item::where('slug', $this->property('slug'))->first();
 }
Example #5
0
 /**
  * When running this component, load all items based on the selections.
  */
 public function onRun()
 {
     // Page links
     $this->itemPage = $this->page['itemPage'] = $this->property('itemPage');
     $this->tagListPage = $this->page['tagListPage'] = $this->property('tagListPage');
     $this->catListPage = $this->page['catListPage'] = $this->property('catListPage');
     // find the correct property to select the items with
     $object = null;
     if ($this->property('selectedTag') != null) {
         $object = $this->loadItemsByTag($this->property('selectedTag'));
     } elseif ($this->property('selectedCat') != null) {
         $object = $this->loadItemsByCategory($this->property('selectedCat'), true);
     } elseif ($this->property('category') != null) {
         $object = $this->loadItemsByCategory($this->property('category'));
     }
     // check if a valid object has been created
     if (!$object) {
         // display all items
         $this->portfolio = Item::paginate($this->property('itemsPerPage'), $this->property('pageNumber'));
     } else {
         // show the items in the portfolio
         $this->portfolio = $object->items()->orderBy('created_at', $this->property('order'))->paginate($this->property('itemsPerPage'), $this->property('pageNumber'));
     }
     // Add url helper to the items
     if ($this->portfolio != null) {
         $this->portfolio = $this->updatePageUrls($this->portfolio);
     }
 }
Example #6
0
 /**
  * Load the selected item by its slug
  *
  * @param $selectedItem
  * @return mixed
  */
 protected function loadItemBySlug($selectedItem)
 {
     $item = PortfolioItem::where('slug', '=', $selectedItem)->first();
     return $item;
 }
 /**
  * Get all posts with matching title or content.
  *
  * @return Collection
  */
 protected function items()
 {
     return Item::with(['images'])->where('title', 'like', "%{$this->query}%")->orWhere('description', 'like', "%{$this->query}%")->get();
 }