本文整理汇总了PHP中Brand::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Brand::find方法的具体用法?PHP Brand::find怎么用?PHP Brand::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Brand
的用法示例。
在下文中一共展示了Brand::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addProducts
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);
}
示例2: getBrands
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;
}
示例3: postUpdate
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']);
}
示例4: testFind
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);
}
示例5: testFind
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);
}
示例6: totalProductWorth
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;
}
示例7: UpdateListBrand
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();
}
}
}
示例8: update
/**
* 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');
}
}
示例9: test_find
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);
}
示例10: putEdit
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');
}
示例11: saveAddCategory
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);
}
示例12: test_find
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);
}
示例13: testFind
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);
}
示例14: single_product
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;
}
}
示例15: testFind
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);
}