Beispiel #1
0
 /**
  * @return \Illuminate\Http\JsonResponse
  */
 public function stock()
 {
     $products = Product::all();
     $stock = Stock::orderBy('quality', 'DESC')->get();
     if ($products->count()) {
         $stock_count = 0;
         foreach ($stock as $stok) {
             $stock_product = Product::where('id', '=', $stok->product_id);
             if ($stock_product->count()) {
                 $stock_name = $stock_product->first()->name;
                 $stock_type = $stock_product->first()->type;
                 $stock[$stock_count]->stock_name = $stock_name;
                 $stock[$stock_count]->type = $stock_type;
             }
             $stock_count++;
         }
         $prod_count = 0;
         foreach ($products as $product) {
             $distributor = Distributor::where('id', '=', $product->distributor_id);
             if ($distributor->count()) {
                 $distributor = $distributor->first();
                 $distributor_name = $distributor->name;
                 $products[$prod_count]->distributor_name = $distributor_name;
             }
             $prod_count++;
         }
         return response()->json(['products' => $product, 'stock' => $stock]);
     } else {
         return response()->json(['products' => [], 'stock' => []]);
     }
 }
 public function create()
 {
     $types = StockType::getType();
     $employees = Employee::all();
     $products = Product::all();
     $params = ['types' => $types, 'employees' => $employees, 'products' => $products];
     return view('pages.new_stock', $params);
 }
 public function save(Request $request)
 {
     $suppliers = $request->get('supplier_id');
     $product = Product::create($request->all());
     foreach ($suppliers as $supp) {
         SupplierProducts::create(['product_id' => $product->id, 'supplier_id' => $supp]);
     }
     $products = Product::all();
     return view('pages.products', ['products' => $products]);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('trackings')->truncate();
     $faker = Faker::create();
     foreach (range(1, 20) as $index) {
         Tracking::create(['image_url' => $faker->imageUrl(640, 480, 'city'), 'facing_id' => Facing::find($faker->numberBetween(1, 20))->id]);
     }
     foreach (range(21, 30) as $index) {
         Tracking::create(['image_url' => $faker->imageUrl(640, 480, 'city'), 'state' => 'Inserted', 'inserted_at' => Carbon::now(), 'facing_id' => Facing::all()->get($faker->numberBetween(1, 20))->id, 'product_id' => Product::all()->get($faker->numberBetween(1, 20))->id, 'brand_id' => Brand::all()->get($faker->numberBetween(1, 20))->id, 'user_id' => User::all()->get($faker->numberBetween(1, 10))->id]);
     }
 }
Beispiel #5
0
 public function getIndex()
 {
     $products_list = [0 => 'Не выбрано'];
     foreach (Product::all() as $product) {
         $products_list[$product->id] = $product->name;
     }
     $blocks_list = [];
     foreach (BlocksContent::all() as $block) {
         $blocks_list[$block->id] = $block->title;
     }
     return view('admin.blocks_content.index', ['products_list' => $products_list, 'blocks_list' => $blocks_list, 'blocks' => BlocksContent::all()]);
 }
 /**
  * Overrides CODES relationship with one for each product available
  *
  * @param User $user
  */
 private function adminFunction(User $user)
 {
     /**
      * if its an admin, override relationship
      * UPDATE: allow everyone have all the codes
      */
     //        if ($user->is('admin') ) {
     $codes = Product::all()->transform(function ($product) use($user) {
         /** @var Code $temp */
         $temp = $product->codes()->with('product', 'product.extras', 'product.profile')->first();
         if ($temp) {
             return $temp->setAttribute('user_id', $user->id);
         }
     });
     $user->setRelation('codes', $codes);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Stantion $depo, Product $product, StoreStation $request)
 {
     $products = $product->all();
     DB::transaction(function () use($depo, $request, $products) {
         $lastInsertedDepo = $depo->create($request->all());
         $pricesIdArr = [];
         foreach ($products as $prod) {
             $price = new Price();
             $price->price = 0;
             $price->save();
             $prod->price()->attach($price->id);
             $pricesIdArr[] = $price->id;
         }
         $lastInsertedDepo->price()->sync($pricesIdArr);
     });
     return redirect('stations')->with('alert-warning', 'Депо успешно добавлено! Внимание! Не забудьте проставить цену товарам для этого депо');
 }
Beispiel #8
0
 /**
  * get products
  *
  * @return Response
  */
 public function getProduct()
 {
     $products = Product::all();
     return Datatables::of($products)->edit_column('image', function ($row) {
         if (!empty($row->image)) {
             return showImage($row->image, PRODUCT_IMAGE . $row->id);
         }
     })->edit_column('status', function ($row) {
         return showSelectStatus($row->id, $row->status, 'Kacana.product.setStatus(' . $row->id . ', 1)', 'Kacana.product.setStatus(' . $row->id . ', 0)');
     })->edit_column('created', function ($row) {
         return showDate($row->created);
     })->edit_column('updated', function ($row) {
         return showDate($row->updated);
     })->add_column('action', function ($row) {
         return showActionButton("/product/editProduct/" . $row->id, 'Kacana.product.removeProduct(' . $row->id . ')', false, false);
     })->make(true);
 }
Beispiel #9
0
<?php

Admin::model('App\\Models\\Order')->title('')->display(function () {
    $display = AdminDisplay::datatables();
    $display->with();
    $display->filters([]);
    $display->columns([Column::custom()->label('Команда')->callback(function ($instance) {
        $product = \App\Models\Product::all()->where('id', $instance->product_id)->first();
        return is_null($product) ? 'Неизвестный' : $product->title;
    }), Column::string('sum')->label('Сумма'), Column::custom()->label('Статус')->callback(function ($instance) {
        if ($instance->status == 0) {
            return '<p class="text-warning">Не оплачен</p>';
        } elseif ($instance->status == 1) {
            return '<p class="text-danger">Ошибка</p>';
        } else {
            return '<p class="text-success">Оплачен</p>';
        }
    })]);
    return $display;
})->createAndEdit(function () {
    return null;
});
 /**
  * Get all of the products for the Customer
  *
  * @return Collection
  */
 public function forCustomer()
 {
     return Product::all();
 }
 public function overview()
 {
     $products = Product::all();
     return view('cms/product/product/overview')->with('items', $products);
 }
 function index()
 {
     $products = Product::all();
     return view('product.cart', ['products' => $products]);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     return Product::all();
 }
 function products()
 {
     return Product::all();
 }
 /**
  * Display Generator Page
  *
  * @param Product $product
  * @return $this
  */
 public function index(Product $product)
 {
     return view('products.index')->with('products', $product->all());
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $products = Product::all();
     return view('products.index', ['products' => $products]);
 }
 protected function show($id)
 {
     $data = Product::all();
     return view('newOrder', $data);
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $products = Product::all();
     return view('site.products.index')->with('products', $products);
 }
Beispiel #19
0
<?php

use app\Models\Product;
$product = new Product();
echo 'List all<br>';
echo '<pre>';
print_r($product->all());
echo '</pre>';
echo '<br>Create Product<br>';
$product->name = 'new product';
$product->sku = 'PC';
$product->price = 5.29;
$product->save();
echo '<pre>';
print_r($product->all());
echo '</pre>';
echo '<br>Update product<br>';
$product->name = 'updated description';
$product->save();
echo '<pre>';
print_r($product->all());
echo '</pre>';
echo '<br>Delete product<br>';
$product->delete();
echo '<pre>';
print_r($product->all());
echo '</pre>';
 public function index(Request $request)
 {
     $products = Product::all();
     return $this->view('products.list', $request, compact('products'));
 }
Beispiel #21
0
 public function getIndex()
 {
     return view('products.index', ['products' => Product::all()]);
 }
 /**
  * Show the application dashboard to the user.
  * @return Response
  */
 public function index()
 {
     return View::make('home')->with('items', Product::all());
 }
 function lists()
 {
     $products = Product::all();
     return view('product.list', ['products' => $products]);
 }
 public function index()
 {
     $products = Product::all();
     return view('product.index', compact('products'));
 }
 public function cart()
 {
     $products = Product::all();
     return view('products.tocart', compact('products'));
 }
Beispiel #26
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $items = Product::all();
     $data = ['route' => $this->key, 'title' => Product::$tableName, 'items' => $items];
     return view("admin.{$this->key}.list", $data);
 }