コード例 #1
0
 public function run()
 {
     $borrowers = [['lname' => 'Benitez', 'fname' => 'Jervey', 'mname' => 'Ricablanca', 'gender' => 'male', 'home_address' => 'Palao, Iligan City', 'created_at' => new DateTime(), 'updated_at' => new DateTime()], ['lname' => 'Oponda', 'fname' => 'Wenhern Ralph', 'mname' => 'Olita', 'gender' => 'male', 'home_address' => 'Gango, Ozamiz City', 'created_at' => new DateTime(), 'updated_at' => new DateTime()], ['lname' => 'Britania', 'fname' => 'Jay Steven', 'mname' => 'Anduyan', 'gender' => 'male', 'home_address' => 'Davao City', 'created_at' => new DateTime(), 'updated_at' => new DateTime()], ['lname' => 'Podiotan', 'fname' => 'Sunshine', 'mname' => 'Encabo', 'gender' => 'female', 'home_address' => 'Aloran, Misamis Occidental', 'created_at' => new DateTime(), 'updated_at' => new DateTime()]];
     Eloquent::unguard();
     foreach ($borrowers as $borrower) {
         Borrower::create($borrower);
     }
 }
コード例 #2
0
 public function store()
 {
     $input = Input::all();
     $rules = array('username' => 'required|min:5|unique:users,username', 'password' => 'required|confirmed', 'password_confirmation' => 'same:password', 'borrower_code' => 'required|unique:borrowers,borrower_code', 'first_name' => 'required', 'last_name' => 'required');
     $custom_error = array('borrower_code.unique' => 'The Student ID was already been taken. Ask Librarian to create your account.');
     $validation = Validator::make($input, $rules, $custom_error);
     if ($validation->passes()) {
         $borrower = new Borrower();
         $borrower->borrower_code = Input::get('borrower_code');
         $borrower->first_name = Input::get('first_name');
         $borrower->last_name = Input::get('last_name');
         $borrower->penalty = 0;
         $borrower->save();
         $user = new User();
         $user->username = Input::get('username');
         $user->password = Hash::make(Input::get('password'));
         $user->previlage = 1;
         $user->borrower_id = $borrower->id;
         $user->save();
         return Redirect::route('login')->with('flash_error', 'You have been successfully registered. Please sign-in to continue.')->with('flash_color', '#27ae60');
     } else {
         return Redirect::back()->withInput()->withErrors($validation)->with('flash_error', 'Validation Errors!');
     }
 }
コード例 #3
0
 /** Additional functions.
  *
  */
 public function addLoan($id)
 {
     $results = Borrower::find($id);
     return View::make('borrowers.addloan')->with('borrower', $results);
 }
コード例 #4
0
 public function delete($id)
 {
     $borrower = Borrower::find($id);
     if ($borrower != null) {
         DB::table('borrowers')->where('id', $id)->delete();
         $borrower->delete();
     } else {
         throw new Exception("Borrower not found.");
     }
 }
コード例 #5
0
 static function findBorrowerRatingById($id = NULL)
 {
     $model = new Borrower();
     $detail = $model->findByUserId($id);
     $ratingIndex = $detail->rating;
     return self::findBorrowerRatingOptions($ratingIndex);
 }