Blame view

app/Http/Controllers/Customers/Payments.php 1.39 KB
b7c7a5f6   Alexey Boroda   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
  <?php
  
  namespace App\Http\Controllers\Customers;
  
  use App\Http\Controllers\Controller;
  use App\Models\Income\Revenue as Payment;
  use App\Models\Setting\Category;
  use App\Models\Banking\Account;
  
  use App\Utilities\Modules;
  
  use Auth;
  
  class Payments extends Controller
  {
  
      /**
       * Display a listing of the resource.
       *
       * @return Response
       */
      public function index()
      {
          $payments = Payment::with(['account', 'category'])->where('customer_id', '=', Auth::user()->customer->id)->paginate();
  
          $payment_methods = Modules::getPaymentMethods('all');
  
          $categories = collect(Category::enabled()->type('income')->pluck('name', 'id'))
              ->prepend(trans('general.all_type', ['type' => trans_choice('general.categories', 2)]), '');
  
          $accounts = collect(Account::enabled()->pluck('name', 'id'))
              ->prepend(trans('general.all_type', ['type' => trans_choice('general.accounts', 2)]), '');
  
          return view('customers.payments.index', compact('payments', 'payment_methods', 'categories', 'accounts'));
      }
  
      /**
       * Show the form for viewing the specified resource.
       *
       * @param  Payment  $payment
       *
       * @return Response
       */
      public function show(Payment $payment)
      {
          $payment_methods = Modules::getPaymentMethods();
  
          return view('customers.payments.show', compact('payment', 'payment_methods'));
      }
  }