Skip to content

Commit

Permalink
Initial commit to repository
Browse files Browse the repository at this point in the history
  • Loading branch information
¨Goodness committed May 25, 2017
0 parents commit 4f0e2c1
Show file tree
Hide file tree
Showing 10 changed files with 718 additions and 0 deletions.
20 changes: 20 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "goodnesskay/laravel-slack",
"description": "A Laravel Package that makes Invitation to Slack Channels seamless",
"type": "library",
"license": "MIT",
"keywords": ["laravel","packages","slack","Automatic Invite","SLack Api"],
"authors": [
{
"name": "Goodness Toluwanimi Kayode",
"email": "gtkbrain@gmail.com"
}
],
"minimum-stability": "dev",
"require": {},
"autoload": {
"psr-4": {
"GoodnessKay\\LaravelSlack\\": "src/"
}
}
}
21 changes: 21 additions & 0 deletions src/Facade/LaravelSlack.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

/*
* This file is part of the Laravel Slack package.
*
* (c) Gooodness Toluwanimi Kayode <gtkbrain@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace GoodnessKay\LaravelSlack\Facade;
use Illuminate\Support\Facades\Facade;

class LaravelSlack extends Facade
{
protected static function getFacadeAccessor()
{
return 'laravelslack';
}
}
17 changes: 17 additions & 0 deletions src/LaravelSlack.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

/*
* This file is part of the Laravel Slack package.
*
* (c) Gooodness Toluwanimi Kayode <gtkbrain@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace GoodnessKay\LaravelSlack;

class LaravelSlack
{

}
59 changes: 59 additions & 0 deletions src/LaravelSlackController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

/*
* This file is part of the Laravel Slack package.
*
* (c) Gooodness Toluwanimi Kayode <gtkbrain@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace GoodnessKay\LaravelSlack;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use GuzzleHttp\Client;
use Validator;


class LaravelSlackController extends Controller
{
public function __construct()
{
$this->client = new Client();
}

/**
* Shows the landing page of
* Laravel Slack Package
*
*/
public function slackPage()
{
return view('slack.slack');
}

/**
* Get Email, Validate and Send
* Invite to User
*
*/
public function sendSlackInvite(Request $request)
{
$validator= Validator::make($request->all(),[
'email'=>'required|email'
]);

if ($validator->fails())
{
return redirect()->back()->with('error','Sorry! Please enter a valid mail or you have used this mail here');
}else{
$email = $request->input('email');
$this->client->request('POST',
config('LaravelSlack.slack_team_url').'/api/users.admin.invite?t='.time().'&email='.$email.'&token='.config('LaravelSlack.slack_api_token').'&set_active=true&_attempts=1'
);
return redirect()->back()->with('alert','Congratulation! Your Invite has been sent successfully to your mail');
}
}
}
52 changes: 52 additions & 0 deletions src/LaravelSlackServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

/*
* This file is part of the Laravel Slack package.
*
* (c) Gooodness Toluwanimi Kayode <gtkbrain@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace GoodnessKay\LaravelSlack;

use Illuminate\Support\ServiceProvider;

class LaravelSlackServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
$this->publishes([
__DIR__.'/config/LaravelSlack.php' => config_path('LaravelSlack.php'),
], 'config');

$this->publishes([
__DIR__.'/views/slack' => resource_path('views/slack'),
]);

$this->publishes([
__DIR__.'/views/slack/slack-asset' => public_path('/slack-asset'),
], 'public');
}

/**
* Register the application services.
*
* @return void
*/
public function register()
{

$this->loadViewsFrom(__DIR__.'/views/slack','slack');
$this->mergeConfigFrom( __DIR__.'/config/LaravelSlack.php', 'LaravelSlack');
$this->app->singleton(LaravelSlack::class, function ($app) {
return new LaravelSlack(config('laravelslack'));
});
}
}
53 changes: 53 additions & 0 deletions src/config/LaravelSlack.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

/*
* This file is part of the Laravel Slack package.
*
* (c) Gooodness Toluwanimi Kayode <gtkbrain@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

return[

/**
* Gets the name of the slack team
*
*/

'slack_team_name'=> getenv('SLACK_TEAM_NAME'),

/**
* Gets brief description of the team
* i.e What is being done by the team
*
*/

'team_description'=> getenv('TEAM_DESCRIPTION'),

/**
* Gets the slack url of the team
* e.g test-group.slack.com
*
*/

'slack_team_url'=> getenv('SLACK_TEAM_URL'),

/**
* Gets the slack API token of the team
* Get it at:
* https://api.slack.com/custom-integrations/legacy-tokens
*
*/

'slack_api_token'=> getenv('SLACK_API_TOKEN'),

/**
* Gets the email of the team
*
*/

'slack_team_email'=> getenv('SLACK_TEAM_EMAIL'),

];
14 changes: 14 additions & 0 deletions src/views/slack/slack-asset/css/bootstrap.min.css

Large diffs are not rendered by default.

Loading

0 comments on commit 4f0e2c1

Please sign in to comment.