Currencies.php
1.78 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
namespace App\Http\Controllers\Api\Settings;
use App\Http\Controllers\ApiController;
use App\Http\Requests\Setting\Currency as Request;
use App\Models\Setting\Currency;
use App\Transformers\Setting\Currency as Transformer;
use Dingo\Api\Routing\Helpers;
class Currencies extends ApiController
{
use Helpers;
/**
* Display a listing of the resource.
*
* @return \Dingo\Api\Http\Response
*/
public function index()
{
$currencies = Currency::collect();
return $this->response->paginator($currencies, new Transformer());
}
/**
* Display the specified resource.
*
* @param Currency $currency
* @return \Dingo\Api\Http\Response
*/
public function show(Currency $currency)
{
return $this->response->item($currency, new Transformer());
}
/**
* Store a newly created resource in storage.
*
* @param $request
* @return \Dingo\Api\Http\Response
*/
public function store(Request $request)
{
$currency = Currency::create($request->all());
return $this->response->created(url('api/currencies/'.$currency->id));
}
/**
* Update the specified resource in storage.
*
* @param $currency
* @param $request
* @return \Dingo\Api\Http\Response
*/
public function update(Currency $currency, Request $request)
{
$currency->update($request->all());
return $this->response->item($currency->fresh(), new Transformer());
}
/**
* Remove the specified resource from storage.
*
* @param Currency $currency
* @return \Dingo\Api\Http\Response
*/
public function destroy(Currency $currency)
{
$currency->delete();
return $this->response->noContent();
}
}