Exemplo n.º 1
0
 public function addProducts($brandid, $catid)
 {
     Larasset::start('header')->css('magicsuggest');
     Larasset::start('footer')->js('magicsuggest');
     $productcat = Productcategory::find($catid)->toArray();
     $brand = Brand::find($productcat['brand_id'])->toArray();
     $data['productcat'] = $productcat;
     $data['brand'] = $brand;
     return View::make('admin.create.addproduct', $data);
 }
 function getBrands()
 {
     $store_brands = array();
     $db_brands = $GLOBALS['DB']->query("SELECT brands.* FROM\n                stores JOIN brands_stores ON (stores.id = brands_stores.store_id)\n                       JOIN brands ON (brands_stores.brand_id = brands.id)\n                WHERE stores.id = {$this->getId()};");
     foreach ($db_brands as $brand) {
         $found_brand = Brand::find($brand['id']);
         array_push($store_brands, $found_brand);
     }
     return $store_brands;
 }
 public function postUpdate()
 {
     $brand_id = Input::get('brand_id');
     $categories = array_values(Input::get('categories'));
     $brand = Brand::find($brand_id);
     $brand->name = Input::get('brand');
     $brand->save();
     $brand->categories()->sync($categories);
     return Redirect::back()->withErrors(['succes' => 'actualizacion :D']);
 }
Exemplo n.º 4
0
 function testFind()
 {
     $brand_name = "Air Jordan";
     $test_brand = new Brand($brand_name);
     $test_brand->save();
     $brand_name2 = "Nike";
     $test_brand2 = new Brand($brand_name2);
     $test_brand2->save();
     $result = Brand::find($test_brand->getId());
     $this->assertEquals($test_brand, $result);
 }
Exemplo n.º 5
0
 function testFind()
 {
     $name = "Clides";
     $test_brand = new Brand($name);
     $test_brand->save();
     $name2 = "Marthas";
     $test_brand2 = new Brand($name2);
     $test_brand2->save();
     $result = Brand::find($test_brand->getId());
     $this->assertEquals($test_brand, $result);
 }
Exemplo n.º 6
0
 public static function totalProductWorth($brand_id)
 {
     $prices = Brand::find($brand_id)->products->lists('total_price');
     if ($prices != null and !empty($prices)) {
         foreach ($prices as $price) {
             @($p += $price);
         }
         return $p;
     }
     return 0;
 }
Exemplo n.º 7
0
 public function UpdateListBrand()
 {
     $input = Input::all();
     $listBrandID = $input['update_list_brand_id'];
     $listBrandID = explode(",", $listBrandID);
     foreach ($listBrandID as $p) {
         if ($input['name'] != '') {
             $brand = Brand::find($p);
             $brand->name = $input['name'];
             $brand->save();
         }
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     //
     $validation = Validate::BrandValidation(Input::all());
     if ($validation->fails()) {
         return Redirect::to('marca/create')->withErrors($validation)->withInput();
     } else {
         $brand = Brand::find($id);
         $brand->brand = Input::get('brand');
         $brand->save();
         return Redirect::to('admin/marca');
     }
 }
Exemplo n.º 9
0
 function test_find()
 {
     //Arrange
     $brand_name = "Nike";
     $test_brand = new Brand($id, $brand_name);
     $test_brand->save();
     $brand_name2 = "Adidas";
     $test_brand2 = new Brand($id, $brand_name2);
     $test_brand2->save();
     //Act
     $result = Brand::find($test_brand->getId());
     //Assert
     $this->assertEquals($test_brand, $result);
 }
Exemplo n.º 10
0
 public function putEdit($id)
 {
     $brand = Brands::find((int) $id);
     if (empty($brand)) {
         return Redirect::to('admin/brand')->with('errors', 'Invalid Brand ID');
     }
     $fields = array('title' => Input::get('title'), 'description' => Input::get('description'), 'status' => Input::get('status'), 'visibility' => Input::get('visibility'), 'slug' => Input::get('slug'), 'url' => Input::get('url'));
     $rules = array('title' => "required|unique:brands,title,{$id}", 'slug' => "required|unique:brands,slug,{$id}");
     $v = Validator::make($fields, $rules);
     if ($v->fails()) {
         return Redirect::to("admin/brand/edit/{$id}")->withErrors($v)->withInput();
     }
     $brand->fill($fields);
     $brand->save();
     return Redirect::to('admin/brand')->with('message', 'Brand Updated');
 }
 public function saveAddCategory()
 {
     $catsArray = json_decode(Input::get('category'));
     $brand_id = Input::get('brand_id');
     $cat_type = Input::get('cat_type');
     if (!empty($catsArray)) {
         //We fetch the name of categories under that brand
         $brandModel = Brand::find($brand_id);
         $brandCat = $brandModel->categories->lists('name');
         $brandName = $brandModel->name;
         $tempStoreCatsForLog['cats'] = array();
         foreach ($catsArray as $category) {
             //We check if the new category existed in the list of categories under the brand
             if (in_array($category, $brandCat)) {
                 $data['status'] = 'error';
                 $data['message'] = $category . ' already exist';
             } else {
                 $cat = new Productcategory();
                 $cat->name = strtolower(trim(extract_char($category, array('text', 'int'))));
                 $cat->brand_id = $brand_id;
                 $cat->type = $cat_type;
                 $tempStoreCatsForLog['cats'][] = $cat->name;
                 if (!$cat->save()) {
                     $data = $cat->validatorStatus;
                 } elseif (empty($data)) {
                     $data['status'] = 'success';
                     $data['message'] = 'Created successfully';
                 }
             }
         }
         if (!empty($tempStoreCatsForLog['cats'])) {
             //Log area
             $log['products'] = "[ {$brandName} ] = " . implode(' | ', $tempStoreCatsForLog['cats']);
             $log['stocktype'] = 'create';
             $this->_saveActivityLog($log);
         }
     } else {
         $data['status'] = 'error';
         $data['message'] = 'Field can not be empty';
     }
     return Response::json($data);
 }
Exemplo n.º 12
0
 function test_find()
 {
     //Arrange
     $brand_name = "Nike";
     $id = 1;
     $test_brand = new Brand($brand_name, $id);
     $test_brand->save();
     //Act
     $result = Brand::find($test_brand->getId());
     //Assert
     $this->assertEquals($test_brand, $result);
 }
Exemplo n.º 13
0
 function testFind()
 {
     //Arrange
     $brand_name = "Super Kicks";
     $test_brand = new Brand($brand_name);
     $test_brand->save();
     $brand_name2 = "Cool Shoes";
     $test_brand2 = new Brand($brand_name2);
     $test_brand->save();
     //Act
     $id = $test_brand->getId();
     $result = Brand::find($id);
     //Assert
     $this->assertEquals($test_brand, $result);
 }
Exemplo n.º 14
0
 public function single_product()
 {
     $product_id = Request::segment(2);
     $product = Product::find($product_id);
     if (!$product) {
         $response_array = array('success' => 'false', 'error_code' => '406', 'error' => 'Product not found.');
         $response_code = 200;
         $response = Response::json($response_array, $response_code);
         return $response;
     } else {
         $response_array['success'] = 'true';
         $response_array['product'] = $product->toArray();
         $response_array['product']['brand'] = array();
         $response_array['product']['tags'] = array();
         $response_array['product']['alternatives'] = array();
         $brand = Brand::find($product->brand_id)->toArray();
         if ($brand) {
             $response_array['product']['brand'] = $brand;
         }
         $tags = DB::table('product_tag')->where('product_tag.product_id', $product->id)->leftJoin('options', 'product_tag.option_id', '=', 'options.id')->select('options.id', 'options.name')->get();
         if ($tags) {
             foreach ($tags as $tag) {
                 $tag = json_decode(json_encode($tag), true);
                 array_push($response_array['product']['tags'], $tag);
             }
         }
         $products = DB::table('product_alternative')->where('product_alternative.product_id', $product->id)->leftJoin('products', 'product_alternative.alternative_product_id', '=', 'products.id')->select('products.*')->get();
         if ($products) {
             foreach ($products as $product) {
                 $product = json_decode(json_encode($product), true);
                 array_push($response_array['product']['alternatives'], $product);
             }
         }
         $response_code = 200;
         $response = Response::json($response_array, $response_code);
         return $response;
     }
 }
Exemplo n.º 15
0
 function testFind()
 {
     //Arrange
     $brand_name = "Nike";
     $test_brand = new Brand($brand_name, $id);
     $test_brand->save();
     $brand_name2 = "Reebok";
     $test_brand2 = new Brand($brand_name2, $id2);
     $test_brand2->save();
     //Act
     $result = Brand::find($test_brand2->getId());
     //assert
     $this->assertEquals($test_brand2, $result);
 }
Exemplo n.º 16
0
 function test_brand_find()
 {
     //Arrange
     $brand_name = "Nike";
     $id1 = 1;
     $test_brand = new Brand($brand_name, $id1);
     $test_brand->save();
     $brand_name2 = "Converse";
     $id2 = 2;
     $test_brand2 = new Brand($brand_name2, $id2);
     $test_brand2->save();
     //Act
     $result = Brand::find($test_brand->getId());
     //Assert
     $this->assertEquals($test_brand, $result);
 }
Exemplo n.º 17
0
 function testFindById()
 {
     //Arrange
     $name = "Brand 1";
     $test_brand = new Brand($name);
     $test_brand->save();
     $name2 = "Brand 2";
     $test_brand2 = new Brand($name2);
     $test_brand2->save();
     //Act
     $search_id = $test_brand->getId();
     $result = Brand::find($search_id);
     //Assert
     $this->assertEquals($test_brand, $result);
 }
Exemplo n.º 18
0
 function testFind()
 {
     //Arrange
     $brand_name = "Feiyue";
     $test_brand = new Brand($brand_name, $id = null);
     $test_brand->save();
     $brand_name2 = "Kailai";
     $test_brand2 = new Brand($brand_name2, $id = null);
     $test_brand2->save();
     //Act
     $result = Brand::find($test_brand->getId());
     //Assert
     $this->assertEquals($test_brand, $result);
 }
Exemplo n.º 19
0
    return $app['twig']->render('brand_edit.html.twig', array('brand' => $brand));
});
$app->patch("/store/{id}", function ($id) use($app) {
    $store = Store::find($id);
    $store->update($_POST['name']);
    return $app['twig']->render('store.html.twig', array('store' => $store, 'brands' => $store->getBrands(), 'all_brands' => Brand::getAll()));
});
$app->patch("/brand/{id}", function ($id) use($app) {
    $brand = Brand::find($id);
    $brand->update($_POST['name']);
    return $app['twig']->render('brand.html.twig', array('brand' => $brand, 'stores' => $brand->getStores(), 'all_stores' => Store::getAll()));
});
$app->delete("/store/{id}", function ($id) use($app) {
    $store = Store::find($id);
    $store->delete();
    return $app['twig']->render('stores.html.twig', array('stores' => Store::getAll()));
});
$app->delete("/brand/{id}", function ($id) use($app) {
    $brand = Brand::find($id);
    $brand->delete();
    return $app['twig']->render('brands.html.twig', array('brands' => Brand::getAll()));
});
$app->post("/delete_brands", function () use($app) {
    Brand::deleteAll();
    return $app['twig']->render('index.html.twig');
});
$app->post("/delete_stores", function () use($app) {
    Store::deleteAll();
    return $app['twig']->render('index.html.twig');
});
return $app;
Exemplo n.º 20
0
 public function delete_brand()
 {
     $id = Request::segment(4);
     $brand = Brand::find($id);
     Brand::where('id', $id)->delete();
     $message = "Successfully deleted the brand";
     $type = "success";
     return Redirect::to('/admin/brands')->with('type', $type)->with('message', $message);
 }
Exemplo n.º 21
0
 function test_find()
 {
     $test_name = "Helmut Lang";
     $test_id = 1;
     $test_brand = new Brand($test_name, $test_id);
     $test_brand->save();
     $test_name2 = "Y-3";
     $test_id2 = 2;
     $test_brand2 = new Brand($test_name2, $test_id2);
     $test_brand2->save();
     $result = Brand::find($test_brand->getId());
     $this->assertEquals($test_brand, $result);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function getRemove($id)
 {
     $brand = Brand::find($id);
     $brand->delete();
     return Redirect::back()->with('success', 'Brand removed successfully.');
 }
Exemplo n.º 23
0
 public function getBrandEdit($id = "")
 {
     return \View::make("backend.brands.edit")->with("p_title", "Brands ")->with("subtitle", ">Edit")->with("mybrand", \Brand::find($id));
 }
Exemplo n.º 24
0
 public function getBrandName()
 {
     /* Start here get brand name */
     App::import("Model", "Brand");
     $Brand = new Brand();
     return $getproviderList = $Brand->find('list', array('fields' => array('Brand.id', 'Brand.brand_name')));
 }
Exemplo n.º 25
0
                        <?php 
if ($user->branch_id) {
    $branch = Branch::find($user->branch_id);
    if ($branch) {
        echo $branch->name;
    }
}
?>
                    </td>
                    -->
                    <td>
                        <?php 
if ($user->branch_id) {
    $branch = Branch::find($user->branch_id);
    if ($branch && isset($branch->brand_id) && $branch->brand_id) {
        $brand = Brand::find($branch->brand_id);
        if ($brand) {
            echo $brand->name;
        }
    }
}
?>
                    </td>
                    <td>
                        {{ $user->isActivated() ? trans('core::all.yes') : trans('core::all.no') }}
                    </td>
                    <td class="center" width="100">
                        <div>
                            @if($currentUser->hasAccess('update-user-info'))
                                <a class="btn btn-xs btn-teal tooltips" data-placement="top" data-original-title="Edit" href="{{ URL::route('showUser', $user->getId()) }}"><i class="fa fa-edit"></i></a>
                            @endif    
Exemplo n.º 26
0
 public function BrandAvatar($brand_id)
 {
     $brand = Brand::find((int) $brand_id);
     if (empty($brand) or empty($brand->image_thumb)) {
         return "/img/egghead.png";
     }
     return '/uploads/brand/' . $brand->image_thumb;
 }
 function testFind()
 {
     // Arrange
     $name = "Babbling Brooks";
     $test_Brand = new Brand($name);
     $test_Brand->save();
     $name2 = "Old Balance";
     $test_Brand2 = new Brand($name2);
     $test_Brand2->save();
     // Act
     $result = Brand::find($test_Brand2->getId());
     // Assert
     $this->assertEquals($test_Brand2, $result);
 }
Exemplo n.º 28
0
 function test_find()
 {
     //Arrange
     $brand_name = "La Sportiva";
     $test_brand = new Brand($brand_name);
     $test_brand->save();
     $brand_name2 = "Evolv";
     $test_brand2 = new Brand($brand_name2);
     $test_brand2->save();
     //Act
     $result = Brand::find($test_brand->getId());
     //Assert
     $this->assertEquals($test_brand, $result);
 }
Exemplo n.º 29
0
    return $app['twig']->render('stores.html.twig', array('stores' => Store::getAll()));
});
$app->post("/delete_brands", function () use($app) {
    Brand::deleteAll();
    return $app['twig']->render('brands.html.twig', array('brands' => Brand::getAll()));
});
//POSTS (ADDS)
$app->post("/add_stores", function () use($app) {
    $store = Store::find($_POST['store_id']);
    $brand = Brand::find($_POST['brand_id']);
    $brand->addStore($store);
    return $app['twig']->render('brand.html.twig', array('brand' => $brand, 'brands' => Brand::getAll(), 'stores' => $brand->getStores(), 'all_stores' => Store::getAll()));
});
$app->post("/add_brands", function () use($app) {
    $store = Store::find($_POST['store_id']);
    $brand = Brand::find($_POST['brand_id']);
    $store->addBrand($brand);
    return $app['twig']->render('store.html.twig', array('store' => $store, 'stores' => Store::getAll(), 'brands' => $store->getBrands(), 'all_brands' => Brand::getAll()));
});
//GET AND EDIT AND DELETE STORE ROUTE
$app->get("/stores/{id}/edit", function ($id) use($app) {
    $store = Store::find($id);
    return $app['twig']->render('store-edit.html.twig', array('store' => $store, 'brands' => $store->getBrands()));
});
$app->patch("/stores/{id}", function ($id) use($app) {
    $store = Store::find($id);
    $new_name = $_POST['new_name'];
    $store->update($new_name);
    return $app['twig']->render('stores.html.twig', array('store' => $store, 'stores' => Store::getAll(), 'brands' => $store->getBrands()));
});
$app->delete("/stores/{id}", function ($id) use($app) {
Exemplo n.º 30
0
 function test_find()
 {
     //Arrange
     $name = "Nike";
     $website = "http://www.nike.com";
     $test_brand = new Brand($name, $website);
     $test_brand->save();
     $name2 = "Adidas";
     $website2 = "http://www.adidas.com";
     $test_brand2 = new Brand($name2, $website2);
     $test_brand2->save();
     //Act
     $result = Brand::find($test_brand2->getId());
     //Assert
     $this->assertEquals($test_brand2, $result);
 }