Magmat - a super smart tool for companies to manage and keep track of Assets, Expenses, Budgets and Requests.
Magmat - a super smart tool for companies to manage and keep track of Assets, Expenses, Budgets and Requests.
Repository
https://github.com/steemrcp/magmat
New Project
What is the project about?
Ever considered the stress of a company managing and keeping track of Assets, Expenses, Budgets and Requests. When a department makes a request for funds, most times this goes through series of paper work before its been approved by the right department or personnel. When funds for this request is disbursed, it most times follow same procedure as that of request. The department gets all expenses on paper sheets or excel files which makes it kind of extra tedious to track and compile. Magmat aims to solve this problem.
Magmat is a super smart tool for companies to manage and keep track of Assets, Expenses, Budgets and Requests.
Technology Stack
Laravel Framework
Feature Added
- User Interface
https://github.com/steemrcp/magmat/commit/694443f0db43b2bba06ee5261b7b95c1456e1c20
- User and Company registration completed: All users of this tool must be registered under a company (a user belongs to a company) so we have
CompanyUser
Model
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class CompanyUser extends Model
{
//
protected $fillable = [
'id', 'company_id', 'user_id', 'invitedby_id', 'invite_accepted', 'role',
];
}
A user gets to the homepage via Route::get('/', 'PageController@home');
. This Route calls the home
method in the PageController
which loads the index view as the homepage.
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class PageController extends Controller
{
//
public function home()
{
return view ('pages.index');
}
}
Route::get('/sign-up', 'PageController@signUp');
calls a GET method to fetch a view by calling the signUp
method of the PageController
. This view presents the user with a form for registration.
The {{ csrf_field() }}
is added to the form to gaurd against cross-site scripting (XSS). Details of the form are submitted as a POST method via Route::post('/create-account', 'AccountController@createAccount');
This Route calls the createAccount
method of the AccountController
to process the registration script.
<?php
namespace App\Http\Controllers;
use Auth;
use App\Company;
use App\UserInvite;
use App\Http\Repositories\CompanyRepository;
use App\Http\Repositories\UserRepository;
use App\Http\Requests\SignupRequest;
use Illuminate\Http\Request;
class AccountController extends Controller
{
// Inject UserRepository and CompanyRepository into this Controller
public function __construct(UserRepository $users, CompanyRepository $companies)
{
$this->middleware('auth', ['except' => ['createAccount']]);
$this->users = $users;
$this->companies = $companies;
}
public function createAccount(SignupRequest $request)
{
//for sign in after account creation
$email = $request->email;
$password = $request->password;
$slug = $this->users->slugIt($request->company);
if (Company::where('slug', $slug)->count() > 0) {
// return redirect()->back()->withErrors("Company already Exists");
return redirect()->back()->with('error', 'Company already Exists');
} else {
$users = $this->users->createAccount($request);
if (!$users) {
// Process the errors
return redirect()->back()->withErrors("Registration Failed.");
}
// Log user in
auth()->login($users);
return redirect('/home')->with('message', "Complete Your Registration");
}
}
}
?>
Care was taken while submitting user details to the database. Atomicity of the database transaction was put in place so its either all actions occur or nothing at all.
public function createAccount($data)
{
$slug = $this->slugIt($data->company);
DB::beginTransaction();
$user = User::create([
'id' => $this->generateUuid(),
'email' => strtolower($data->email),
'password' => Hash::make($data->password),
]);
$company = Company::create([
'id' => $this->generateUuid(),
'main_user' => $user->id,
'name' => $data->company,
'slug' => $slug
]);
$companyUser = CompanyUser::create([
'id' => $this->generateUuid(),
'company_id' => $company->id,
'user_id' => $user->id,
'invitedby_id' => $user->id,
'role' => 'Owner',
'invite_accepted' => 1
]);
if (!$user && !$company && !$companyUser) {
DB::rollback();
return false;
}
DB::commit();
return $user;
}
}
If any part of the database transaction fails to execute, DB::rollback();
is used to roll back database to the its initial state.
https://github.com/steemrcp/magmat/commit/c07a6ab43d3b76c8ebddc67574320fed168ac2be
- User sign up update: Sign ups aren't completed at the initial stage but stored in the
auth
session and passed to all other pages needed for user to provide complete details for registration.
https://github.com/steemrcp/magmat/commit/697019051d8508218cbb5fcc666eeebff657477b
- User Verification by email now complete: A user must be verified in order to carry out activities on Magmat.
User verification is achieved by listening for a GET request, when a request is recieved at account/activate/{id}
endpoint with a parameter id
, Route Model Binding is applied to fetch for user whose account is tied to the id provided.
Route::get('/account/activate/{id}', 'AccountController@accountActivationByEmail')
This route then calls the accountActivationByEmail
method of AccountController
. The AccountController
injects the User Model to fetch resource from accountActivationByEmail
method in the User
Model. The user is notified if all goes fine.
public function accountActivationByEmail($id)
{
// Lets activate user account
$activate = $this->users->accountActivationByEmail($id);
if ($activate) {
Auth::logout();
//send to where they will enter their details
//Alert::success('Thanks for veryfying your email. You can now log in to your Magmat Account.')-persistent("OK");
return redirect('/sign-in')->with('message', "Thanks for veryfying your email. You can now log in to your MAgmat Account.");;
}
Alert::error('Cannot activate your account at this time','Invalid activation key')->autoclose(4000);
return redirect('home');
}
https://github.com/steemrcp/magmat/commit/3bba9c3a0060810992a80716f17dc4983a19ee84
- Incase of activation mail failed or not received, user can request for another activation mail to be resent.
https://github.com/steemrcp/magmat/commit/e84606bdf20827d4f167904f53675e4017d36c16
- Login functionality added
https://github.com/steemrcp/magmat/commit/217e6a7b003f8f070490268aed08844862547aac
Roadmap
Create Company functionalities.
Company Admin should be able create departments for the company
Users should be able to be added one or more departments by admin
Users should be able to receive invites from departmental heads.
Departments should be able to submit orders for funds and budgets, also invoice for expenses.
Orders and invoices should be processed and reviewed by the appropriate department.
More roadmap to be added as i come close to completing the above ones.
How to contribute
Contact steemrcp on the github repo or [email protected]
You can fork the repo
Make your changes
Make a pull request
I have seen an influx of contributions like this recently. I have a problem with this, because to me it seems like these are just being submitted to receive a reward. The reasons I think this are the following
If you really want to provide value to the open source community and want to get rewarded for it, then I recommend thinking of a project of which the use is actually tangible.
Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]