|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace BB\Http\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use BB\Entities\User; |
|
6
|
|
|
use BB\Repo\PolicyRepository; |
|
7
|
|
|
use BB\Repo\UserRepository; |
|
8
|
|
|
use BB\Validators\InductionValidator; |
|
9
|
|
|
use Illuminate\Http\Request; |
|
10
|
|
|
use BB\Http\Requests; |
|
11
|
|
|
use Michelf\Markdown; |
|
12
|
|
|
|
|
13
|
|
|
class MemberInductionController extends Controller |
|
14
|
|
|
{ |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @var PolicyRepository |
|
18
|
|
|
*/ |
|
19
|
|
|
private $policyRepository; |
|
20
|
|
|
/** |
|
21
|
|
|
* @var UserRepository |
|
22
|
|
|
*/ |
|
23
|
|
|
private $userRepository; |
|
24
|
|
|
/** |
|
25
|
|
|
* @var InductionValidator |
|
26
|
|
|
*/ |
|
27
|
|
|
private $inductionValidator; |
|
28
|
|
|
|
|
29
|
|
|
function __construct(PolicyRepository $policyRepository, UserRepository $userRepository, InductionValidator $inductionValidator) |
|
|
|
|
|
|
30
|
|
|
{ |
|
31
|
|
|
$this->policyRepository = $policyRepository; |
|
32
|
|
|
$this->userRepository = $userRepository; |
|
33
|
|
|
$this->inductionValidator = $inductionValidator; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Display a listing of the resource. |
|
38
|
|
|
* |
|
39
|
|
|
* @return \Illuminate\Http\Response |
|
40
|
|
|
*/ |
|
41
|
|
|
public function index() |
|
42
|
|
|
{ |
|
43
|
|
|
// |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Display the specified resource. |
|
48
|
|
|
* |
|
49
|
|
|
* @param int $id |
|
50
|
|
|
* @return \Illuminate\Http\Response |
|
51
|
|
|
*/ |
|
52
|
|
|
public function show($id) |
|
53
|
|
|
{ |
|
54
|
|
|
$user = User::findWithPermission($id); |
|
55
|
|
|
|
|
56
|
|
|
$document = $this->policyRepository->getByName('member-agreement'); |
|
57
|
|
|
|
|
58
|
|
|
$htmlDocument = Markdown::defaultTransform($document); |
|
59
|
|
|
|
|
60
|
|
|
return view('account.induction')->with('user', $user)->with('document', $htmlDocument); |
|
|
|
|
|
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Update the specified resource in storage. |
|
65
|
|
|
* |
|
66
|
|
|
* @param \Illuminate\Http\Request $request |
|
67
|
|
|
* @param int $id |
|
68
|
|
|
* @return \Illuminate\Http\Response |
|
69
|
|
|
*/ |
|
70
|
|
|
public function update(Request $request, $id) |
|
71
|
|
|
{ |
|
72
|
|
|
$user = User::findWithPermission($id); |
|
73
|
|
|
|
|
74
|
|
|
$input = $request->only('rules_agreed', 'induction_completed'); |
|
75
|
|
|
|
|
76
|
|
|
$this->inductionValidator->validate($input); |
|
77
|
|
|
|
|
78
|
|
|
$this->userRepository->recordInductionCompleted($id); |
|
79
|
|
|
|
|
80
|
|
|
return \Redirect::route('account.show', [$user->id]); |
|
|
|
|
|
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.