|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by PhpStorm. |
|
4
|
|
|
* User: Mark |
|
5
|
|
|
* Date: 12/10/2016 |
|
6
|
|
|
* Time: 20:13. |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace App\Modules\Accounts; |
|
10
|
|
|
|
|
11
|
|
|
use App\Classes\Email; |
|
12
|
|
|
use App\Model\Account; |
|
13
|
|
|
use Illuminate\Http\Request; |
|
14
|
|
|
use App\Modules\ModuleEngine; |
|
15
|
|
|
use Illuminate\Contracts\View\View; |
|
16
|
|
|
use App\Classes\Repositories\RoleRepository; |
|
17
|
|
|
use App\Http\Controllers\DashboardController; |
|
18
|
|
|
use App\Classes\Repositories\AccountRepository; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Class Controller. |
|
22
|
|
|
*/ |
|
23
|
|
|
class Controller extends ModuleEngine |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* @var AccountRepository |
|
27
|
|
|
*/ |
|
28
|
|
|
private $accounts; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @var RoleRepository |
|
32
|
|
|
*/ |
|
33
|
|
|
private $roles; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* This is the dashboard controller, this should be used |
|
37
|
|
|
* whenever any class is going to show the dashboard to |
|
38
|
|
|
* the user. |
|
39
|
|
|
* |
|
40
|
|
|
* DashboardController constructor. |
|
41
|
|
|
* @param AccountRepository $accounts |
|
42
|
|
|
* @param RoleRepository $roles |
|
43
|
|
|
*/ |
|
44
|
|
|
public function __construct(AccountRepository $accounts, RoleRepository $roles) |
|
45
|
|
|
{ |
|
46
|
|
|
$this->accounts = $accounts; |
|
47
|
|
|
|
|
48
|
|
|
$this->roles = $roles; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Return all the accounts viable. |
|
53
|
|
|
*/ |
|
54
|
|
|
public function index() |
|
55
|
|
|
{ |
|
56
|
|
|
return $this->make('index')->with('accounts', $this->accounts->all()); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Form to create a new account. |
|
61
|
|
|
* |
|
62
|
|
|
* @param RoleRepository $roleRepository |
|
63
|
|
|
* @return Controller|View |
|
64
|
|
|
*/ |
|
65
|
|
|
public function create(RoleRepository $roleRepository) |
|
66
|
|
|
{ |
|
67
|
|
|
return $this->make('create')->with('groups', $roleRepository->get()); |
|
|
|
|
|
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Store a new account to the database. |
|
72
|
|
|
* |
|
73
|
|
|
* @param Request $request |
|
74
|
|
|
* @param Account $account |
|
75
|
|
|
* @return \Illuminate\Http\RedirectResponse |
|
76
|
|
|
*/ |
|
77
|
|
|
public function store(Request $request, Account $account) |
|
78
|
|
|
{ |
|
79
|
|
|
$this->validate($request, ['forename' => 'required|min:1|max:255', 'surname' => 'required|min:3|max:255', 'password' => 'required|min:3|max:255', 'email' => 'required|email', 'group' => 'required|integer']); |
|
80
|
|
|
|
|
81
|
|
|
$account->forename = $request['forename']; |
|
82
|
|
|
$account->surname = $request['surname']; |
|
83
|
|
|
$account->role_id = $request['group']; |
|
84
|
|
|
$account->email = $request['email']; |
|
85
|
|
|
$account->setPassword($request['password'])->save(); |
|
86
|
|
|
|
|
87
|
|
|
return redirect()->route('admin.accounts.index'); |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.