コード例 #1
0
ファイル: PagesController.php プロジェクト: hootlex/apodeiksi
 /**
  * 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);
 }
コード例 #2
0
ファイル: ReceiptExists.php プロジェクト: hootlex/apodeiksi
 /**
  * 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);
 }
コード例 #3
0
 /**
  * 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';
 }
コード例 #4
0
ファイル: ReceiptsApiTest.php プロジェクト: hootlex/apodeiksi
 /**
  * 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);
 }
コード例 #5
0
ファイル: DatabaseSeeder.php プロジェクト: hootlex/apodeiksi
 /**
  * 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;');
 }
コード例 #6
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));
 }
コード例 #7
0
 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');
 }
コード例 #8
0
 /**
  * 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";
 }
コード例 #9
0
 /**
  * Show all existing receipts.
  *
  * @return Response
  */
 public function receipts()
 {
     $receipts = Receipt::paginate(10);
     return view('admin.receipts', compact('receipts'))->with('page_title', 'Όλες οι αποδείξεις των χρηστών');
 }
コード例 #10
0
 /**
  * Display the specified resource.
  *
  * @return Response
  */
 public function receipts()
 {
     $receipts = Receipt::where('afm', '=', Auth::user()->afm)->paginate(30);
     return view('business.receipts', compact('receipts'));
 }