Skip to content
This repository was archived by the owner on Jan 5, 2019. It is now read-only.

Commit dfc2af4

Browse files
author
Mario Basic
committed
Added console command to add a new user.
1 parent 7f0776a commit dfc2af4

File tree

9 files changed

+106
-40
lines changed

9 files changed

+106
-40
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use App\User;
6+
use Validator;
7+
use Illuminate\Console\Command;
8+
9+
class CreateUser extends Command
10+
{
11+
/**
12+
* The name and signature of the console command.
13+
*
14+
* @var string
15+
*/
16+
protected $signature = 'user:create
17+
{name : The name of the user}
18+
{email : Email used to login}';
19+
20+
/**
21+
* The console command description.
22+
*
23+
* @var string
24+
*/
25+
protected $description = 'Creates a new user for the application.';
26+
27+
/**
28+
* Create a new command instance.
29+
*
30+
* @return void
31+
*/
32+
public function __construct()
33+
{
34+
parent::__construct();
35+
}
36+
37+
/**
38+
* Execute the console command.
39+
*
40+
* @return mixed
41+
*/
42+
public function handle()
43+
{
44+
$name = $this->argument('name');
45+
$email = $this->argument('email');
46+
$password = $this->secret('User password:');
47+
48+
$data = compact('name', 'email', 'password');
49+
$validator = Validator::make($data, [
50+
'name' => 'required|max:255',
51+
'email' => 'required|email|max:255|unique:users',
52+
'password' => 'required|min:6',
53+
]);
54+
if($validator->fails()) {
55+
foreach($validator->errors()->all() as $error) {
56+
$this->error($error);
57+
return 0;
58+
}
59+
}
60+
61+
User::create([
62+
'name' => $data['name'],
63+
'email' => $data['email'],
64+
'password' => bcrypt($data['password']),
65+
]);
66+
67+
$this->info('User has been created.');
68+
$this->comment('You can now login using the email and password entered here.');
69+
}
70+
}

app/Console/Kernel.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class Kernel extends ConsoleKernel
1414
*/
1515
protected $commands = [
1616
// Commands\Inspire::class,
17-
\App\Console\Commands\SpawnOccurrences::class
17+
\App\Console\Commands\SpawnOccurrences::class,
18+
\App\Console\Commands\CreateUser::class
1819
];
1920

2021
/**

app/Http/routes.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,16 @@
1919
Route::resource('services', 'ServiceController');
2020
});
2121

22-
Route::auth();
22+
// Authentication Routes...
23+
$this->get('login', 'Auth\AuthController@showLoginForm');
24+
$this->post('login', 'Auth\AuthController@login');
25+
$this->get('logout', 'Auth\AuthController@logout');
26+
27+
// Registration Routes...
28+
// $this->get('register', 'Auth\AuthController@showRegistrationForm');
29+
// $this->post('register', 'Auth\AuthController@register');
30+
31+
// Password Reset Routes...
32+
$this->get('password/reset/{token?}', 'Auth\PasswordController@showResetForm');
33+
$this->post('password/email', 'Auth\PasswordController@sendResetLinkEmail');
34+
$this->post('password/reset', 'Auth\PasswordController@reset');

readme.md

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,17 @@
11
# Kyle
22

3-
**Monitor when to bill clients based on their services employed.**
3+
**Monitor when to bill clients based on the services they use.**
44

5-
The main point of interest here are "events".
5+
## Create new user
66

7-
Services have:
7+
To create a new user use this command:
88

9-
- title
10-
- note
11-
- month ( 1-12 ) - which month this expense happens
12-
- day ( 1-31 ) - which day this expense happens
13-
- cost
14-
- currency (HRK, USD, EUR)
15-
- client_id
16-
- active
9+
```
10+
php artisan user:create "John Doe" [email protected]
11+
```
1712

18-
ServiceLog have:
13+
You will be asked for the password.
1914

20-
- service_id
21-
- occurs_at (exact date of the event)
22-
- offer_sent
23-
- payment_received
24-
- receipt_sent
15+
## Info
2516

26-
Clients have:
27-
28-
- name
29-
- oib
30-
- street
31-
- city
32-
- postal code
33-
34-
> At the start of every year, create new service occurrences using task scheduler
17+
At the start of every year 1st of January a command `occurrences:spawn` is executed using the task scheduler. **Be sure to add Cron entry `* * * * * php /path/to/artisan schedule:run >> /dev/null 2>&1` to your server.** This command creates new occurrences for services that will occur in the new year.

resources/views/auth/login.blade.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
@extends('layouts.app')
22

3+
@section('meta_title', 'Login')
4+
35
@section('content')
46
<div class="container">
57
<div class="row">

resources/views/auth/passwords/email.blade.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
@extends('layouts.app')
22

3+
@section('meta_title', 'Reset Password')
4+
35
<!-- Main Content -->
46
@section('content')
57
<div class="container">

resources/views/auth/passwords/reset.blade.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
@extends('layouts.app')
22

3+
@section('meta_title', 'Reset Password')
4+
35
@section('content')
46
<div class="container">
57
<div class="row">

resources/views/auth/register.blade.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
@extends('layouts.app')
22

3+
@section('meta_title', 'Register')
4+
35
@section('content')
46
<div class="container">
57
<div class="row">

resources/views/layouts/app.blade.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,11 @@
99

1010
<!-- Fonts -->
1111
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css" integrity="sha384-XdYbMnZ/QjLh6iI4ogqCTaIjrFk87ip+ekIjefZch0Y+PvJ8CDYtEs1ipDmPorQ+" crossorigin="anonymous">
12-
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:100,300,400,700">
1312

1413
<!-- Styles -->
1514
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
1615
{{-- <link href="{{ elixir('css/app.css') }}" rel="stylesheet"> --}}
1716

18-
<style>
19-
body {
20-
font-family: 'Lato';
21-
}
22-
23-
.fa-btn {
24-
margin-right: 6px;
25-
}
26-
</style>
2717
</head>
2818
<body id="app-layout">
2919
<nav class="navbar navbar-default navbar-static-top">
@@ -70,8 +60,10 @@
7060
<ul class="nav navbar-nav navbar-right">
7161
<!-- Authentication Links -->
7262
@if (Auth::guest())
73-
<li><a href="{{ url('/login') }}">Login</a></li>
74-
<li><a href="{{ url('/register') }}">Register</a></li>
63+
<li class="{{ Ekko::isActiveUrl('/login') }}">
64+
<a href="{{ url('/login') }}">Login</a>
65+
</li>
66+
{{-- <li><a href="{{ url('/register') }}">Register</a></li> --}}
7567
@else
7668
<li class="dropdown">
7769
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">

0 commit comments

Comments
 (0)