Beispiel #1
0
 public function index()
 {
     $products = Product::take(6)->get();
     $products->map(function ($item) {
         $item->url = route('product', $item->slug);
         return $item;
     });
     $data = [];
     $data['popular'] = ['title' => 'POPÜLER BİSİKLETLER', 'list' => $products->toArray(), 'more' => ['title' => 'Hepsini Göreyim', 'url' => $this->urls['products']]];
     //$view = hbs('content/product-list', ]);
     $billboardImages = [['filename' => 'Bradley_MG_0056.jpg', 'style' => 'margin-top:-25%'], ['filename' => 'delta-lifestyle-5_2048x2048.jpg', 'style' => 'margin-top:-20%'], ['filename' => 'IMG_3639.jpg', 'style' => 'margin-top:-20%'], ['filename' => 'ZULU_WEB_0005.jpg', 'style' => 'margin-top:-20%']];
     $image = array_rand($billboardImages);
     $image = $billboardImages[$image];
     $data['billboard'] = ['url' => $this->urls['products'], 'image' => $image];
     //$billboardView = hbs('part/billboard', );
     $this->meta['title'] = 'Merhaba';
     $data['videos'] = ['url' => $this->urls['videos']];
     $view = hbs('content/home', $data);
     return $this->layout($view);
 }
Beispiel #2
0
 public function search($keyword)
 {
     return Product::with('variants')->where('title', 'like', '%' . $keyword . '%')->get();
 }
Beispiel #3
0
 private function debug_remove_nonexistent_images()
 {
     $products = Product::all();
     $products->each(function ($p) {
         $images = $p->images;
         $path = 'images/';
         foreach ($images as $idx => $image) {
             if (!file_exists($path . $image)) {
                 $images[$idx] = 'xx XX xx';
                 unset($images[$idx]);
             }
         }
         // Reset array keys
         $images = array_values($images);
         $p->images = $images;
         $p->save();
     });
     return $products;
 }