@@ 23-62 (lines=40) @@ | ||
20 | use GuzzleHttp\Client; |
|
21 | use Validator; |
|
22 | ||
23 | class LaravelSlackController extends Controller |
|
24 | { |
|
25 | public function __construct() |
|
26 | { |
|
27 | $this->client = new Client(); |
|
28 | } |
|
29 | ||
30 | /** |
|
31 | * Shows the landing page of |
|
32 | * Laravel Slack Package |
|
33 | * |
|
34 | */ |
|
35 | public function slackPage() |
|
36 | { |
|
37 | return view('slack.slack'); |
|
38 | } |
|
39 | ||
40 | /** |
|
41 | * Get Email, Validate and Send |
|
42 | * Invite to User |
|
43 | * |
|
44 | */ |
|
45 | public function sendSlackInvite(Request $request) |
|
46 | { |
|
47 | $validator= Validator::make($request->all(),[ |
|
48 | 'email'=>'required|email' |
|
49 | ]); |
|
50 | ||
51 | if ($validator->fails()) |
|
52 | { |
|
53 | return redirect()->back()->with('error','Sorry! Please enter a valid mail or you have used this mail here'); |
|
54 | }else{ |
|
55 | $email = $request->input('email'); |
|
56 | $this->client->request('POST', |
|
57 | config('LaravelSlack.slack_team_url').'/api/users.admin.invite?t='.time().'&email='.$email.'&token='.config('LaravelSlack.slack_api_token').'&set_active=true&_attempts=1' |
|
58 | ); |
|
59 | return redirect()->back()->with('alert','Congratulation! Your Invite has been sent successfully to your mail'); |
|
60 | } |
|
61 | } |
|
62 | } |
|
63 |
@@ 20-59 (lines=40) @@ | ||
17 | use Validator; |
|
18 | ||
19 | ||
20 | class LaravelSlackController extends Controller |
|
21 | { |
|
22 | public function __construct() |
|
23 | { |
|
24 | $this->client = new Client(); |
|
25 | } |
|
26 | ||
27 | /** |
|
28 | * Shows the landing page of |
|
29 | * Laravel Slack Package |
|
30 | * |
|
31 | */ |
|
32 | public function slackPage() |
|
33 | { |
|
34 | return view('slack.slack'); |
|
35 | } |
|
36 | ||
37 | /** |
|
38 | * Get Email, Validate and Send |
|
39 | * Invite to User |
|
40 | * |
|
41 | */ |
|
42 | public function sendSlackInvite(Request $request) |
|
43 | { |
|
44 | $validator= Validator::make($request->all(),[ |
|
45 | 'email'=>'required|email' |
|
46 | ]); |
|
47 | ||
48 | if ($validator->fails()) |
|
49 | { |
|
50 | return redirect()->back()->with('error','Sorry! Please enter a valid mail or you have used this mail here'); |
|
51 | }else{ |
|
52 | $email = $request->input('email'); |
|
53 | $this->client->request('POST', |
|
54 | config('LaravelSlack.slack_team_url').'/api/users.admin.invite?t='.time().'&email='.$email.'&token='.config('LaravelSlack.slack_api_token').'&set_active=true&_attempts=1' |
|
55 | ); |
|
56 | return redirect()->back()->with('alert','Congratulation! Your Invite has been sent successfully to your mail'); |
|
57 | } |
|
58 | } |
|
59 | } |
|
60 |