1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-22 17:31:35 +02:00
invoiceninja/app/Http/Controllers/TaxRateApiController.php

65 lines
1.5 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
{
/**
* @var TaxRateRepository
*/
protected $taxRateRepo;
/**
* @var string
*/
2016-05-01 22:55:13 +02:00
protected $entityType = ENTITY_TAX_RATE;
/**
* TaxRateApiController constructor.
* @param TaxRateRepository $taxRateRepo
*/
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);
}
/**
* @param UpdateTaxRateRequest $request
* @param $publicId
* @return \Illuminate\Http\Response
*/
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);
}
}