mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Some more code to facilitate creating your very first account.
This commit is contained in:
parent
b216c1e16b
commit
67ef8f6be6
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
'driver' => 'smtp',
|
'driver' => 'smtp',
|
||||||
'host' => '',
|
'host' => ';',
|
||||||
'port' => 587,
|
'port' => 587,
|
||||||
'from' => ['address' => '', 'name' => 'Firefly V'],
|
'from' => ['address' => '', 'name' => 'Firefly V'],
|
||||||
'encryption' => 'tls',
|
'encryption' => 'tls',
|
||||||
|
99
app/controllers/AccountController.php
Normal file
99
app/controllers/AccountController.php
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
|
||||||
|
|
||||||
|
class AccountController extends \BaseController {
|
||||||
|
|
||||||
|
public function __construct(ARI $accounts) {
|
||||||
|
$this->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)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -6,6 +6,9 @@ namespace Firefly\Storage\Account;
|
|||||||
|
|
||||||
interface AccountRepositoryInterface
|
interface AccountRepositoryInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
public function count();
|
public function count();
|
||||||
|
|
||||||
|
public function store();
|
||||||
|
|
||||||
}
|
}
|
@ -5,6 +5,8 @@ namespace Firefly\Storage\Account;
|
|||||||
|
|
||||||
class EloquentAccountRepository implements AccountRepositoryInterface
|
class EloquentAccountRepository implements AccountRepositoryInterface
|
||||||
{
|
{
|
||||||
|
public $validator;
|
||||||
|
|
||||||
public function __construct()
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,9 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
class Account extends Eloquent
|
class Account extends Elegant
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public static $rules
|
||||||
|
= [
|
||||||
|
'name' => 'required|between:100,100',
|
||||||
|
];
|
||||||
|
|
||||||
public function accountType()
|
public function accountType()
|
||||||
{
|
{
|
||||||
return $this->belongsTo('AccountType');
|
return $this->belongsTo('AccountType');
|
||||||
|
@ -4,12 +4,15 @@
|
|||||||
class Elegant extends Eloquent
|
class Elegant extends Eloquent
|
||||||
{
|
{
|
||||||
public static $rules = [];
|
public static $rules = [];
|
||||||
|
public $validator;
|
||||||
|
|
||||||
public function isValid()
|
public function isValid()
|
||||||
{
|
{
|
||||||
return Validator::make(
|
$validator = Validator::make(
|
||||||
$this->toArray(),
|
$this->toArray(),
|
||||||
$this::$rules
|
$this::$rules
|
||||||
)->passes();
|
);
|
||||||
|
$this->validator = $validator;
|
||||||
|
return $validator->passes();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -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('/reset/{reset}',['uses' => 'UserController@reset','as' => 'reset','before' => 'guest']);
|
||||||
Route::get('/logout',['uses' => 'UserController@logout','as' => 'logout','before' => 'auth']);
|
Route::get('/logout',['uses' => 'UserController@logout','as' => 'logout','before' => 'auth']);
|
||||||
Route::get('/remindme',['uses' => 'UserController@remindme','as' => 'remindme','before' => 'guest']);
|
Route::get('/remindme',['uses' => 'UserController@remindme','as' => 'remindme','before' => 'guest']);
|
||||||
|
|
||||||
|
|
||||||
Route::post('/login',['uses' => 'UserController@postLogin','before' => 'csrf|guest']);
|
Route::post('/login',['uses' => 'UserController@postLogin','before' => 'csrf|guest']);
|
||||||
Route::post('/register',['uses' => 'UserController@postRegister','before' => 'csrf|guest']);
|
Route::post('/register',['uses' => 'UserController@postRegister','before' => 'csrf|guest']);
|
||||||
Route::post('/remindme',['uses' => 'UserController@postRemindme','before' => 'csrf|guest']);
|
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']);
|
66
app/views/accounts/create-first-time.blade.php
Normal file
66
app/views/accounts/create-first-time.blade.php
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
@extends('layouts.default')
|
||||||
|
@section('content')
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-8 col-md-8 col-sm-12">
|
||||||
|
<h1>Firefly<br/>
|
||||||
|
<small>Add a new account</small>
|
||||||
|
</h1>
|
||||||
|
<p class="lead">
|
||||||
|
Accounts are the record holders for transactions and transfers. Money moves
|
||||||
|
from one account to another.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
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).
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
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.
|
||||||
|
</p>
|
||||||
|
{{Form::open(['class' => 'form-horizontal','url' => route('accounts.store')])}}
|
||||||
|
<div class="form-group">
|
||||||
|
{{ Form::label('name', 'Account name', ['class' => 'col-sm-3 control-label'])}}
|
||||||
|
<div class="col-sm-9">
|
||||||
|
{{ Form::text('name', Input::old('name'), ['class' => 'form-control']) }}
|
||||||
|
@if($errors->has('name'))
|
||||||
|
<p class="text-danger">{{$errors->first('name')}}</p>
|
||||||
|
@else
|
||||||
|
<p class="text-info">Use something descriptive such as "checking account" or "My Bank Main Account".</p>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
{{ Form::label('openingbalance', 'Opening balance', ['class' => 'col-sm-3 control-label'])}}
|
||||||
|
<div class="col-sm-9">
|
||||||
|
{{ Form::input('number','openingbalance', Input::old('openingbalance'), ['step' => 'any', 'class' => 'form-control'])}}
|
||||||
|
@if($errors->has('openingbalance'))
|
||||||
|
<p class="text-danger">{{$errors->first('openingbalance')}}</p>
|
||||||
|
@else
|
||||||
|
<p class="text-info">What's the current balance of this new account?</p>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
{{ Form::label('openingbalancedate', 'Opening balance date', ['class' => 'col-sm-3 control-label'])}}
|
||||||
|
<div class="col-sm-9">
|
||||||
|
{{ Form::input('date','openingbalancedate', Input::old('openingbalancedate') ?: date('Y-m-d'), ['class' => 'form-control']) }}
|
||||||
|
@if($errors->has('openingbalancedate'))
|
||||||
|
<p class="text-danger">{{$errors->first('openingbalancedate')}}</p>
|
||||||
|
@else
|
||||||
|
<p class="text-info">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.</p>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-offset-3 col-sm-9">
|
||||||
|
<button type="submit" class="btn btn-default">Create my first account</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@stop
|
@ -19,6 +19,7 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
@include('partials.flashes')
|
||||||
@yield('content')
|
@yield('content')
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
Click the link below to create your first account, and get started with Firefly.
|
Click the link below to create your first account, and get started with Firefly.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<a href="#" class="btn btn-info">Start with a new account</a>
|
<a href="{{route('accounts.create')}}" class="btn btn-info">Start with a new account</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user