1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00
invoiceninja/app/Http/Controllers/TaxRateController.php

96 lines
2.3 KiB
PHP
Raw Normal View History

2015-10-21 13:11:08 +02:00
<?php namespace App\Http\Controllers;
use Auth;
use Str;
use DB;
use Datatable;
use Utils;
use URL;
use View;
use Input;
use Session;
use Redirect;
use App\Models\TaxRate;
2015-11-05 23:37:04 +01:00
use App\Services\TaxRateService;
use App\Ninja\Repositories\TaxRateRepository;
use App\Http\Requests\CreateTaxRateRequest;
use App\Http\Requests\UpdateTaxRateRequest;
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'));
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'));
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);
}
}