public function searchMaterial($name, $status, $availability, $categorie) { $qeury = Material::select('*'); if ($name != '') { $qeury = $qeury->where('name', 'LIKE', '%' . $name . '%'); } if ($status != 'all') { $qeury = $qeury->where('status', '=', $status); } if ($availability != 'all') { $qeury = $qeury->where('availability', '=', $availability); } if ($categorie != 'all') { $qeury = $qeury->whereHas('categories', function ($q) use($categorie) { $q->where('categories.id', '=', $categorie); }); } $result = $qeury->get(); return $result; }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { if (Auth::check()) { $this->material = Material::find($id); if ($this->material->fill(Input::all())->isValid('edit')) { if (Input::hasFile('image')) { $filename = substr_replace(Input::file('image')->getClientOriginalName(), "", -4) . Input::get('name') . '.png'; $image = Image::make(Input::file('image')->getRealPath())->heighten(500); $image->crop(500, 500); $destenation = 'images/' . $filename; $image->save($destenation); } else { $material = Material::select('image')->find($id); $filename = $material->image; } $this->material->image = $filename; $this->material->save(); $this->categorie->updateMaterialCategorie(Input::get('categorie'), $id); if (!empty(Input::get('accessories'))) { $this->accessorie->updateAccessories(Input::get('accessories'), $this->material->id); } return Redirect::to('/beheer/materiaal')->with('message', 'u hebt succesvol ' . Input::get('name') . ' aangepast'); } else { return Redirect::back()->withInput()->withErrors($this->material->errors); } } else { return Redirect::to('/'); } }