Ejemplo n.º 1
0
 public static function boot()
 {
     parent::boot();
     ProductCategory::deleting(function ($productTag) {
         File::delete($productTag->image);
     });
 }
Ejemplo n.º 2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     factory(Priola\ProductCategory::class, 5)->create()->each(function ($pc) {
         for ($i = 0; $i < 1; $i++) {
             if (rand(0, 1) == 1) {
                 $pc->productLines()->save(factory(Priola\ProductLine::class)->make());
             }
         }
     });
     foreach (\Priola\ProductCategory::all() as $productCategory) {
         factory(Priola\Product::class, 10)->create(['product_category_id' => $productCategory->id])->each(function ($p) {
             for ($i = 0; $i < 5; $i++) {
                 $p->productColors()->save(factory(Priola\ProductColor::class)->make());
             }
             $p->masterClasses()->save(factory(Priola\MasterClass::class)->make());
         });
     }
     foreach (\Priola\ProductLine::all() as $productLine) {
         factory(Priola\Product::class, 10)->create(['product_line_id' => $productLine->id])->each(function ($p) {
             for ($i = 0; $i < 5; $i++) {
                 $p->productColors()->save(factory(Priola\ProductColor::class)->make());
             }
             $p->masterClasses()->save(factory(Priola\MasterClass::class)->make());
         });
     }
     foreach (\Priola\MasterClass::all() as $masterClass) {
         factory(Priola\MasterClassStep::class, 6)->create(['master_class_id' => $masterClass->id]);
     }
 }
Ejemplo n.º 3
0
 public static function boot()
 {
     parent::boot();
     ProductCategory::deleting(function ($masterClass) {
         File::delete($masterClass->image);
     });
 }
Ejemplo n.º 4
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $productCategoryList = ProductCategory::lists('title', 'id');
     $productLineList = ProductLine::lists('title', 'id');
     $productList = Product::lists('title', 'id');
     $productTagList = ProductTag::lists('name', 'name');
     return View('admin.products.edit', ['productCategoryList' => $productCategoryList, 'productLineList' => $productLineList, 'productList' => $productList, 'product' => Product::find($id), 'productTagList' => $productTagList]);
 }
 /**
  * @param $findResults
  * @param $directory
  * @param $fileNameWithoutExt
  * @param $imagePattern
  * @param $row
  * @param $createdProductCategories
  */
 private function createProductCategory($findResults, $directory, $fileNameWithoutExt, $imagePattern, $row, $createdProductCategories)
 {
     $imageOriginalPath = $findResults[0];
     $imageExt = File::extension($imageOriginalPath);
     $imagePath = $directory . $fileNameWithoutExt . $imagePattern . '.' . $imageExt;
     $newImagePath = 'img/uploads/' . str_random(32) . '.' . $imageExt;
     File::move($imagePath, public_path() . '/' . $newImagePath);
     $createdProductCategories[$row['nomer']] = ProductCategory::create(['title' => $row['nazvanie'], 'image' => $newImagePath, 'description' => $row['opisanie']]);
 }
 public function saveOrder(Request $request)
 {
     $productCategory = ProductCategory::findOrFail($request->get('product-category-id'));
     $productCategory->menu_order = $request->get('product-category-order');
     $productCategory->save();
     return redirect('/admin/productCategories');
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $productCategoryList = ProductCategory::lists('title', 'id');
     return View('admin.productLines.edit', ['productCategoryList' => $productCategoryList, 'productLine' => ProductLine::find($id)]);
 }
Ejemplo n.º 8
0
 public function search()
 {
     $searchResults = new \Illuminate\Database\Eloquent\Collection();
     $string = Input::get('string');
     $productCategories = ProductCategory::where('title', 'like', '%' . $string . '%')->orWhere('description', 'like', '%' . $string . '%')->get();
     foreach ($productCategories as $productCategory) {
         $body = strip_tags($productCategory->description);
         if (strlen($body) > 100) {
             $body = substr($body, 0, 100);
         }
         $searchResult = new SearchResult(['title' => $productCategory->title, 'body' => $body, 'link' => '/catalog/' . $productCategory->id]);
         $searchResults->push($searchResult);
     }
     $productLines = ProductLine::where('title', 'like', '%' . $string . '%')->orWhere('description', 'like', '%' . $string . '%')->get();
     foreach ($productLines as $productLine) {
         $body = strip_tags($productLine->description);
         if (strlen($body) > 100) {
             $body = substr($body, 0, 100);
         }
         $searchResult = new SearchResult(['title' => $productLine->title, 'body' => $body, 'link' => '/productLine/' . $productLine->id]);
         $searchResults->push($searchResult);
     }
     $products = Product::where('title', 'like', '%' . $string . '%')->orWhere('description', 'like', '%' . $string . '%')->get();
     foreach ($products as $product) {
         $body = strip_tags($product->description);
         if (strlen($body) > 100) {
             $body = substr($body, 0, 100);
         }
         $searchResult = new SearchResult(['title' => $product->title, 'body' => $body, 'link' => '/product/' . $product->id]);
         $searchResults->push($searchResult);
     }
     $masterClasses = MasterClass::where('title', 'like', '%' . $string . '%')->orWhere('description', 'like', '%' . $string . '%')->get();
     foreach ($masterClasses as $masterClass) {
         $body = strip_tags($masterClass->description);
         if (strlen($body) > 100) {
             $body = substr($body, 0, 100);
         }
         $searchResult = new SearchResult(['title' => $masterClass->title, 'body' => $body, 'link' => '/master-class/' . $masterClass->id]);
         $searchResults->push($searchResult);
     }
     $events = Event::where('title', 'like', '%' . $string . '%')->orWhere('body', 'like', '%' . $string . '%')->get();
     foreach ($events as $event) {
         $body = strip_tags($event->description);
         if (strlen($body) > 100) {
             $body = substr($body, 0, 100);
         }
         $searchResult = new SearchResult(['title' => $event->title, 'body' => $body, 'link' => '/events/' . $event->id]);
         $searchResults->push($searchResult);
     }
     $novelties = Novelty::where('title', 'like', '%' . $string . '%')->orWhere('body', 'like', '%' . $string . '%')->get();
     foreach ($novelties as $novelty) {
         $body = strip_tags($novelty->description);
         if (strlen($body) > 100) {
             $body = mb_substr($body, 0, 100);
         }
         $searchResult = new SearchResult(['title' => $novelty->title, 'body' => $body, 'link' => '/novelties/' . $novelty->id]);
         $searchResults->push($searchResult);
     }
     $reviews = Review::where('body', 'like', '%' . $string . '%')->get()->load('regionTechnology');
     foreach ($reviews as $review) {
         $body = strip_tags($review->body);
         if (strlen($body) > 100) {
             $body = mb_substr($body, 0, 100);
         }
         $searchResult = new SearchResult(['title' => RegionTechnology::where('id', $review->region_technology_id)->first()->username, 'body' => $body, 'link' => '/reviews/' . $review->id]);
         $searchResults->push($searchResult);
     }
     $competitions = Competition::where('title', 'like', '%' . $string . '%')->orWhere('description', 'like', '%' . $string . '%')->get();
     foreach ($competitions as $competition) {
         $body = strip_tags($competition->description);
         if (strlen($body) > 100) {
             $body = substr($body, 0, 100);
         }
         $searchResult = new SearchResult(['title' => $competition->title, 'body' => $body, 'link' => '/competitions/' . $competition->id]);
         $searchResults->push($searchResult);
     }
     $courses = Course::where('title', 'like', '%' . $string . '%')->orWhere('description', 'like', '%' . $string . '%')->get();
     foreach ($courses as $course) {
         $body = strip_tags($course->description);
         if (strlen($body) > 100) {
             $body = substr($body, 0, 100);
         }
         $searchResult = new SearchResult(['title' => $course->title, 'body' => $body, 'link' => '/courses/' . $course->id]);
         $searchResults->push($searchResult);
     }
     $massMediaNews = MassMediaNews::where('title', 'like', '%' . $string . '%')->orWhere('body', 'like', '%' . $string . '%')->get();
     foreach ($massMediaNews as $massMediaNewItem) {
         $body = strip_tags($massMediaNewItem->body);
         if (strlen($body) > 100) {
             $body = substr($body, 0, 100);
         }
         $searchResult = new SearchResult(['title' => $massMediaNewItem->title, 'body' => $body, 'link' => '/mass-media-news/' . $massMediaNewItem->id]);
         $searchResults->push($searchResult);
     }
     $regionWorkshops = RegionWorkshop::where('title', 'like', '%' . $string . '%')->orWhere('description', 'like', '%' . $string . '%')->get();
     foreach ($regionWorkshops as $regionWorkshop) {
         $body = strip_tags($regionWorkshop->description);
         if (strlen($body) > 100) {
             $body = substr($body, 0, 100);
         }
         $searchResult = new SearchResult(['title' => $regionWorkshop->title, 'body' => $body, 'link' => '/regions/workshops/' . $regionWorkshop->id]);
         $searchResults->push($searchResult);
     }
     return view('home.searchResults', ['string' => $string, 'searchResults' => $searchResults]);
 }