本文整理汇总了PHP中app\models\Item::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::find方法的具体用法?PHP Item::find怎么用?PHP Item::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Item
的用法示例。
在下文中一共展示了Item::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Update the specified resource in storage.
*
* @param ProductRequest $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(ProductRequest $request, $id)
{
$input = $request->all();
$input['type'] = 'Product';
Item::find($id)->update($input);
return redirect()->route('product.index')->withMessage('Product has been Updated')->withStatus('success');
}
示例2: delete
public function delete(Request $request, $id)
{
$b = Item::find($id);
$b->name = $request->input('name');
$b->delete();
return Redirect('itemmaster');
}
示例3: actionIndex
/**
* @return string
*/
public function actionIndex()
{
$low_stock_items = Item::find()->where('quantity >= 1 AND quantity <= 10')->all();
$empty_stock_items = Item::find()->where('quantity = 0')->all();
$logs = Log::find()->orderBy('created_at DESC')->limit(10)->all();
return $this->render('index', ['low_stock_items' => $low_stock_items, 'empty_stock_items' => $empty_stock_items, 'logs' => $logs]);
}
示例4: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
$item = \App\Models\Item::find($id);
$item->delete();
return redirect('toDo');
}
示例5: store
/**
* POST /api/itemRequests
* @param StoreItemRequest $request
* @return Response
*/
public function store(StoreItemRequest $request)
{
$currentUser = Auth::user();
if ($currentUser && $this->itemsRepository->itemAlreadyExists($request)) {
//Checking $currentUser is true because if it's feedback sent from one of my apps,
//the itemAlreadyExists method will throw an exception because the user isn't logged in
return response(['error' => "You already have this item here.", 'status' => Response::HTTP_BAD_REQUEST], Response::HTTP_BAD_REQUEST);
} else {
$item = new Item($request->only(['title', 'body', 'priority', 'urgency', 'favourite', 'alarm', 'not_before', 'recurring_unit', 'recurring_frequency']));
if ($request->get('recurring_unit') === 'none') {
$item->recurring_unit = null;
}
//This is because the alarm was getting set to 0000-00-00 00:00:00 when no alarm was specified
if ($request->has('alarm') && !$request->get('alarm')) {
$item->alarm = null;
}
$parent = false;
if ($request->get('parent_id')) {
$parent = Item::find($request->get('parent_id'));
$item->parent()->associate($parent);
}
if ($currentUser) {
$item->user()->associate(Auth::user());
} else {
//User is not logged in. It could be a feedback request from one of my apps. Add the item to my items (user_id 1).
$item->user()->associate(1);
}
$item->category()->associate(Category::find($request->get('category_id')));
$item->index = $item->calculateIndex($request->get('index'), $parent);
$item->save();
$item = $this->transform($this->createItem($item, new ItemTransformer()))['data'];
return response($item, Response::HTTP_CREATED);
}
}
示例6: indexAction
public function indexAction($test = null)
{
$items = Item::find();
// throw new ApiException('fuck!');
$this->setMessage(':D');
$this->setError('D:');
return $items;
}
示例7: remove
public function remove()
{
// Get task
$listItem = $this->getTask();
// Remove task
Item::find($listItem)->delete();
return redirect()->back();
}
示例8: create
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create($id)
{
//Create stock
// Get item
$item = Item::find($id);
// Get suppliers for select list
$suppliers = Supplier::lists('name', 'id');
return View::make('inventory.stock.create')->with('item', $item)->with('suppliers', $suppliers);
}
示例9: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$this->validation_rules($request);
$itemUpdate = $request->input();
$item = Item::find($id);
$item->update($itemUpdate);
Session::flash('flash_message', 'Data item layanan berhasil diupdate!');
return redirect('admin/item');
}
示例10: actionUpdate
/**
* Updates an existing Menu model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
$dataProvider = new ActiveDataProvider(['query' => Item::find()->joinWith('menuItems')->where(['menu_id' => $model->menu_id]), 'pagination' => ['pageSize' => 10]]);
$all_items = Item::find()->all();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->menu_id]);
} else {
return $this->render('update', ['model' => $model, 'dataProvider' => $dataProvider, 'all_items' => $all_items]);
}
}
示例11: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Item::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id]);
$query->andFilterWhere(['like', 'descricao', $this->descricao])->andFilterWhere(['like', 'tipo', $this->tipo]);
return $dataProvider;
}
示例12: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Item::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'category' => $this->category, 'compressive' => $this->compressive, 'density' => $this->density]);
$query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'created', $this->created])->andFilterWhere(['like', 'url', $this->url])->andFilterWhere(['like', 'field', $this->field])->andFilterWhere(['like', 'price', $this->price])->andFilterWhere(['like', 'absorption', $this->absorption])->andFilterWhere(['like', 'img', $this->img])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'content', $this->content]);
return $dataProvider;
}
示例13: update
/**
* Updates all book metadata
*
* @param $request
* @param $product
*/
public function update($request, $product)
{
\DB::beginTransaction();
$product->is->update($request->all());
$product->is->authors()->sync($request['author-list']);
$product->update($request->all());
$item = Item::find($product->organizations()->first()->pivot->id);
$item->update($request->all());
if ($request['tag-list']) {
$item->tags()->sync($request['tag-list']);
} else {
$item->tags()->detach();
}
\DB::commit();
}
示例14: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Item::find();
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10], 'sort' => ['defaultOrder' => ['updated_at' => SORT_DESC]]]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
// grid filtering conditions
$query->andFilterWhere(['id' => $this->id, 'quantity' => $this->quantity, 'stock' => $this->stock, 'price' => $this->price, 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by]);
$query->andFilterWhere(['like', 'code', $this->code])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'unit', $this->unit]);
return $dataProvider;
}
示例15: searchWithItem
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function searchWithItem($params)
{
$query = Item::find();
$query->innerJoinWith('itemPrices.price');
$query->joinWith('billItems');
$query->orderBy(BillItem::tableName() . '.quantity DESC');
$dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => new Sort(['attributes' => ['name', 'code', 'quantity', 'quantity_stock', 'created_at', 'updated_at', 'item_total' => ['asc' => ['price.total' => SORT_ASC], 'desc' => ['price.total' => SORT_DESC]]]])]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['quantity' => $this->quantity, 'quantity_stock' => $this->quantity_stock, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
$query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'code', $this->code])->andFilterWhere(['like', 'price.total', $this->item_total]);
return $dataProvider;
}