Beispiel #1
0
 /**
  * Show user receipts of a specific Category.
  *
  * @param  int  $id
  * @return Response
  */
 public function browseCategory($id)
 {
     $receipts = Receipt::whereHas('categories', function ($query) use($id) {
         $query->where('id', '=', $id);
     })->where('user_id', '=', $this->user->id)->paginate();
     return view('pages.receipts', compact('receipts'))->with('page_title', Category::find($id)->name);
 }
Beispiel #2
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $receipt_id = $request->segment(4);
     if (!Receipt::find($receipt_id)) {
         abort(404);
     }
     return $next($request);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param $receipt_id
  * @param $category_id
  * @return Response
  * @internal param int $id
  */
 public function destroy($receipt_id, $category_id)
 {
     $receipt = Receipt::find($receipt_id);
     $category = Category::find($category_id);
     if ($receipt->hasCategory($category)) {
         $receipt->categories()->detach($category->id);
     }
     return 'success';
 }
Beispiel #4
0
 /**
  * Receipt DELETE test
  *
  * @return void
  */
 public function testDELETEReceipt()
 {
     $receipt = Receipt::first();
     $endpoint = $this->getEndpointWithToken($this->endpoint . '/' . $receipt->id);
     $this->call('DELETE', $endpoint);
     //fetch inserted receipt
     $deleted_receipt = Receipt::find($receipt->id);
     $this->assertNull($deleted_receipt);
 }
Beispiel #5
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     \App\User::truncate();
     \App\Receipt::truncate();
     \App\Category::truncate();
     $this->call('UserSeeder');
     $this->call('ReceiptSeeder');
     $this->call('CategorySeeder');
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
 }
 /**
  * Remove category from receipt test
  *
  */
 public function testRemoveCategoryReceipt()
 {
     $receipt = Factory::create('App\\Receipt');
     $category = Factory::create('App\\Category');
     $receipt->categories()->attach($category->id);
     $this->assertTrue($receipt->hasCategory($category));
     $fullEndpoint = $this->getFullEndpoint($receipt, $category);
     $endpoint = $this->getEndpointWithToken($fullEndpoint);
     $this->call('DELETE', $endpoint);
     //fetch receipt again and check categories
     $receipt = \App\Receipt::find($receipt->id);
     $this->assertFalse($receipt->hasCategory($category));
 }
 public function complete(Request $request, $id)
 {
     $userid = Auth::id();
     $transaction_id = Transaction::where('user_id', $userid)->where('status', 'open')->first()->transaction_id;
     $totalValue = Transaction::where('user_id', $userid)->where('status', 'open')->sum('price');
     $tax = 0.08;
     $total = $totalValue * $tax + $totalValue;
     $change = $id;
     $notes = $request->input('notes');
     $cash_received = $change + $total;
     //store receipt
     Receipt::create(array('transaction_id' => $transaction_id, 'user_id' => $userid, 'total' => $total, 'cash_received' => $cash_received, 'change' => $change, 'notes' => $notes));
     //close transaction
     $transactionItems = Transaction::where('user_id', $userid)->where('status', 'open')->get();
     foreach ($transactionItems as $item) {
         $item->update(array('status' => 'closed'));
     }
     return redirect('home');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Receipt::findOrFail($id)->delete();
     return "Receipt with id {$id} has been deleted";
 }
 /**
  * Show all existing receipts.
  *
  * @return Response
  */
 public function receipts()
 {
     $receipts = Receipt::paginate(10);
     return view('admin.receipts', compact('receipts'))->with('page_title', 'Όλες οι αποδείξεις των χρηστών');
 }
 /**
  * Display the specified resource.
  *
  * @return Response
  */
 public function receipts()
 {
     $receipts = Receipt::where('afm', '=', Auth::user()->afm)->paginate(30);
     return view('business.receipts', compact('receipts'));
 }