public function postImageDestroy() { $portfolio_item = Portfolio::find(Input::get('id')); if ($portfolio_item) { $portfolio_item->image = ''; $portfolio_item->save(); return Redirect::back()->with('message', 'Элемент удален'); } return Redirect::back()->with('message', "Ошибка"); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Portfolio::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', 'caption', $this->caption])->andFilterWhere(['like', 'alt', $this->alt])->andFilterWhere(['like', 'description', $this->description]); return $dataProvider; }
/** * Remove the specified resource from storage. * DELETE /portfolios/{id} * * @param int $id * @return Response */ public function destroy($id) { $portfolio = Portfolio::find($id); $portfolio->delete(); return Redirect::to('/portfolios')->with('okmessage', 'Portfolio deleted'); }