mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 18:54:58 +00:00 
			
		
		
		
	Some work on the category controller.
This commit is contained in:
		| @@ -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(); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|   | ||||
| @@ -92,7 +92,8 @@ class Account extends Ardent | ||||
|         ); | ||||
|     } | ||||
|  | ||||
|     public function predict(\Carbon\Carbon $date) { | ||||
|     public function predict(\Carbon\Carbon $date) | ||||
|     { | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -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'); | ||||
|     } | ||||
|  | ||||
| }  | ||||
| @@ -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; | ||||
|         } | ||||
|     } | ||||
|   | ||||
| @@ -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'); | ||||
|     } | ||||
| }  | ||||
| @@ -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', | ||||
|   | ||||
| @@ -14,12 +14,15 @@ | ||||
|  * @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 = [ | ||||
|     public static $factory | ||||
|         = [ | ||||
|             'type' => 'string' | ||||
|         ]; | ||||
|  | ||||
|   | ||||
| @@ -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> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user