public function updateAccessories($accessories, $materialId)
 {
     Accessorie::where('fk_mastermaterial', '=', $materialId)->orwhere('fk_slavematerial', '=', $materialId)->delete();
     $insertValues = array();
     foreach ($accessories as $accessorie) {
         $insertValues[] = array('fk_mastermaterial' => $materialId, 'fk_slavematerial' => $accessorie);
         $insertValues[] = array('fk_mastermaterial' => $accessorie, 'fk_slavematerial' => $materialId);
     }
     Accessorie::insert($insertValues);
 }
 public function index()
 {
     if (Auth::check()) {
         $categories = $this->categorie->getCategoriesWhitMaterials();
         $users = User::where('id', '!=', Auth::user()->id)->get();
         $accessories = Accessorie::getAllAccessories();
         return View::make('users.index', ['categories' => $categories, 'users' => $users, 'accessories' => $accessories]);
     } else {
         return Redirect::to('/')->with('error', 'Je bent niet ingelogd');
     }
 }
 public function deleteMaterial($id)
 {
     DB::table('materialcategories')->where('fk_materialsid', '=', $id)->delete();
     Accessorie::where('fk_mastermaterial', '=', $id)->orwhere('fk_slavematerial', '=', $id)->delete();
     Material::where('id', '=', $id)->delete();
 }