Beispiel #1
0
 protected function loadInvoices()
 {
     if (!($user = Auth::getUser())) {
         throw new \Exception('You must be logged in');
     }
     $invoices = InvoiceModel::orderBy('sent_at');
     $invoices->where('user_id', $user->id)->get();
     $invoices->each(function ($invoice) {
         $invoice->setUrl($this->invoicePage, $this->controller);
     });
     return $invoices;
 }
Beispiel #2
0
 public function getInvoice()
 {
     if ($this->invoice !== null) {
         return $this->invoice;
     }
     if (!($hash = $this->property('hash'))) {
         return null;
     }
     $invoice = InvoiceModel::whereHash($hash)->first();
     if ($invoice) {
         $invoice->setUrlPageName($this->invoicePage);
     }
     return $this->invoice = $invoice;
 }
Beispiel #3
0
 public function getInvoice()
 {
     if ($this->invoice !== null) {
         return $this->invoice;
     }
     if (!($id = $this->property('id'))) {
         return null;
     }
     $invoice = InvoiceModel::where('id', $id)->first();
     /*
      * Only users can view their own invoices
      */
     $user = Auth::getUser();
     if (!$user) {
         $invoice = null;
     }
     if ($invoice && $invoice->user_id != $user->id) {
         $invoice = null;
     }
     if ($invoice) {
         $invoice->setUrlPageName($this->payPage);
     }
     return $this->invoice = $invoice;
 }