コード例 #1
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  [int]  $id
  * @return [Response]
  */
 public function destroy($id)
 {
     // Check if is_staff
     if (!$this->is_staff()) {
         Session::flash('alert_danger', 'Access denied.');
         return Redirect::to('dashboard');
     } else {
         try {
             // Inactivate the Loan
             $loan = Loan::find($id);
             $loan->active = 0;
             $loan->save();
             // Save Transaction
             $transaction = new Transaction();
             $transaction->loan_id = $id;
             $transaction->user_id = $this->user->id;
             $transaction->transaction_type_id = "3";
             $transaction->updated_item_id = $id;
             $transaction->transaction_description = "Loan Deleted";
             $transaction->save();
         } catch (\RuntimeException $e) {
             Session::flash('alert_danger', 'Failed to delete loan.');
             return Redirect::to('loan/' . $id);
         }
         Session::flash('alert_success', 'Deleted loan successfully.');
         return Redirect::to('dashboard');
     }
 }
コード例 #2
0
ファイル: SellController.php プロジェクト: rana7cse/motoshop
 public function getInfo($id)
 {
     return Loan::find($id);
 }