From 67ef8f6be6ce9641e5e29532874092fe844f8da2 Mon Sep 17 00:00:00 2001
From: Sander Dorigo
Date: Mon, 30 Jun 2014 15:46:12 +0200
Subject: [PATCH] Some more code to facilitate creating your very first
account.
---
app/config/mail.php | 2 +-
app/controllers/AccountController.php | 99 +++++++++++++++++++
.../Account/AccountRepositoryInterface.php | 3 +
.../Account/EloquentAccountRepository.php | 13 +++
app/models/Account.php | 7 +-
app/models/Elegant.php | 7 +-
app/routes.php | 8 +-
.../accounts/create-first-time.blade.php | 66 +++++++++++++
app/views/layouts/default.blade.php | 1 +
app/views/start.blade.php | 2 +-
10 files changed, 200 insertions(+), 8 deletions(-)
create mode 100644 app/controllers/AccountController.php
create mode 100644 app/views/accounts/create-first-time.blade.php
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')])}}
+
+
+
+
+
+
+
+
+
+@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