blob: 33e945de727c62671cbd80451305fac6cd82f216 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
<?php
namespace CamilStaps\BotleaguesApi;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Redirect;
class UserController extends BaseController {
protected $user;
public function __construct(User $user) {
$this->user = $user;
}
public function index() {
return $this->user->all();
}
public function show($id) {
return $this->user->findOrFail($id);
}
public function edit($id) {
return $this->response->noContent();
}
public function store() {
try {
$this->user->email = Input::get('email');
$this->user->password = Hash::make(Input::get('password'));
if ($this->user->save()) {
return $this->response->created();
} else {
throw new Dingo\Api\Exception\StoreResourceFailedException;
}
} catch (Exception $e) {
throw new Dingo\Api\Exception\StoreResourceFailedException;
}
}
}
|