本文整理汇总了PHP中ProductCategory::find方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductCategory::find方法的具体用法?PHP ProductCategory::find怎么用?PHP ProductCategory::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProductCategory
的用法示例。
在下文中一共展示了ProductCategory::find方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addmodels
public function addmodels($id)
{
if ($this->isAdminRequest()) {
//$id = $_POST['id'];
// print_r($_POST);
$rules = array('models' => 'required');
$validator = Validator::make(Input::all(), $rules);
// process the login
if ($validator->fails()) {
return Redirect::to('admin/products/' . $id . '/models')->withErrors($validator)->with('productcategory', ProductCategory::find($id))->with('models', Products::where('product_category_id', '=', $id)->get())->withInput(Input::all());
} else {
$models = Input::get('models');
$models_arr = explode(",", $models);
foreach ($models_arr as $model) {
$product_model = new Products();
$product_model->model_id = $model;
$product_model->product_category_id = $id;
$product_model->save();
}
// // redirect
Session::flash('message', 'Successfully added models.');
return Redirect::to('admin/products/' . $id . '/models');
}
//$import = importmodels('boo');
//
// $productcategory = ProductCategory::find($id);
// $models = Products::where('product_category_id','=',$id)->get();
// return View::make('admin.products.models')
// ->with('productcategory',$productcategory)
// ->with('models',$models);
// }
}
}
示例2: getProductCategories
/**
* Get all categories of product.
* @return an array with contains information of product categories
*/
public function getProductCategories()
{
$categories = array();
$resultSet = ProductCategory::find();
foreach ($resultSet as $rowSet) {
array_push($categories, array('productCategoryId' => $rowSet->getProductCategoryId(), 'productCategorySlug' => $rowSet->getProductCategorySlug(), 'productCategoryName' => (array) json_decode($rowSet->getProductCategoryName())));
}
return $categories;
}
示例3: testResetDepths
/**
* testResetDepths method
*
* Tests TreePlusBehavior::resetDepths().
*
* @return void
* @access public
*/
public function testResetDepths()
{
$this->ProductCategory->resetDepths();
$result = $this->ProductCategory->find('list', array('fields' => array('id', 'depth'), 'order' => array('id' => 'ASC'), 'recursive' => false));
$this->assertEqual(array_values($result), array(0, 1, 1, 0, 1, 1));
}
示例4: setdefault
public function setdefault($id, $fileid)
{
//
$default = ProductCategory::find($id);
if ($default->default_image == $fileid) {
$default->default_image = '';
} else {
$default->default_image = $fileid;
}
$default->save();
Session::flash('message', 'Successfully set default status for ' . $default->title);
return Redirect::to('admin/products/' . $id . '/files');
}
示例5: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
//
if ($this->isAdminRequest()) {
// delete
$product = ProductCategory::find($id);
$product->delete();
$product->products()->delete();
$product->children()->delete();
// redirect
Session::flash('message', 'Successfully deleted the Product!');
return Redirect::to('admin/products');
}
}