akaunting 3.0 (the last dance)

This commit is contained in:
Burak Civan
2022-06-01 10:15:55 +03:00
parent cead09f6d4
commit d9c0764572
3812 changed files with 126831 additions and 102949 deletions

View File

@ -4,48 +4,48 @@ namespace App\Http\Controllers\Api\Settings;
use App\Abstracts\Http\ApiController;
use App\Http\Requests\Setting\Category as Request;
use App\Http\Resources\Setting\Category as Resource;
use App\Jobs\Setting\CreateCategory;
use App\Jobs\Setting\DeleteCategory;
use App\Jobs\Setting\UpdateCategory;
use App\Models\Setting\Category;
use App\Transformers\Setting\Category as Transformer;
class Categories extends ApiController
{
/**
* Display a listing of the resource.
*
* @return \Dingo\Api\Http\Response
* @return \Illuminate\Http\JsonResponse
*/
public function index()
{
$categories = Category::collect();
$categories = Category::withSubCategory()->collect();
return $this->response->paginator($categories, new Transformer());
return Resource::collection($categories);
}
/**
* Display the specified resource.
*
* @param Category $category
* @return \Dingo\Api\Http\Response
* @return \Illuminate\Http\JsonResponse
*/
public function show(Category $category)
{
return $this->item($category, new Transformer());
return new Resource($category);
}
/**
* Store a newly created resource in storage.
*
* @param $request
* @return \Dingo\Api\Http\Response
* @return \Illuminate\Http\JsonResponse
*/
public function store(Request $request)
{
$category = $this->dispatch(new CreateCategory($request));
return $this->response->created(route('api.categories.show', $category->id), $this->item($category, new Transformer()));
return $this->created(route('api.categories.show', $category->id), new Resource($category));
}
/**
@ -53,16 +53,16 @@ class Categories extends ApiController
*
* @param $category
* @param $request
* @return \Dingo\Api\Http\Response
* @return \Illuminate\Http\JsonResponse
*/
public function update(Category $category, Request $request)
{
try {
$category = $this->dispatch(new UpdateCategory($category, $request));
return $this->item($category->fresh(), new Transformer());
return new Resource($category->fresh());
} catch(\Exception $e) {
$this->response->errorUnauthorized($e->getMessage());
$this->errorUnauthorized($e->getMessage());
}
}
@ -70,29 +70,29 @@ class Categories extends ApiController
* Enable the specified resource in storage.
*
* @param Category $category
* @return \Dingo\Api\Http\Response
* @return \Illuminate\Http\JsonResponse
*/
public function enable(Category $category)
{
$category = $this->dispatch(new UpdateCategory($category, request()->merge(['enabled' => 1])));
return $this->item($category->fresh(), new Transformer());
return new Resource($category->fresh());
}
/**
* Disable the specified resource in storage.
*
* @param Category $category
* @return \Dingo\Api\Http\Response
* @return \Illuminate\Http\JsonResponse
*/
public function disable(Category $category)
{
try {
$category = $this->dispatch(new UpdateCategory($category, request()->merge(['enabled' => 0])));
return $this->item($category->fresh(), new Transformer());
return new Resource($category->fresh());
} catch(\Exception $e) {
$this->response->errorUnauthorized($e->getMessage());
$this->errorUnauthorized($e->getMessage());
}
}
@ -100,16 +100,16 @@ class Categories extends ApiController
* Remove the specified resource from storage.
*
* @param Category $category
* @return \Dingo\Api\Http\Response
* @return \Illuminate\Http\Response
*/
public function destroy(Category $category)
{
try {
$this->dispatch(new DeleteCategory($category));
return $this->response->noContent();
return $this->noContent();
} catch(\Exception $e) {
$this->response->errorUnauthorized($e->getMessage());
$this->errorUnauthorized($e->getMessage());
}
}
}

View File

@ -4,31 +4,31 @@ namespace App\Http\Controllers\Api\Settings;
use App\Abstracts\Http\ApiController;
use App\Http\Requests\Setting\Currency as Request;
use App\Http\Resources\Setting\Currency as Resource;
use App\Jobs\Setting\CreateCurrency;
use App\Jobs\Setting\DeleteCurrency;
use App\Jobs\Setting\UpdateCurrency;
use App\Models\Setting\Currency;
use App\Transformers\Setting\Currency as Transformer;
class Currencies extends ApiController
{
/**
* Display a listing of the resource.
*
* @return \Dingo\Api\Http\Response
* @return \Illuminate\Http\JsonResponse
*/
public function index()
{
$currencies = Currency::collect();
return $this->response->paginator($currencies, new Transformer());
return Resource::collection($currencies);
}
/**
* Display the specified resource.
*
* @param int|string $id
* @return \Dingo\Api\Http\Response
* @return \Illuminate\Http\JsonResponse
*/
public function show($id)
{
@ -39,20 +39,20 @@ class Currencies extends ApiController
$currency = Currency::where('code', $id)->first();
}
return $this->item($currency, new Transformer());
return new Resource($currency);
}
/**
* Store a newly created resource in storage.
*
* @param $request
* @return \Dingo\Api\Http\Response
* @return \Illuminate\Http\JsonResponse
*/
public function store(Request $request)
{
$currency = $this->dispatch(new CreateCurrency($request));
return $this->response->created(route('api.currencies.show', $currency->id), $this->item($currency, new Transformer()));
return $this->created(route('api.currencies.show', $currency->id), new Resource($currency));
}
/**
@ -60,16 +60,16 @@ class Currencies extends ApiController
*
* @param $currency
* @param $request
* @return \Dingo\Api\Http\Response
* @return \Illuminate\Http\JsonResponse
*/
public function update(Currency $currency, Request $request)
{
try {
$currency = $this->dispatch(new UpdateCurrency($currency, $request));
return $this->item($currency->fresh(), new Transformer());
return new Resource($currency->fresh());
} catch(\Exception $e) {
$this->response->errorUnauthorized($e->getMessage());
$this->errorUnauthorized($e->getMessage());
}
}
@ -77,29 +77,29 @@ class Currencies extends ApiController
* Enable the specified resource in storage.
*
* @param Currency $currency
* @return \Dingo\Api\Http\Response
* @return \Illuminate\Http\JsonResponse
*/
public function enable(Currency $currency)
{
$currency = $this->dispatch(new UpdateCurrency($currency, request()->merge(['enabled' => 1])));
return $this->item($currency->fresh(), new Transformer());
return new Resource($currency->fresh());
}
/**
* Disable the specified resource in storage.
*
* @param Currency $currency
* @return \Dingo\Api\Http\Response
* @return \Illuminate\Http\JsonResponse
*/
public function disable(Currency $currency)
{
try {
$currency = $this->dispatch(new UpdateCurrency($currency, request()->merge(['enabled' => 0])));
return $this->item($currency->fresh(), new Transformer());
return new Resource($currency->fresh());
} catch(\Exception $e) {
$this->response->errorUnauthorized($e->getMessage());
$this->errorUnauthorized($e->getMessage());
}
}
@ -107,16 +107,16 @@ class Currencies extends ApiController
* Remove the specified resource from storage.
*
* @param Currency $currency
* @return \Dingo\Api\Http\Response
* @return \Illuminate\Http\Response
*/
public function destroy(Currency $currency)
{
try {
$this->dispatch(new DeleteCurrency($currency));
return $this->response->noContent();
return $this->noContent();
} catch(\Exception $e) {
$this->response->errorUnauthorized($e->getMessage());
$this->errorUnauthorized($e->getMessage());
}
}
}

View File

@ -4,14 +4,11 @@ namespace App\Http\Controllers\Api\Settings;
use App\Abstracts\Http\ApiController;
use App\Http\Requests\Setting\Setting as Request;
use App\Http\Resources\Setting\Setting as Resource;
use App\Models\Setting\Setting;
use App\Transformers\Setting\Setting as Transformer;
use Dingo\Api\Routing\Helpers;
class Settings extends ApiController
{
use Helpers;
/**
* Instantiate a new controller instance.
*/
@ -26,20 +23,20 @@ class Settings extends ApiController
/**
* Display a listing of the resource.
*
* @return \Dingo\Api\Http\Response
* @return \Illuminate\Http\JsonResponse
*/
public function index()
{
$settings = Setting::all();
return $this->response->collection($settings, new Transformer());
return Resource::collection($settings);
}
/**
* Display the specified resource.
*
* @param int|string $id
* @return \Dingo\Api\Http\Response
* @return \Illuminate\Http\JsonResponse
*/
public function show($id)
{
@ -50,20 +47,20 @@ class Settings extends ApiController
$setting = Setting::where('key', $id)->first();
}
return $this->item($setting, new Transformer());
return new Resource($setting);
}
/**
* Store a newly created resource in storage.
*
* @param $request
* @return \Dingo\Api\Http\Response
* @return \Illuminate\Http\JsonResponse
*/
public function store(Request $request)
{
$setting = Setting::create($request->all());
return $this->response->created(route('api.settings.show', $setting->id), $this->item($setting, new Transformer()));
return $this->created(route('api.settings.show', $setting->id), new Resource($setting));
}
/**
@ -71,25 +68,25 @@ class Settings extends ApiController
*
* @param $setting
* @param $request
* @return \Dingo\Api\Http\Response
* @return \Illuminate\Http\JsonResponse
*/
public function update(Setting $setting, Request $request)
{
$setting->update($request->all());
return $this->item($setting->fresh(), new Transformer());
return new Resource($setting->fresh());
}
/**
* Remove the specified resource from storage.
*
* @param Setting $setting
* @return \Dingo\Api\Http\Response
* @return \Illuminate\Http\Response
*/
public function destroy(Setting $setting)
{
$setting->delete();
return $this->response->noContent();
return $this->noContent();
}
}

View File

@ -4,48 +4,48 @@ namespace App\Http\Controllers\Api\Settings;
use App\Abstracts\Http\ApiController;
use App\Http\Requests\Setting\Tax as Request;
use App\Http\Resources\Setting\Tax as Resource;
use App\Jobs\Setting\CreateTax;
use App\Jobs\Setting\DeleteTax;
use App\Jobs\Setting\UpdateTax;
use App\Models\Setting\Tax;
use App\Transformers\Setting\Tax as Transformer;
class Taxes extends ApiController
{
/**
* Display a listing of the resource.
*
* @return \Dingo\Api\Http\Response
* @return \Illuminate\Http\JsonResponse
*/
public function index()
{
$taxes = Tax::collect();
return $this->response->paginator($taxes, new Transformer());
return Resource::collection($taxes);
}
/**
* Display the specified resource.
*
* @param Tax $tax
* @return \Dingo\Api\Http\Response
* @return \Illuminate\Http\JsonResponse
*/
public function show(Tax $tax)
{
return $this->item($tax, new Transformer());
return new Resource($tax);
}
/**
* Store a newly created resource in storage.
*
* @param $request
* @return \Dingo\Api\Http\Response
* @return \Illuminate\Http\JsonResponse
*/
public function store(Request $request)
{
$tax = $this->dispatch(new CreateTax($request));
return $this->response->created(route('api.taxes.show', $tax->id), $this->item($tax, new Transformer()));
return $this->created(route('api.taxes.show', $tax->id), new Resource($tax));
}
/**
@ -53,16 +53,16 @@ class Taxes extends ApiController
*
* @param $tax
* @param $request
* @return \Dingo\Api\Http\Response
* @return \Illuminate\Http\JsonResponse
*/
public function update(Tax $tax, Request $request)
{
try {
$tax = $this->dispatch(new UpdateTax($tax, $request));
return $this->item($tax->fresh(), new Transformer());
return new Resource($tax->fresh());
} catch(\Exception $e) {
$this->response->errorUnauthorized($e->getMessage());
$this->errorUnauthorized($e->getMessage());
}
}
@ -70,29 +70,29 @@ class Taxes extends ApiController
* Enable the specified resource in storage.
*
* @param Tax $tax
* @return \Dingo\Api\Http\Response
* @return \Illuminate\Http\JsonResponse
*/
public function enable(Tax $tax)
{
$tax = $this->dispatch(new UpdateTax($tax, request()->merge(['enabled' => 1])));
return $this->item($tax->fresh(), new Transformer());
return new Resource($tax->fresh());
}
/**
* Disable the specified resource in storage.
*
* @param Tax $tax
* @return \Dingo\Api\Http\Response
* @return \Illuminate\Http\JsonResponse
*/
public function disable(Tax $tax)
{
try {
$tax = $this->dispatch(new UpdateTax($tax, request()->merge(['enabled' => 0])));
return $this->item($tax->fresh(), new Transformer());
return new Resource($tax->fresh());
} catch(\Exception $e) {
$this->response->errorUnauthorized($e->getMessage());
$this->errorUnauthorized($e->getMessage());
}
}
@ -100,16 +100,16 @@ class Taxes extends ApiController
* Remove the specified resource from storage.
*
* @param Tax $tax
* @return \Dingo\Api\Http\Response
* @return \Illuminate\Http\Response
*/
public function destroy(Tax $tax)
{
try {
$this->dispatch(new DeleteTax($tax));
return $this->response->noContent();
return $this->noContent();
} catch(\Exception $e) {
$this->response->errorUnauthorized($e->getMessage());
$this->errorUnauthorized($e->getMessage());
}
}
}