public function post_new() { $input = Input::all(); //grab our input $rules = array('name' => 'required|alpha', 'lastName' => 'required|alpha', 'permit' => 'required|min:2', 'lot' => 'required|integer', 'msc' => 'integer', 'ticket' => 'required|min:2|numeric|unique:tickets,ticketID', 'fineAmt' => 'required|numeric', 'licensePlate' => 'required|alpha_num', 'licensePlateState' => 'required|max:2', 'dateIssued' => 'required', 'violations' => 'required', 'areaOfViolation' => 'required|alpha_num', 'appealLetter' => 'required|max:700'); //validation rules $validation = Validator::make($input, $rules); //let's run the validator if ($validation->fails()) { return Redirect::to('appeal/new')->with_errors($validation); } //hashing the name of the file uploaded for security sake //then we'll be dropping it into the public/uploads file //get the file extension $extension = File::extension($input['appealLetter']['name']); //encrypt the file name $file = Crypter::encrypt($input['appealLetter']['name'] . time()); //for when the crypter likes to put slashes in our scrambled filname $file = preg_replace('#/+#', '', $file); //concatenate extension and filename $filename = $file . "." . $extension; Input::upload('appealLetter', path('public') . 'uploads/', $filename); //format the fine amount in case someone screws it up $fineamt = number_format(Input::get('fineAmt'), 2, '.', ''); //inserts the form data into the database assuming we pass validation Appeal::create(array('name' => Input::get('name'), 'lastName' => Input::get('lastName'), 'permitNumber' => Input::get('permit'), 'assignedLot' => Input::get('lot'), 'MSC' => Input::get('msc'), 'ticketID' => Input::get('ticket'), 'fineAmt' => $fineamt, 'licensePlate' => Str::upper(Input::get('licensePlate')), 'licensePlateState' => Input::get('licensePlateState'), 'dateIssued' => date('Y-m-d', strtotime(Input::get('dateIssued'))), 'violations' => Input::get('violations'), 'areaOfViolation' => Input::get('areaOfViolation'), 'letterlocation' => URL::to('uploads/' . $filename), 'CWID' => Session::get('cwid'))); return Redirect::to('appeal/')->with('alertMessage', 'Appeal submitted successfully.'); }