public function addReservation() { $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ023456789"; srand((double) microtime() * 1000000); $i = 0; $pass = ''; while ($i <= 7) { $num = rand() % 33; $tmp = substr($chars, $num, 1); $pass = $pass . $tmp; $i++; } $finalcode = 'ID-' . $pass; $cancellation = Maintenance::where(['name' => 'cancellation fee', 'type' => 'fee'])->first(); return View::make('admin.reservation')->withTerms(Condition::orderBy('number')->get())->withCancellation($cancellation)->withFinalcode($finalcode); }