mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Continued working on category controller [skip ci]
This commit is contained in:
@@ -158,7 +158,6 @@ class BudgetController extends BaseController
|
||||
return Redirect::route('budgets.index.budget');
|
||||
}
|
||||
|
||||
return Redirect::route('budgets.index');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Firefly\Storage\Category\CategoryRepositoryInterface as CRI;
|
||||
use Firefly\Helper\Controllers\CategoryInterface as CI;
|
||||
|
||||
/**
|
||||
* Class CategoryController
|
||||
@@ -9,47 +10,78 @@ class CategoryController extends BaseController
|
||||
{
|
||||
protected $_repository;
|
||||
|
||||
public function __construct(CRI $repository)
|
||||
public function __construct(CRI $repository, CI $category)
|
||||
{
|
||||
$this->_repository = $repository;
|
||||
$this->_category = $category;
|
||||
View::share('menu', 'categories');
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return View::make('categories.create');
|
||||
}
|
||||
|
||||
public function delete(Category $category)
|
||||
{
|
||||
return View::make('categories.delete')->with('category',$category);
|
||||
return View::make('categories.delete')->with('category', $category);
|
||||
}
|
||||
|
||||
public function destroy()
|
||||
{
|
||||
$result = $this->_repository->destroy(Input::get('id'));
|
||||
if ($result === true) {
|
||||
Session::flash('success', 'The category was deleted.');
|
||||
} else {
|
||||
Session::flash('error', 'Could not delete the category. Check the logs to be sure.');
|
||||
}
|
||||
return Redirect::route('categories.index');
|
||||
}
|
||||
|
||||
public function edit(Category $category)
|
||||
{
|
||||
return View::make('categories.edit')->with('category',$category);
|
||||
return View::make('categories.edit')->with('category', $category);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$categories = $this->_repository->get();
|
||||
return View::make('categories.index')->with('categories',$categories);
|
||||
return View::make('categories.index')->with('categories', $categories);
|
||||
}
|
||||
|
||||
public function show(Category $category)
|
||||
{
|
||||
return View::make('categories.show')->with('category',$category);
|
||||
$start = \Session::get('start');
|
||||
$end = \Session::get('end');
|
||||
|
||||
|
||||
$journals = $this->_category->journalsInRange($category, $start, $end);
|
||||
|
||||
return View::make('categories.show')->with('category', $category)->with('journals',$journals);
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
$category = $this->_repository->store(Input::all());
|
||||
if ($category->id) {
|
||||
Session::flash('success', 'Category created!');
|
||||
|
||||
if (Input::get('create') == '1') {
|
||||
return Redirect::route('categories.create');
|
||||
}
|
||||
return Redirect::route('categories.index');
|
||||
} else {
|
||||
Session::flash('error', 'Could not save the new category!');
|
||||
return Redirect::route('categories.create')->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
public function update()
|
||||
{
|
||||
$category = $this->_repository->update(Input::all());
|
||||
Session::flash('success', 'Category "' . $category->name . '" updated.');
|
||||
|
||||
return Redirect::route('categories.index');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -110,5 +110,21 @@ class ChartController extends BaseController
|
||||
return Response::json($this->_chart->categories($start, $end));
|
||||
|
||||
|
||||
}
|
||||
public function categoryShowChart(Category $category) {
|
||||
$start = Session::get('start');
|
||||
$end = Session::get('end');
|
||||
$range = Session::get('range');
|
||||
|
||||
$serie = $this->_chart->categoryShowChart($category, $range, $start, $end);
|
||||
$data = [
|
||||
'chart_title' => $category->name,
|
||||
'subtitle' => '<a href="' . route('categories.show', [$category->id]) . '">View more</a>',
|
||||
'series' => $serie
|
||||
];
|
||||
return Response::json($data);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user