1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 21:52:35 +01:00
invoiceninja/app/Http/Controllers/TaxRateApiController.php

55 lines
1.3 KiB
PHP
Raw Normal View History

<?php namespace App\Http\Controllers;
use App\Models\TaxRate;
2016-05-02 15:12:37 +02:00
use App\Ninja\Repositories\TaxRateRepository;
use App\Http\Requests\CreateTaxRateRequest;
use App\Http\Requests\UpdateTaxRateRequest;
class TaxRateApiController extends BaseAPIController
{
protected $taxRateRepo;
2016-05-02 15:12:37 +02:00
2016-05-01 22:55:13 +02:00
protected $entityType = ENTITY_TAX_RATE;
2016-05-02 15:12:37 +02:00
public function __construct(TaxRateRepository $taxRateRepo)
{
2016-03-02 15:36:46 +01:00
parent::__construct();
$this->taxRateRepo = $taxRateRepo;
}
public function index()
{
2016-05-01 22:55:13 +02:00
$taxRates = TaxRate::scope()
->withTrashed()
->orderBy('created_at', 'desc');
2016-05-02 15:12:37 +02:00
2016-05-02 10:38:01 +02:00
return $this->listResponse($taxRates);
}
public function store(CreateTaxRateRequest $request)
{
2016-05-02 15:12:37 +02:00
$taxRate = $this->taxRateRepo->save($request->input());
return $this->itemResponse($taxRate);
}
2016-05-02 15:12:37 +02:00
public function update(UpdateTaxRateRequest $request, $publicId)
{
2016-05-02 15:12:37 +02:00
if ($request->action) {
return $this->handleAction($request);
}
2016-05-02 15:12:37 +02:00
$data = $request->input();
$data['public_id'] = $publicId;
$taxRate = $this->taxRateRepo->save($data, $request->entity());
2016-05-02 15:12:37 +02:00
return $this->itemResponse($taxRate);
}
2016-05-02 15:12:37 +02:00
public function destroy($publicId)
{
2016-05-02 15:12:37 +02:00
//stub
}
}