Simple app for expenses management made in Laravel 5.4.
Skip to available routes & screenshot
You need to have NodeJS
(http://nodejs.org) installed. If you already have NodeJS installed, follow the instructions below. Open terminal in main folder and install npm packages with command:
> npm install
Update the packages with command:
> npm update
You need to install composer
(https://getcomposer.org/). Update package dependencies running the following commands in console:
> composer install
> composer update
There are several configuration options in this package listed below.
First you need to generate secure key by running in terminal (at the project root folder) following command:
> php artisan key:generate
Rename file .env.example
(which is in the root folder) to .env
, open it and change database connection parameters:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=expenses
DB_USERNAME=root
DB_PASSWORD=root
You can edit accounts credentials in file config/accounts.php
. You can login to them with buttons on /login
page (for testing purposes).
You can provide following elements:
name
- user nameemail
- user email, used to log in (must be in correct format),password
- user password, used to log in (will be encrypted in database),roles
- array of roles, i.e.['user', 'admin']
, that will be assigned to the account after its creation.
Example item can look like this:
'user' => [
'name' => 'User',
'email' => 'email@domain.com',
'password' => 'secret',
'roles' => ['user']
],
To add accounts to the database you need to run following command in console:
> php artisan migrate
> php artisan db:seed --class=UsersTableSeeder
If you're having problem you might need to rollback database migrations (this will erase all the data stored in) with the command:
> php artisan migrate:reset
You can edit navigation links in file config/navbars.php
. Currently they are supported role based links on top and side. Each item can contain route, text, icon, links
elements. With links
element you can provide array of items for the second level menu on the side i.e:
'admin' => [ // role name
'side' => [ // side or top?
[
'name' => 'Roles',
'route' => '#',
'icon' => 'fa-user-md', // font-awesome icon
'links' => [ // array of second level links
['name' => 'View roles', 'route' => '/roles', 'icon' => 'fa-list'],
]
],
[
'name' => 'Users',
'route' => 'users',
'icon' => 'fa-users',
'links' => [
['name' => 'Create user', 'route' => '/users/create', 'icon' => 'fa-plus'],
['name' => 'View users', 'route' => '/users', 'icon' => 'fa-list'],
]
],
],
'top' => [], // same syntax as in side array
],
You can seed the database with auto-generated items (currently there is supported generation of: users, expenses, payments
). Expenses
and payments
records will be randomly associated with each other and with users accounts.
If you want to change the count of generated items you can do this by editing the file config/database.php
, at the end there is proper code to do this:
'seeding_count' => [
'users' => 3, // UsersTableSeeder
'expenses' => 30, // ExpensesTableSeeder
'payments' => 100 // PaymentsTableSeeder
],
You can also change the default table names but this is not recommended since is was not tested yet. You can do this be editing the same file and changing following lines (and the end of file):
'payments' => 'payments',
'expenses' => 'expenses'
To seed the database you can type in following command:
> php artisan migrate --seed
This project uses the Spatie Larvel Permission
library (https://github.com/spatie/laravel-permission).
To add some new roles and associated permissions, edit the file config/roles.php
. There is currently 16 permissions in following naming convention:
Permissions naming convention:
"{Model}{Action}{Owner}"
{Model} - name of the model class {Expense|Payment}
{Action} - name of action {Get|Store|Update|Delete}
{Owner} - the owner of model {Own|All}
In example, if we got permission named ExpenseUpdateAll, we can update
expenses owned by anyone, but with permission named ExpenseUpdateOwn,
we can update the expense only when we are owning it (user.id must
be equal to expense.user_id).
To specify some role with its permissions you should do this as below:
'admin' => [
// Expense related permissions:
['name' => 'ExpenseGetAll', 'guard_name' => 'web'],
['name' => 'ExpenseStoreAll', 'guard_name' => 'web'],
// ... rest of permissions
],
To run the server open terminal in root folder and type following command:
> php artisan serve
Now you should be able to visit the site at: http://localhost:8000.
Hover over link to see its address (route with variable). CTRL + click
opens link in new tab.
{user}
stands for User id in the database (users.id). {expense}
, Expense id, etc.
- Login page
- Homepage
- Admin (also inherits all permissions from user role)
-
localhost:8000/users * create new user
-
localhost:8000/roles
-
localhost:8000/expenses main route inherits from user (view own expenses)
-
localhost:8000/payments main route inherits from user (view own payments)
- User
- user menu
- localhost:8000/expenses
- view all expenses
- create new expense
- edit/remove expense only when it doesn't have any associated accepted/rejected payments to it
- view expense details and associated payments
- localhost:8000/payments
- view all payments
- create new payment associated to expense
- view payment details
- edit/delete payment only when associated expense doesn't have any accepted/rejected payments to it
- view
accepted
own payments - view
pending
own payments - view
rejected
own payments
- etc.