Created
April 18, 2019 14:48
-
-
Save mikestratton/740462905bd62778ff78fe120ab71c2b to your computer and use it in GitHub Desktop.
Environmental Assessment Software
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This function store results of a technicians work for | |
an EPA regulated firm. The technician would login and | |
calculate the square footage(with roof area includes | |
Pythagorean theorem) using a javascript calculator. He | |
would then enter the value found and save. The square | |
footage found would then define then number of samples | |
necessary for the EPA tech to take. | |
... | |
*/ | |
public function store(DefinitionsCreateRequest $request) | |
{ | |
$input = $request->all(); | |
$input['surveyor_id'] = Auth::id(); | |
$quantity = $request->input('quantity'); | |
$samples = 0; | |
if($quantity <= 999){ | |
$samples = 3; | |
} | |
elseif($quantity >= 1000 && $quantity <= 4999){ | |
$samples = 5; | |
} | |
elseif($quantity >= 5000){ | |
$samples = 7; | |
} | |
$input['samples_required'] = $samples; | |
$definition = Definition::create($input); | |
$definition_id = $definition->id; | |
// sample | |
$data = [ | |
'property_id' => $request->property_id, | |
'surveyor_id' => Auth::id(), | |
'samples_required' => $samples, | |
'definition_id' => $definition_id, | |
'description_id' => $request->description_id, | |
]; | |
$property_id = $request->property_id; | |
//does property record exist? | |
if(Sample::where('property_id', '=', $property_id)->exists()) { | |
$i = 1; | |
$j = DB::table('samples') | |
->where('property_id', '=', $property_id) | |
->max('counter'); | |
while($i <= $samples) { | |
$k = $i + $j; | |
$data['counter'] = $k; | |
Sample::create($data); | |
$i++; | |
} | |
} | |
else{ | |
$i = 1; | |
while($i <= $samples) { | |
$data['counter'] = $i; | |
Sample::create($data); | |
$i++; | |
} | |
} | |
return redirect('/surveyor/define-ha'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment