1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace DoeSangue\Http\Controllers\Auth\V1; |
4
|
|
|
|
5
|
|
|
use Illuminate\Http\Request; |
6
|
|
|
use DoeSangue\Http\Controllers\Controller; |
7
|
|
|
use DoeSangue\Http\Requests\UserInvitationRequest; |
8
|
|
|
use Hash, DB; |
9
|
|
|
|
10
|
|
|
class InvitationRequestsController extends Controller |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* Create an invite when user requests from API. |
14
|
|
|
* |
15
|
|
|
* @param UserInvitationRequest $request |
16
|
|
|
* @return void |
17
|
|
|
*/ |
18
|
1 |
|
public function createInvitation(UserInvitationRequest $request) |
19
|
|
|
{ |
20
|
|
|
|
21
|
1 |
|
$guestExist = DB::table('invitation_requests') |
22
|
1 |
|
->where('guest_email', $request['guest_email'])->first(); |
23
|
|
|
|
24
|
1 |
|
if (!$guestExist) { |
25
|
|
|
$guest = [ |
26
|
1 |
|
'first_name' => $request->first_name, |
|
|
|
|
27
|
1 |
|
'last_name' => $request->last_name, |
|
|
|
|
28
|
1 |
|
'guest_email' => $request->guest_email, |
|
|
|
|
29
|
1 |
|
'country_id' => $request->country_id, |
|
|
|
|
30
|
1 |
|
'token' => Hash::make(str_random(60)), |
31
|
1 |
|
'created_at' => \Carbon\Carbon::now(), |
32
|
1 |
|
'updated_at' => \Carbon\Carbon::now() |
33
|
|
|
]; |
34
|
|
|
|
35
|
1 |
|
DB::table('invitation_requests')->insert($guest); |
36
|
|
|
|
37
|
|
|
return response()->json([ |
38
|
|
|
'message' => 'Urrah! You have been invited. Check you email for more information.' |
39
|
|
|
], 201); |
40
|
|
|
} else { |
41
|
|
|
return response()->json([ |
42
|
|
|
'message' => 'Oops. Looks like you have been invited already. But don\'t scary, we will send you again!' |
43
|
|
|
], 200); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Check if User was invited before. |
50
|
|
|
* |
51
|
|
|
* @param Request $data |
52
|
|
|
* @return void |
53
|
|
|
*/ |
54
|
|
|
public function checkInvitation(Request $data) |
|
|
|
|
55
|
|
|
{} |
56
|
|
|
} |
57
|
|
|
|
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.