app/Http/Controllers/TreeviewController.php
/**
	 * Display a listing of the resource.
	 *
	 * @return Response
	 */
Display a listing of the resource.
@return Response
Display a listing of the resource . @return Response
public function index($id)
	{
		$user = \App\User::where('email',session()->get('email'))->update(['open_project' => $id]);
		$p_value = \App\TestProject::find($id);
		session(['open_project' => $id, 'project_name' => $p_value->tp_name ]);
	  	$tree = array();
	  		$testfunctionalities = \App\TestFunctionality::where('tp_id', $p_value->tp_id)->get();
			$tp_count = count($testfunctionalities);
	  		$tree_node = array();
	  		$tree_node['text'] =  $p_value->tp_name;
			$tree_node['tags']  = [$tp_count];
			$tree_node['backColor']  = '#dddfd4';
	  		$url = route('project.show' , ['id' => $id] );
			$tree_node['href'] = $url;
			foreach ($testfunctionalities as $functionality) {
				$testscenarios = \App\TestScenario::where(['tp_id' => $p_value->tp_id , 'tf_id' => $functionality->tf_id ])->orderBy('seq_no', 'asc')->get();
				$tsc_count = count($testscenarios);
				$f_node = array();
				$f_node['text'] = $functionality->tf_name;
				$f_node['href'] = route('functionality.show' , ['id' => $functionality->tf_id] );
				$f_node['title']  = $functionality->description;;
				$f_node['tags']  = [$tsc_count];
				$f_node['backColor']  = '#c9d8c5';
				foreach ($testscenarios as $scenario) {
					$testcases = \App\TestCase::where(['tp_id' => $p_value->tp_id , 'tsc_id' => $scenario->tsc_id ])->orderBy('seq_no', 'asc')->get();
					$tc_count = count($testcases);
					$s_node = array();
					$s_node['text'] = $scenario->tsc_name;
					$s_node['href'] = route('scenario.show' , ['id' => $scenario->tsc_id] );
					$s_node['help']  = $scenario->description;
					$s_node['tags']  = [$tc_count];
					$s_node['backColor']  = '#e9ece5';
					foreach ($testcases as $case) {
						$teststeps = \App\TestStep::where(['tp_id' => $p_value->tp_id , 'tc_id' => $case->tc_id , 'soft_delete' => false])->get();
						$ts_count = count($teststeps);
						$c_node = array();
						$c_node['text'] = $case->tc_name;	
						$c_node['tooltip']  = $case->description;
						$c_node['href'] = route('testcase.show' , ['id' => $case->tc_id] );
						$c_node['tags']  = [$ts_count];
						$s_node['nodes'][] = $c_node;			
					}
					$f_node['nodes'][] = $s_node;
				}
	  			$tree_node['nodes'][] = $f_node ;	  			
			}	
			$tree[] = $tree_node;
	  	return $tree;
	}
public function index ( $ id ) { $ user = \ App \ User :: where ( 'email' , session ( ) -> get ( 'email' ) ) -> update ( [ 'open_project' => $ id ] ) ; $ p_value = \ App \ TestProject :: find ( $ id ) ; session ( [ 'open_project' => $ id , 'project_name' => $ p_value -> tp_name ] ) ; $ tree = array ( ) ; $ testfunctionalities = \ App \ TestFunctionality :: where ( 'tp_id' , $ p_value -> tp_id ) -> get ( ) ; $ tp_count = count ( $ testfunctionalities ) ; $ tree_node = array ( ) ; $ tree_node [ 'text' ] = $ p_value -> tp_name ; $ tree_node [ 'tags' ] = [ $ tp_count ] ; $ tree_node [ 'backColor' ] = '#dddfd4' ; $ url = route ( 'project.show' , [ 'id' => $ id ] ) ; $ tree_node [ 'href' ] = $ url ; foreach ( $ testfunctionalities as $ functionality ) { $ testscenarios = \ App \ TestScenario :: where ( [ 'tp_id' => $ p_value -> tp_id , 'tf_id' => $ functionality -> tf_id ] ) -> orderBy ( 'seq_no' , 'asc' ) -> get ( ) ; $ tsc_count = count ( $ testscenarios ) ; $ f_node = array ( ) ; $ f_node [ 'text' ] = $ functionality -> tf_name ; $ f_node [ 'href' ] = route ( 'functionality.show' , [ 'id' => $ functionality -> tf_id ] ) ; $ f_node [ 'title' ] = $ functionality -> description ; ; $ f_node [ 'tags' ] = [ $ tsc_count ] ; $ f_node [ 'backColor' ] = '#c9d8c5' ; foreach ( $ testscenarios as $ scenario ) { $ testcases = \ App \ TestCase :: where ( [ 'tp_id' => $ p_value -> tp_id , 'tsc_id' => $ scenario -> tsc_id ] ) -> orderBy ( 'seq_no' , 'asc' ) -> get ( ) ; $ tc_count = count ( $ testcases ) ; $ s_node = array ( ) ; $ s_node [ 'text' ] = $ scenario -> tsc_name ; $ s_node [ 'href' ] = route ( 'scenario.show' , [ 'id' => $ scenario -> tsc_id ] ) ; $ s_node [ 'help' ] = $ scenario -> description ; $ s_node [ 'tags' ] = [ $ tc_count ] ; $ s_node [ 'backColor' ] = '#e9ece5' ; foreach ( $ testcases as $ case ) { $ teststeps = \ App \ TestStep :: where ( [ 'tp_id' => $ p_value -> tp_id , 'tc_id' => $ case -> tc_id , 'soft_delete' => false ] ) -> get ( ) ; $ ts_count = count ( $ teststeps ) ; $ c_node = array ( ) ; $ c_node [ 'text' ] = $ case -> tc_name ; $ c_node [ 'tooltip' ] = $ case -> description ; $ c_node [ 'href' ] = route ( 'testcase.show' , [ 'id' => $ case -> tc_id ] ) ; $ c_node [ 'tags' ] = [ $ ts_count ] ; $ s_node [ 'nodes' ] [ ] = $ c_node ; } $ f_node [ 'nodes' ] [ ] = $ s_node ; } $ tree_node [ 'nodes' ] [ ] = $ f_node ; } $ tree [ ] = $ tree_node ; return $ tree ; }
Display a listing of the resource.
Display a listing of the resource .
//foreach ($projects as $key => $p_value) { //Take each project node and find associated functionalities  //"#".$p_value->tp_id; //Repeat same for scenarios //Repeat same for cases	 /*
						//Child node of test cases is test step and there node details added below
						foreach ($teststeps as $step) {
							$st_node = array();
							$st_node['text'] = "St - ".$step->description;	
							$st_node['href'] = route('teststep.show' , ['id' => $step->ts_id] );
							$c_node['nodes'][] = $st_node;
						}*/ //create node for case and add to scenario //create node for scenario and add to functionality //create node for functionality and add to project  //eventually forming the data for tree node //} //return tree format data