1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 08:21:34 +02:00
invoiceninja/app/Http/Controllers/TaxRateController.php

93 lines
2.3 KiB
PHP
Raw Normal View History

2017-01-30 20:40:43 +01:00
<?php
2015-10-21 13:11:08 +02:00
2017-01-30 20:40:43 +01:00
namespace App\Http\Controllers;
use App\Http\Requests\CreateTaxRateRequest;
use App\Http\Requests\UpdateTaxRateRequest;
use App\Models\TaxRate;
use App\Ninja\Repositories\TaxRateRepository;
use App\Services\TaxRateService;
2015-10-21 13:11:08 +02:00
use Auth;
use Input;
use Redirect;
2017-01-30 20:40:43 +01:00
use Session;
use URL;
use View;
2015-10-21 13:11:08 +02:00
class TaxRateController extends BaseController
{
2015-11-05 23:37:04 +01:00
protected $taxRateService;
protected $taxRateRepo;
2015-11-05 23:37:04 +01:00
public function __construct(TaxRateService $taxRateService, TaxRateRepository $taxRateRepo)
2015-11-05 23:37:04 +01:00
{
2016-03-02 14:36:42 +01:00
//parent::__construct();
2015-11-05 23:37:04 +01:00
$this->taxRateService = $taxRateService;
$this->taxRateRepo = $taxRateRepo;
2015-11-05 23:37:04 +01:00
}
2015-10-21 13:11:08 +02:00
public function index()
{
return Redirect::to('settings/' . ACCOUNT_TAX_RATES);
}
public function getDatatable()
{
2015-11-05 23:37:04 +01:00
return $this->taxRateService->getDatatable(Auth::user()->account_id);
2015-10-21 13:11:08 +02:00
}
public function edit($publicId)
{
$data = [
'taxRate' => TaxRate::scope($publicId)->firstOrFail(),
'method' => 'PUT',
'url' => 'tax_rates/'.$publicId,
'title' => trans('texts.edit_tax_rate'),
];
return View::make('accounts.tax_rate', $data);
}
public function create()
{
$data = [
'taxRate' => null,
'method' => 'POST',
'url' => 'tax_rates',
'title' => trans('texts.create_tax_rate'),
];
return View::make('accounts.tax_rate', $data);
}
public function store(CreateTaxRateRequest $request)
2015-10-21 13:11:08 +02:00
{
$this->taxRateRepo->save($request->input());
2015-10-21 13:11:08 +02:00
Session::flash('message', trans('texts.created_tax_rate'));
2017-01-30 20:40:43 +01:00
return Redirect::to('settings/' . ACCOUNT_TAX_RATES);
2015-10-21 13:11:08 +02:00
}
public function update(UpdateTaxRateRequest $request, $publicId)
2015-10-21 13:11:08 +02:00
{
$this->taxRateRepo->save($request->input(), $request->entity());
2016-03-02 14:36:42 +01:00
Session::flash('message', trans('texts.updated_tax_rate'));
2017-01-30 20:40:43 +01:00
2015-10-21 13:11:08 +02:00
return Redirect::to('settings/' . ACCOUNT_TAX_RATES);
}
2015-11-05 23:37:04 +01:00
public function bulk()
2015-10-21 13:11:08 +02:00
{
2015-11-05 23:37:04 +01:00
$action = Input::get('bulk_action');
$ids = Input::get('bulk_public_id');
$count = $this->taxRateService->bulk($ids, $action);
2015-10-21 13:11:08 +02:00
Session::flash('message', trans('texts.archived_tax_rate'));
return Redirect::to('settings/' . ACCOUNT_TAX_RATES);
}
}