mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Some work on the category controller.
This commit is contained in:
parent
8dcaaeade7
commit
04a9ada682
@ -1,29 +1,47 @@
|
||||
<?php
|
||||
|
||||
class ComponentsController extends BaseController
|
||||
use Firefly\Storage\Category\CategoryRepositoryInterface as CRI;
|
||||
|
||||
/**
|
||||
* Class CategoryController
|
||||
*/
|
||||
class CategoryController extends BaseController
|
||||
{
|
||||
protected $_repository;
|
||||
|
||||
public function __construct(CRI $repository)
|
||||
{
|
||||
$this->_repository = $repository;
|
||||
View::share('menu', 'categories');
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
}
|
||||
|
||||
public function delete()
|
||||
public function delete(Category $category)
|
||||
{
|
||||
return View::make('categories.delete')->with('category',$category);
|
||||
}
|
||||
|
||||
public function destroy()
|
||||
{
|
||||
}
|
||||
|
||||
public function edit()
|
||||
public function edit(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);
|
||||
}
|
||||
|
||||
public function show()
|
||||
public function show(Category $category)
|
||||
{
|
||||
return View::make('categories.show')->with('category',$category);
|
||||
}
|
||||
|
||||
public function store()
|
||||
|
@ -14,7 +14,7 @@ class EloquentCategoryRepository implements CategoryRepositoryInterface
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
return \Auth::user()->categories()->get();
|
||||
return \Auth::user()->categories()->orderBy('name','ASC')->get();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,15 +4,15 @@ use LaravelBook\Ardent\Ardent as Ardent;
|
||||
/**
|
||||
* Account
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $user_id
|
||||
* @property integer $account_type_id
|
||||
* @property string $name
|
||||
* @property boolean $active
|
||||
* @property-read \AccountType $accountType
|
||||
* @property-read \User $user
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $user_id
|
||||
* @property integer $account_type_id
|
||||
* @property string $name
|
||||
* @property boolean $active
|
||||
* @property-read \AccountType $accountType
|
||||
* @property-read \User $user
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Transaction[] $transactions
|
||||
* @method static \Illuminate\Database\Query\Builder|\Account whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Account whereCreatedAt($value)
|
||||
@ -92,7 +92,8 @@ class Account extends Ardent
|
||||
);
|
||||
}
|
||||
|
||||
public function predict(\Carbon\Carbon $date) {
|
||||
public function predict(\Carbon\Carbon $date)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -4,10 +4,10 @@
|
||||
/**
|
||||
* AccountType
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $description
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $description
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Account[] $accounts
|
||||
* @method static \Illuminate\Database\Query\Builder|\AccountType whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\AccountType whereCreatedAt($value)
|
||||
|
@ -18,7 +18,7 @@
|
||||
* @method static \Illuminate\Database\Query\Builder|\Budget whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Budget whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Budget whereClass($value)
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Limit[] $limits
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Limit[] $limits
|
||||
*/
|
||||
class Budget extends Component
|
||||
{
|
||||
@ -35,8 +35,9 @@ class Budget extends Component
|
||||
return $this->hasMany('Limit', 'component_id');
|
||||
}
|
||||
|
||||
public function transactionjournals() {
|
||||
return $this->belongsToMany('TransactionJournal','component_transaction_journal','component_id');
|
||||
public function transactionjournals()
|
||||
{
|
||||
return $this->belongsToMany('TransactionJournal', 'component_transaction_journal', 'component_id');
|
||||
}
|
||||
|
||||
}
|
@ -18,7 +18,7 @@
|
||||
* @method static \Illuminate\Database\Query\Builder|\Category whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Category whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Category whereClass($value)
|
||||
* @property-read \Limit $limits
|
||||
* @property-read \Limit $limits
|
||||
*/
|
||||
class Category extends Component
|
||||
{
|
||||
|
@ -19,7 +19,7 @@
|
||||
* @method static \Illuminate\Database\Query\Builder|\Component whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Component whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Component whereClass($value)
|
||||
* @property-read \Limit $limits
|
||||
* @property-read \Limit $limits
|
||||
*/
|
||||
class Component extends Firefly\Database\SingleTableInheritanceEntity
|
||||
{
|
||||
|
@ -98,10 +98,10 @@ class LimitRepetition extends Ardent
|
||||
. '"!');
|
||||
break;
|
||||
case 'daily':
|
||||
return $this->startdate->format('Ymd').'-5';
|
||||
return $this->startdate->format('Ymd') . '-5';
|
||||
break;
|
||||
case 'weekly':
|
||||
return $this->startdate->format('Ymd').'4';
|
||||
return $this->startdate->format('Ymd') . '4';
|
||||
break;
|
||||
case 'monthly':
|
||||
return $this->startdate->format('Ymd') . '-3';
|
||||
@ -113,7 +113,7 @@ class LimitRepetition extends Ardent
|
||||
return $this->startdate->format('Ymd') . '-1';
|
||||
break;
|
||||
case 'yearly':
|
||||
return $this->startdate->format('Ymd').'-0';
|
||||
return $this->startdate->format('Ymd') . '-0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -6,13 +6,13 @@ use LaravelBook\Ardent\Ardent;
|
||||
/**
|
||||
* Preference
|
||||
*
|
||||
* @property integer $id
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $user_id
|
||||
* @property string $name
|
||||
* @property string $data
|
||||
* @property-read \User $user
|
||||
* @property integer $user_id
|
||||
* @property string $name
|
||||
* @property string $data
|
||||
* @property-read \User $user
|
||||
* @method static \Illuminate\Database\Query\Builder|\Preference whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Preference whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Preference whereUpdatedAt($value)
|
||||
|
@ -6,18 +6,18 @@ use LaravelBook\Ardent\Ardent;
|
||||
/**
|
||||
* Transaction
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $account_id
|
||||
* @property integer $transaction_journal_id
|
||||
* @property string $description
|
||||
* @property float $amount
|
||||
* @property-read \Account $account
|
||||
* @property-read \TransactionJournal $transactionJournal
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $account_id
|
||||
* @property integer $transaction_journal_id
|
||||
* @property string $description
|
||||
* @property float $amount
|
||||
* @property-read \Account $account
|
||||
* @property-read \TransactionJournal $transactionJournal
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Component[] $components
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Budget[] $budgets
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Category[] $categories
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Budget[] $budgets
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Category[] $categories
|
||||
* @method static \Illuminate\Database\Query\Builder|\Transaction whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Transaction whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Transaction whereUpdatedAt($value)
|
||||
@ -61,11 +61,11 @@ class Transaction extends Ardent
|
||||
|
||||
public function budgets()
|
||||
{
|
||||
return $this->belongsToMany('Budget','component_transaction','transaction_id','component_id');
|
||||
return $this->belongsToMany('Budget', 'component_transaction', 'transaction_id', 'component_id');
|
||||
}
|
||||
|
||||
public function categories()
|
||||
{
|
||||
return $this->belongsToMany('Category','component_transaction','transaction_id','component_id');
|
||||
return $this->belongsToMany('Category', 'component_transaction', 'transaction_id', 'component_id');
|
||||
}
|
||||
}
|
@ -4,10 +4,10 @@
|
||||
/**
|
||||
* TransactionCurrency
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $code
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $code
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\TransactionJournal[] $transactionJournals
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionCurrency whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionCurrency whereCreatedAt($value)
|
||||
|
@ -63,6 +63,7 @@ class TransactionJournal extends Ardent
|
||||
public static function factory()
|
||||
{
|
||||
$date = new \Carbon\Carbon;
|
||||
|
||||
return [
|
||||
'transaction_type_id' => 'factory|TransactionType',
|
||||
'transaction_currency_id' => 'factory|TransactionCurrency',
|
||||
|
@ -4,23 +4,26 @@
|
||||
/**
|
||||
* TransactionType
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $type
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $type
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\TransactionJournal[] $transactionJournals
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionType whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionType whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionType whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionType whereType($value)
|
||||
*/
|
||||
class TransactionType extends Eloquent {
|
||||
public function transactionJournals() {
|
||||
class TransactionType extends Eloquent
|
||||
{
|
||||
public function transactionJournals()
|
||||
{
|
||||
return $this->hasMany('TransactionJournal');
|
||||
}
|
||||
|
||||
public static $factory = [
|
||||
'type' => 'string'
|
||||
];
|
||||
public static $factory
|
||||
= [
|
||||
'type' => 'string'
|
||||
];
|
||||
|
||||
}
|
@ -10,19 +10,19 @@ use LaravelBook\Ardent\Ardent;
|
||||
/**
|
||||
* User
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $email
|
||||
* @property string $password
|
||||
* @property string $reset
|
||||
* @property string $remember_token
|
||||
* @property boolean $migrated
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Account[] $accounts
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Preference[] $preferences
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Component[] $components
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Budget[] $budgets
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Category[] $categories
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $email
|
||||
* @property string $password
|
||||
* @property string $reset
|
||||
* @property string $remember_token
|
||||
* @property boolean $migrated
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Account[] $accounts
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Preference[] $preferences
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Component[] $components
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Budget[] $budgets
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Category[] $categories
|
||||
* @method static \Illuminate\Database\Query\Builder|\User whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\User whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\User whereUpdatedAt($value)
|
||||
@ -92,7 +92,8 @@ class User extends Ardent implements UserInterface, RemindableInterface
|
||||
return $this->hasMany('Category');
|
||||
}
|
||||
|
||||
public function transactionjournals() {
|
||||
public function transactionjournals()
|
||||
{
|
||||
return $this->hasMany('TransactionJournal');
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,13 @@ Route::group(['before' => 'auth'], function () {
|
||||
Route::get('/chart/home/budgets', ['uses' => 'ChartController@homeBudgets', 'as' => 'chart.budgets']);
|
||||
Route::get('/chart/home/info/{accountname}/{day}/{month}/{year}', ['uses' => 'ChartController@homeAccountInfo', 'as' => 'chart.info']);
|
||||
|
||||
// Categories controller:
|
||||
Route::get('/categories',['uses' => 'CategoryController@index','as' => 'categories.index']);
|
||||
Route::get('/categories/create',['uses' => 'CategoryController@create','as' => 'categories.create']);
|
||||
Route::get('/categories/show/{category}',['uses' => 'CategoryController@show','as' => 'categories.show']);
|
||||
Route::get('/categories/edit/{category}',['uses' => 'CategoryController@edit','as' => 'categories.edit']);
|
||||
Route::get('/categories/delete/{category}',['uses' => 'CategoryController@delete','as' => 'categories.delete']);
|
||||
|
||||
|
||||
// preferences controller
|
||||
Route::get('/preferences', ['uses' => 'PreferencesController@index', 'as' => 'preferences']);
|
||||
@ -54,8 +61,8 @@ Route::group(['before' => 'auth'], function () {
|
||||
Route::get('/accounts/{account}/delete', ['uses' => 'AccountController@delete', 'as' => 'accounts.delete']);
|
||||
|
||||
// budget controller:
|
||||
Route::get('/budgets/create',['uses' => 'BudgetController@create', 'as' => 'budgets.create']);
|
||||
Route::get('/budgets',['uses' => 'BudgetController@indexByDate','as' => 'budgets.index']);
|
||||
Route::get('/budgets/create',['uses' => 'BudgetController@create', 'as' => 'budgets.create']);
|
||||
Route::get('/budgets/budget',['uses' => 'BudgetController@indexByBudget','as' => 'budgets.index.budget']);
|
||||
Route::get('/budgets/show/{budget}',['uses' => 'BudgetController@show', 'as' => 'budgets.show']);
|
||||
Route::get('/budgets/edit/{budget}',['uses' => 'BudgetController@edit', 'as' => 'budgets.edit']);
|
||||
|
34
app/views/categories/index.blade.php
Normal file
34
app/views/categories/index.blade.php
Normal file
@ -0,0 +1,34 @@
|
||||
@extends('layouts.default')
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||
<h1>Firefly
|
||||
<small>Categories</small>
|
||||
</h1>
|
||||
<p class="lead">Use categories to group your expenses</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
|
||||
</tr>
|
||||
@foreach($categories as $category)
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{{route('categories.show',$category->id)}}">{{{$category->name}}}</a>
|
||||
</td>
|
||||
<td>
|
||||
<div class="btn-group btn-group-xs">
|
||||
<a href="{{route('categories.edit',$category->id)}}" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span></a>
|
||||
<a href="{{route('categories.delete',$category->id)}}" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span></a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@stop
|
27
app/views/partials/menu/categories.blade.php
Normal file
27
app/views/partials/menu/categories.blade.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
$r = Route::current()->getName();
|
||||
?>
|
||||
<nav class="navbar navbar-default" role="navigation">
|
||||
<div class="container-fluid">
|
||||
<!-- Brand and toggle get grouped for better mobile display -->
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="{{route('index')}}">Firefly III</a>
|
||||
</div>
|
||||
|
||||
<!-- Collect the nav links, forms, and other content for toggling -->
|
||||
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
||||
<ul class="nav navbar-nav">
|
||||
<li @if($r=='index')class="active"@endif><a href="{{route('index')}}">Home</a></li>
|
||||
<li @if($r=='categories.index')class="active"@endif><a href="{{route('categories.index')}}">Categories</a></li>
|
||||
<li @if($r=='categories.create')class="active"@endif><a href="{{route('categories.create')}}"><span class="glyphicon glyphicon-plus"></span> Create category</a></li>
|
||||
</ul>
|
||||
@include('partials.menu.shared')
|
||||
</div><!-- /.navbar-collapse -->
|
||||
</div><!-- /.container-fluid -->
|
||||
</nav>
|
@ -23,6 +23,7 @@ $r = Route::current()->getName();
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li><a href="{{route('accounts.index')}}"><span class="glyphicon glyphicon-inbox"></span> Accounts</a></li>
|
||||
<li><a href="{{route('budgets.index')}}"><span class="glyphicon glyphicon-euro"></span> Budgets</a></li>
|
||||
<li><a href="{{route('categories.index')}}"><span class="glyphicon glyphicon-tags"></span> Categories</a></li>
|
||||
<li><a href="{{route('transactions.index')}}"><span class="glyphicon glyphicon-list-alt"></span> Transactions</a></li>
|
||||
<li class="divider"></li>
|
||||
<li><a href="#">Separated link</a></li>
|
||||
|
Loading…
Reference in New Issue
Block a user