diff --git a/app/config/mail.php b/app/config/mail.php index a208c28e86..f9444f6c2e 100644 --- a/app/config/mail.php +++ b/app/config/mail.php @@ -2,7 +2,7 @@ return [ 'driver' => 'smtp', - 'host' => '', + 'host' => ';', 'port' => 587, 'from' => ['address' => '', 'name' => 'Firefly V'], 'encryption' => 'tls', diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php new file mode 100644 index 0000000000..efd7cc92d7 --- /dev/null +++ b/app/controllers/AccountController.php @@ -0,0 +1,99 @@ +accounts = $accounts; + } + + /** + * Display a listing of the resource. + * + * @return Response + */ + public function index() + { + + } + + + /** + * Show the form for creating a new resource. + * + * @return Response + */ + public function create() + { + if($this->accounts->count() == 0) { + return View::make('accounts.create-first-time'); + } + return View::make('accounts'); + } + + + /** + * Store a newly created resource in storage. + * + * @return Response + */ + public function store() + { + $account = $this->accounts->store(); + if($account === false) { + Session::flash('error','Could not create account with provided information'); + return Redirect::route('accounts.create')->withInput()->withErrors($this->accounts->validator); + } + } + + + /** + * Display the specified resource. + * + * @param int $id + * @return Response + */ + public function show($id) + { + // + } + + + /** + * Show the form for editing the specified resource. + * + * @param int $id + * @return Response + */ + public function edit($id) + { + // + } + + + /** + * Update the specified resource in storage. + * + * @param int $id + * @return Response + */ + public function update($id) + { + // + } + + + /** + * Remove the specified resource from storage. + * + * @param int $id + * @return Response + */ + public function destroy($id) + { + // + } + + +} diff --git a/app/lib/Firefly/Storage/Account/AccountRepositoryInterface.php b/app/lib/Firefly/Storage/Account/AccountRepositoryInterface.php index 39399bdbce..a8d4a21ddc 100644 --- a/app/lib/Firefly/Storage/Account/AccountRepositoryInterface.php +++ b/app/lib/Firefly/Storage/Account/AccountRepositoryInterface.php @@ -6,6 +6,9 @@ namespace Firefly\Storage\Account; interface AccountRepositoryInterface { + public function count(); + public function store(); + } \ No newline at end of file diff --git a/app/lib/Firefly/Storage/Account/EloquentAccountRepository.php b/app/lib/Firefly/Storage/Account/EloquentAccountRepository.php index 81fbca3990..5c03c33304 100644 --- a/app/lib/Firefly/Storage/Account/EloquentAccountRepository.php +++ b/app/lib/Firefly/Storage/Account/EloquentAccountRepository.php @@ -5,6 +5,8 @@ namespace Firefly\Storage\Account; class EloquentAccountRepository implements AccountRepositoryInterface { + public $validator; + public function __construct() { } @@ -14,4 +16,15 @@ class EloquentAccountRepository implements AccountRepositoryInterface } + public function store() { + $account = new \Account; + $account->name = Input::get('name'); + + if($account->isValid()) { + + } + $this->validator = $account->validator; + return false; + } + } \ No newline at end of file diff --git a/app/models/Account.php b/app/models/Account.php index 3f206da7c4..ffc5863ca9 100644 --- a/app/models/Account.php +++ b/app/models/Account.php @@ -1,9 +1,14 @@ 'required|between:100,100', + ]; + public function accountType() { return $this->belongsTo('AccountType'); diff --git a/app/models/Elegant.php b/app/models/Elegant.php index 94318f6afa..8d4bc8b4ac 100644 --- a/app/models/Elegant.php +++ b/app/models/Elegant.php @@ -4,12 +4,15 @@ class Elegant extends Eloquent { public static $rules = []; + public $validator; public function isValid() { - return Validator::make( + $validator = Validator::make( $this->toArray(), $this::$rules - )->passes(); + ); + $this->validator = $validator; + return $validator->passes(); } } \ No newline at end of file diff --git a/app/routes.php b/app/routes.php index b4511d3af8..324aaa29d4 100644 --- a/app/routes.php +++ b/app/routes.php @@ -17,8 +17,10 @@ Route::get('/verify/{verification}',['uses' => 'UserController@verify','as' => ' Route::get('/reset/{reset}',['uses' => 'UserController@reset','as' => 'reset','before' => 'guest']); Route::get('/logout',['uses' => 'UserController@logout','as' => 'logout','before' => 'auth']); Route::get('/remindme',['uses' => 'UserController@remindme','as' => 'remindme','before' => 'guest']); - - Route::post('/login',['uses' => 'UserController@postLogin','before' => 'csrf|guest']); Route::post('/register',['uses' => 'UserController@postRegister','before' => 'csrf|guest']); -Route::post('/remindme',['uses' => 'UserController@postRemindme','before' => 'csrf|guest']); \ No newline at end of file +Route::post('/remindme',['uses' => 'UserController@postRemindme','before' => 'csrf|guest']); + +// accountcontroller +Route::get('/accounts/create',['uses' => 'AccountController@create','as' => 'accounts.create','before' => 'auth']); +Route::post('/accounts/store',['uses' => 'AccountController@store','as' => 'accounts.store','before' => 'csrf|auth']); \ No newline at end of file diff --git a/app/views/accounts/create-first-time.blade.php b/app/views/accounts/create-first-time.blade.php new file mode 100644 index 0000000000..0be135e733 --- /dev/null +++ b/app/views/accounts/create-first-time.blade.php @@ -0,0 +1,66 @@ +@extends('layouts.default') +@section('content') +
+
+

Firefly
+ Add a new account +

+

+ Accounts are the record holders for transactions and transfers. Money moves + from one account to another. +

+

+ In a double-entry bookkeeping system (such as this one) there is a "from" account and a "to" + account, even when money is created from thin air (such as interest, or when new accounts already have + a positive balance). +

+

+ Your first account should be a checking or savings account. Enter its name and if relevant + the current balance. Check your bank statements for the last current balance you can find. +

+ {{Form::open(['class' => 'form-horizontal','url' => route('accounts.store')])}} +
+ {{ Form::label('name', 'Account name', ['class' => 'col-sm-3 control-label'])}} +
+ {{ Form::text('name', Input::old('name'), ['class' => 'form-control']) }} + @if($errors->has('name')) +

{{$errors->first('name')}}

+ @else +

Use something descriptive such as "checking account" or "My Bank Main Account".

+ @endif + +
+
+
+ {{ Form::label('openingbalance', 'Opening balance', ['class' => 'col-sm-3 control-label'])}} +
+ {{ Form::input('number','openingbalance', Input::old('openingbalance'), ['step' => 'any', 'class' => 'form-control'])}} + @if($errors->has('openingbalance')) +

{{$errors->first('openingbalance')}}

+ @else +

What's the current balance of this new account?

+ @endif +
+
+
+ {{ Form::label('openingbalancedate', 'Opening balance date', ['class' => 'col-sm-3 control-label'])}} +
+ {{ Form::input('date','openingbalancedate', Input::old('openingbalancedate') ?: date('Y-m-d'), ['class' => 'form-control']) }} + @if($errors->has('openingbalancedate')) +

{{$errors->first('openingbalancedate')}}

+ @else +

When was this the balance of the new account? Since your bank statements may lag behind, update this date to match the date of the last known balance of the account.

+ @endif +
+
+
+
+ +
+
+ + + +
+
+@stop \ No newline at end of file diff --git a/app/views/layouts/default.blade.php b/app/views/layouts/default.blade.php index 1ee555f09b..08c91c3350 100644 --- a/app/views/layouts/default.blade.php +++ b/app/views/layouts/default.blade.php @@ -19,6 +19,7 @@
+ @include('partials.flashes') @yield('content')
diff --git a/app/views/start.blade.php b/app/views/start.blade.php index 736e57dfe2..2f1821e78c 100644 --- a/app/views/start.blade.php +++ b/app/views/start.blade.php @@ -23,7 +23,7 @@ Click the link below to create your first account, and get started with Firefly.

- Start with a new account + Start with a new account