Skip to content
This repository was archived by the owner on Jan 5, 2019. It is now read-only.

Commit 1a68b14

Browse files
author
Mario Basic
committed
Occurrences can now toogle state for offer, payment and receipt.
1 parent ffbafeb commit 1a68b14

File tree

17 files changed

+156
-44225
lines changed

17 files changed

+156
-44225
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Api;
4+
5+
use App\Occurrence;
6+
use App\Http\Requests;
7+
use Illuminate\Http\Request;
8+
use App\Http\Controllers\Controller;
9+
10+
class OccurrenceController extends Controller
11+
{
12+
public function toggleOffer(Occurrence $occurrence, Request $request)
13+
{
14+
$this->validate($request, [
15+
'state' => 'required|boolean'
16+
]);
17+
18+
$occurrence->offer_sent = $request->get('state');
19+
$occurrence->save();
20+
21+
return $occurrence->offer_sent;
22+
}
23+
24+
public function togglePayment(Occurrence $occurrence, Request $request)
25+
{
26+
$this->validate($request, [
27+
'state' => 'required|boolean'
28+
]);
29+
30+
$occurrence->payment_received = $request->get('state');
31+
$occurrence->save();
32+
33+
return $occurrence->payment_received;
34+
}
35+
36+
public function toggleReceipt(Occurrence $occurrence, Request $request)
37+
{
38+
$this->validate($request, [
39+
'state' => 'required|boolean'
40+
]);
41+
42+
$occurrence->receipt_sent = $request->get('state');
43+
$occurrence->save();
44+
45+
return $occurrence->receipt_sent;
46+
}
47+
}

app/Http/api_routes.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22

33
Route::group(['prefix' => 'api/v1', 'middleware' => 'auth:api'], function () {
44
Route::get('quote', 'QuoteController@getQuote');
5+
Route::get('occurrences/{occurrence}/offer', 'OccurrenceController@toggleOffer');
6+
Route::get('occurrences/{occurrence}/payment', 'OccurrenceController@togglePayment');
7+
Route::get('occurrences/{occurrence}/receipt', 'OccurrenceController@toggleReceipt');
58
});

app/Occurrence.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,19 @@ public function service()
1515
{
1616
return $this->belongsTo(Service::class);
1717
}
18+
19+
public function getFutureOfferState()
20+
{
21+
return $this->offer_sent ? 0 : 1;
22+
}
23+
24+
public function getFuturePaymentState()
25+
{
26+
return $this->payment_received ? 0 : 1;
27+
}
28+
29+
public function getFutureReceiptState()
30+
{
31+
return $this->receipt_sent ? 0 : 1;
32+
}
1833
}

public/build/css/app-7e869186f4.css

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)