app/Http/Controllers/TestScenarioController.php
/**
	 * Store a newly created resource in storage.
	 *
	 * @return Response
	 */
Store a newly created resource in storage.
@return Response
Store a newly created resource in storage . @return Response
public function store(Request $request)
	{
		$messages = [
		    'tf_id.not_in' => 'The functionality field is required.'
		];
		$validator = \Validator::make($request->all(), array(
			'name' => 'required',
			'tf_id' => 'not_in:none'
			), $messages);
		if ($validator->fails())
		{
			foreach ($validator->errors()->toArray() as $key => $value) {
				$error[]=$value[0];
			} 
		}
		else{
			if( session()->has('email')){
				$content['tp_id']               	= session()->get('open_project');
				$content['tf_id']               	= $request->tf_id;				
				$content['tsc_id']                 	= $request->tf_id."_".$this->genrateRandomInt(4);		
				$content['tsc_name']                = $request->name;
				$content['scenario_brief']          = "";
				$content['description']             = $request->description;
		        $content['expected_result']         = $request->expected_result;		
		        $content['status'] 					= "not_executed";
		       	$count 								= \App\TestScenario::where('tf_id',  $content['tf_id'])->count();
		       	$content['seq_no'] 	        		= $count+1;
		       	$content['actual_result'] 	  		= "not_executed";
			 	$create 							= \App\TestScenario::create($content);
		        return redirect()->route('profile');
		 	}else
		 	{
		 		$error[] = "Session expired. Please login to continue";
		 	}
	 	}
	 	return redirect()->route('scenario.create', ['message' => $error])->withInput();
	}
public function store ( Request $ request ) { $ messages = [ 'tf_id.not_in' => 'The functionality field is required.' ] ; $ validator = \ Validator :: make ( $ request -> all ( ) , array ( 'name' => 'required' , 'tf_id' => 'not_in:none' ) , $ messages ) ; if ( $ validator -> fails ( ) ) { foreach ( $ validator -> errors ( ) -> toArray ( ) as $ key => $ value ) { $ error [ ] = $ value [ 0 ] ; } } else { if ( session ( ) -> has ( 'email' ) ) { $ content [ 'tp_id' ] = session ( ) -> get ( 'open_project' ) ; $ content [ 'tf_id' ] = $ request -> tf_id ; $ content [ 'tsc_id' ] = $ request -> tf_id . " _ " . $ this -> genrateRandomInt ( 4 ) ; $ content [ 'tsc_name' ] = $ request -> name ; $ content [ 'scenario_brief' ] = " " ; $ content [ 'description' ] = $ request -> description ; $ content [ 'expected_result' ] = $ request -> expected_result ; $ content [ 'status' ] = " not_executed " ; $ count = \ App \ TestScenario :: where ( 'tf_id' , $ content [ 'tf_id' ] ) -> count ( ) ; $ content [ 'seq_no' ] = $ count + 1 ; $ content [ 'actual_result' ] = " not_executed " ; $ create = \ App \ TestScenario :: create ( $ content ) ; return redirect ( ) -> route ( 'profile' ) ; } else { $ error [ ] = " Session expired. Please login to continue " ; } } return redirect ( ) -> route ( 'scenario.create' , [ 'message' => $ error ] ) -> withInput ( ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
//Validations //Process when validations pass