コード例 #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $orderMake = [['amount' => rand(2, 14) * 5.9, 'order_number' => str_random(25)], ['amount' => rand(2, 14) * 5.9, 'order_number' => str_random(25)], ['amount' => rand(2, 14) * 5.9, 'order_number' => str_random(25)], ['amount' => rand(2, 14) * 5.9, 'order_number' => str_random(25)], ['amount' => rand(2, 14) * 5.9, 'order_number' => str_random(25)], ['amount' => rand(2, 14) * 5.9, 'order_number' => str_random(25)], ['amount' => rand(2, 14) * 5.9, 'order_number' => str_random(25)], ['amount' => rand(2, 14) * 5.9, 'order_number' => str_random(25)]];
     foreach ($orderMake as $order) {
         $order = CrudHelper::store(new App\Order(), $order);
         $order = CrudHelper::show(new App\Order(), 'id', $order['id'])->first();
         $order->products()->sync(['1', '2', '3']);
     }
 }
コード例 #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $users = [['name' => 'Andreas Admin', 'email' => '*****@*****.**', 'password' => bcrypt('2wsxzaq1'), 'role' => '1'], ['name' => 'Andreas Agent', 'email' => '*****@*****.**', 'password' => bcrypt('2wsxzaq1'), 'role' => '2'], ['name' => 'Andreas Lender', 'email' => '*****@*****.**', 'password' => bcrypt('2wsxzaq1'), 'role' => '3']];
     foreach ($users as $user) {
         $role = $user['role'];
         $user = CrudHelper::store(new App\User(), ['name' => $user['name'], 'email' => $user['email'], 'password' => $user['password']]);
         $user = CrudHelper::show(new App\User(), 'id', $user['id'])->first();
         $user->roles()->sync([$role]);
     }
 }
コード例 #3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $productMake = ['15', '14', '13', '12', '11', '10', '9', '8', '7', '6', '5', '4', '3', '2', '1'];
     foreach ($productMake as $go) {
         $product = CrudHelper::store(new App\Product(), ['name' => 'Test Product ' . str_random(20), 'price' => rand(2, 14) * 5.9, 'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed in leo quis neque cursus laoreet. Vestibulum sed placerat dolor. Donec sem purus, pulvinar quis felis eu, pharetra pharetra turpis. Praesent blandit, mauris nec euismod vulputate, nisl ex egestas purus, sed iaculis sem ipsum sed sem. Etiam ultrices lacus eu ante fringilla viverra. Cras ac pellentesque ipsum, et vulputate nulla. Duis consequat, tortor non pulvinar mollis, est orci eleifend ex, in rutrum risus augue nec enim. Donec dapibus mauris sit amet diam laoreet vehicula.']);
         $product = CrudHelper::show(new App\Product(), 'id', $product['id'])->first();
         $category = [rand(1, 10), rand(1, 10), rand(1, 10)];
         $images = [rand(1, 10), rand(1, 10), rand(1, 10), rand(1, 10), rand(1, 10)];
         $product->categories()->sync($category);
         $product->images()->sync($images);
     }
 }
コード例 #4
0
 public function getCategoryIds($categories)
 {
     foreach ($categories as $categoryKey => $categoryValue) {
         if (is_null($categoryValue)) {
             unset($categories[$categoryKey]);
         }
     }
     foreach ($categories as $key => $value) {
         $category = CrudHelper::show(new \App\Category(), 'category', $value)->first();
         $categoryIds[] = $category->id;
     }
     return $categoryIds;
 }
コード例 #5
0
 public function show($id)
 {
     $product = CrudHelper::show(new \App\Product(), 'id', $id, ['categories', 'images'])->first()->toArray();
     $categories = $product['categories'];
     $images = $product['images'];
     foreach ($images as $isMain) {
         if ($isMain['is_main'] === 1) {
             $mainImage[] = $isMain;
         }
     }
     $mainImage = $mainImage[0];
     foreach ($categories as $category) {
         $productCategories[] = $category['category'];
     }
     $productCategories = implode(', ', $productCategories);
     return view('shop.shopSingle')->with(['product' => $product, 'productCategories' => $productCategories, 'images' => $images, 'mainImage' => $mainImage]);
 }
コード例 #6
0
 public function showSingleOrder($orderNumber)
 {
     $order = CrudHelper::show(new \App\Order(), 'order_number', $orderNumber, ['products'])->first();
     dd($order);
 }
コード例 #7
0
 public function showContact($model, $contactId, $relationships = [])
 {
     $contact = CrudHelper::show($model, 'id', $contactId, $relationships);
     if ($contact == null) {
         abort(404);
     }
     return $contact->first();
 }
コード例 #8
0
 public function showProgram($id)
 {
     $program = CrudHelper::show(new \App\Program(), 'slug', $id);
     $program = $this->programLinter($program);
     return $program;
 }
コード例 #9
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $program = CrudHelper::show(new \App\Program(), 'id', $id);
     foreach ($request->all() as $key => $value) {
         $updateData[$key] = $value;
     }
     unset($updateData['_method']);
     unset($updateData['_token']);
     $updateData['slug'] = CrudHelper::slugify($updateData['titleStrong'] . ' ' . $updateData['title']);
     $program->update($updateData);
     $program = $this->programLinter($program);
     $program = $program->first();
     return redirect()->route('program.edit', $program['slug'])->with('success_message', 'Property Updated');
 }