app/Http/Controllers/TestScenarioController.php
/**
	 * Update the specified resource in storage.
	 *
	 * @param  int  $id
	 * @return Response
	 */
Update the specified resource in storage.
@param  int  $id
@return Response
Update the specified resource in storage . @param int $id @return Response
public function update($id, Request $request)
	{
		$validator = \Validator::make($request->all(), array(
			'name' => 'required' 
			));
		if ($validator->fails())
		{
			foreach ($validator->errors()->toArray() as $key => $value) {
				$error[]=$value[0];
			} 
		}
		else{
			if( session()->has('email')){
				$content['tsc_name']                = $request->name;
				$content['description']             = $request->description;
		        $content['expected_result']         = $request->expected_result;
		        $scenario_update 					= \App\TestScenario::find($id);
		        $old_description 					= $scenario_update->description;
		        $scenario_update->update($content);
		        if($request->update_level == "project"){
		        	$tp_id = session()->get('open_project');
		        	unset($content['tsc_name']);
		        	\App\TestScenario::where(['description' => $old_description, 'tp_id' => $tp_id])->update($content);
		        }
			 	return redirect()->route('scenario.show', ['id' => $id]);
		 	}else
		 	{
		 		$error[] = "Session expired. Please login to continue";
		 	}
	 	}
	 	return redirect()->route('scenario.edit', ['id' => $id, 'message' => $error])->withInput();
	}
public function update ( $ id , Request $ request ) { $ validator = \ Validator :: make ( $ request -> all ( ) , array ( 'name' => 'required' ) ) ; if ( $ validator -> fails ( ) ) { foreach ( $ validator -> errors ( ) -> toArray ( ) as $ key => $ value ) { $ error [ ] = $ value [ 0 ] ; } } else { if ( session ( ) -> has ( 'email' ) ) { $ content [ 'tsc_name' ] = $ request -> name ; $ content [ 'description' ] = $ request -> description ; $ content [ 'expected_result' ] = $ request -> expected_result ; $ scenario_update = \ App \ TestScenario :: find ( $ id ) ; $ old_description = $ scenario_update -> description ; $ scenario_update -> update ( $ content ) ; if ( $ request -> update_level == " project " ) { $ tp_id = session ( ) -> get ( 'open_project' ) ; unset ( $ content [ 'tsc_name' ] ) ; \ App \ TestScenario :: where ( [ 'description' => $ old_description , 'tp_id' => $ tp_id ] ) -> update ( $ content ) ; } return redirect ( ) -> route ( 'scenario.show' , [ 'id' => $ id ] ) ; } else { $ error [ ] = " Session expired. Please login to continue " ; } } return redirect ( ) -> route ( 'scenario.edit' , [ 'id' => $ id , 'message' => $ error ] ) -> withInput ( ) ; }
Update the specified resource in storage.
Update the specified resource in storage .
//Validations //'status' => 'required'         //Process when validations pass