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

Commit 5d07577

Browse files
author
Mario Basic
committed
Clients can now be added from services create and edit form.
1 parent 8bef436 commit 5d07577

File tree

8 files changed

+90
-3
lines changed

8 files changed

+90
-3
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Api;
4+
5+
use Illuminate\Http\Request;
6+
7+
use App\Http\Requests;
8+
use App\Http\Controllers\Controller;
9+
use App\Client;
10+
11+
class ClientController extends Controller
12+
{
13+
public function store(Request $request)
14+
{
15+
$this->validate($request, [
16+
'name' => 'required|string|max:255'
17+
]);
18+
19+
$client = Client::create([
20+
'name' => $request->get('name')
21+
]);
22+
23+
return $client->toArray();
24+
}
25+
}

app/Http/api_routes.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
Route::post('categories', 'CategoryController@store');
77

8+
Route::post('clients', 'ClientController@store');
9+
810
Route::get('occurrences/{occurrence}/offer', 'OccurrenceController@toggleOffer');
911
Route::get('occurrences/{occurrence}/payment', 'OccurrenceController@togglePayment');
1012
Route::get('occurrences/{occurrence}/receipt', 'OccurrenceController@toggleReceipt');

public/build/js/app-6c3908ebed.js renamed to public/build/js/app-4f5c48cb5a.js

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

public/build/js/app.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/build/rev-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"css/app.css": "css/app-fdd1ba9962.css",
3-
"js/app.js": "js/app-6c3908ebed.js"
3+
"js/app.js": "js/app-4f5c48cb5a.js"
44
}

public/js/app.js

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

public/js/app.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/assets/js/app.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,24 @@ $('#category_id').selectize({
9898
}
9999
});
100100
}
101+
});
102+
103+
// Categories can be created on-the-fly
104+
$('#client_id').selectize({
105+
persist: true,
106+
create: function (input, callback) {
107+
$.ajax('/api/v1/clients', {
108+
data: {
109+
name: input,
110+
api_token: api_token
111+
},
112+
method: 'POST',
113+
success: function (data) {
114+
return callback({
115+
value: data.id,
116+
text: data.name
117+
});
118+
}
119+
});
120+
}
101121
});

0 commit comments

Comments
 (0)