public function testArrayRemoveBlanks() { // arrange $array = [1, null, 'two', '', 3]; // act $filteredArray = array_remove_blanks($array); // assert $expected = [0 => 1, 2 => 'two', 4 => 3]; $this->assertEquals($expected, $filteredArray); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { $obj = $this->model->findOrFail($id); $obj->fill(Input::all()); $obj->save(); if ($obj->errors()->any()) { // var_dump($obj->errors());exit; return Redirect::route($this->modelName . '.edit', $id)->withInput()->withErrors($obj->errors()); } // save related $obj->attributeValues()->sync(array_remove_blanks(Input::get('attributeValues', []))); return Redirect::route('opportunities.show', $obj->uid)->with('myflash', 'Your service opportunity has been updated.'); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { $obj = $this->model->findOrFail($id); $input = Input::all(); if (isset($input['logo']) && $input['logo']) { $input['logo'] = $this->uploadHandler->handle($input['logo'], Beneficiary::LOGO_DIR); // TODO error handling } else { unset($input['logo']); } $obj->fill($input); $obj->save(); if ($obj->errors()->any()) { // var_dump($obj->errors());exit; return Redirect::route($this->modelName . '.edit', $id)->withInput()->withErrors($obj->errors()); } // save related $obj->attributeValues()->sync(array_remove_blanks(Input::get('attributeValues', []))); return Redirect::route('beneficiaries.show', $obj->uid)->with('myflash', 'Your beneficiary has been updated.'); }