diff --git a/app/Http/Controllers/PaycheckController.php b/app/Http/Controllers/PaycheckController.php new file mode 100644 index 0000000..f1e1a22 --- /dev/null +++ b/app/Http/Controllers/PaycheckController.php @@ -0,0 +1,79 @@ + '', 'payrate' => '', 'grosspay' => '', 'netpay' => '', 'fedtax' => '', 'statetax' => '', 'sstax' => '', 'medtax' => '']); + } + public function results(Request $stuff) + { + $hours = $stuff->input('hours'); + $payrate = $stuff->input('payrate'); + $grosspay; + $netpay; + $fedtax; + $statetax; + $sstax; + $medtax; + $totaltax; + + $empthours = isset($hours); + $emptpayrate = isset($payrate); + + if (!$empthours | !$emptpayrate) + { + return view('paycheck', ['hours' => 'd', 'payrate' => '', 'grosspay' => '', 'netpay' => '', 'fedtax' => '', 'statetax' => '', 'sstax' => '', 'medtax' => '']); + } + + $grosspay = $hours * $payrate; + if ($grosspay < 87) + { + $fedtax = 0; + } + else if ($grosspay >= 87 && $grosspay < 443) + { + $fedtax = floor(($grosspay - 88.50) * .10 * 100)/100; + } + else if ($grosspay >= 443 && $grosspay < 1529) + { + $fedtax = floor(($grosspay - 208.00) * .15 * 100)/100; + } + else if ($grosspay <= 1529 && $grosspay < 3925) + { + $fedtax = floor(($grosspay - 744.04) * .25 * 100)/100; + } + + $statetax = round($grosspay * .0375 * 100)/100; + + if ($hours >=26) + { + $sstax = round(($grosspay * .062) * 100)/100; + } + else + { + $sstax = 0; + } + + if ($hours >= 26) + { + $medtax = round(($grosspay * .0145) * 100)/100; + } + else + { + $medtax = 0; + } + + + $totaltax = $fedtax + $statetax + $sstax + $medtax; + $netpay = $grosspay - $totaltax; + + + return view('paycheck', ['hours' => $hours, 'payrate' => $payrate, 'grosspay' => $grosspay, 'netpay' => $netpay, 'fedtax' => $fedtax, 'statetax' => $statetax, 'sstax' => $sstax, 'medtax' => $medtax]); + } +} diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index 532b569..8d6ac12 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -9,14 +9,24 @@ - +

HomeIsWhereTheMoneyIs

-
+


- + +

+
diff --git a/resources/views/paycheck.blade.php b/resources/views/paycheck.blade.php new file mode 100644 index 0000000..b1cb9c1 --- /dev/null +++ b/resources/views/paycheck.blade.php @@ -0,0 +1,88 @@ + + + + Paycheck Calculator + + + + + + + + + + + +
+

Home

+
+
+

Bi-weekly paycheck calculator

+

+ {!! Form::open(array('action' => 'PaycheckController@results')) !!} +

+ {{ Form::label('hourslbl', 'hours') }} +

+

+ {{ Form::text('hours') }} +

+

+ {{ Form::label('payratelbl', 'payrate') }} +

+

+ {{ Form::text('payrate') }} +

+

+ {{ Form::button('do it', array('type' => 'submit')) }} +

+ {!! Form::close() !!} + @if ($hours!=='d') + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ @endif + @if ($hours==='d') +

Remember to fill in all the fields

+ @endif +
+ + diff --git a/routes/web.php b/routes/web.php index e373291..f3e49f9 100755 --- a/routes/web.php +++ b/routes/web.php @@ -34,3 +34,5 @@ Route::get('hotboy', function () { Route::get('stunt', function () { return "Check the database, I think someone was created"; }); +Route::get('paycheck', 'PaycheckController@display'); +Route::post('paycheck/biweekly', 'PaycheckController@results');