Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	routes.php
#	src/Http/Controllers/DeployController.php
#	src/Http/Controllers/Front/Ajax/ClientsController.php
#	src/Http/Controllers/Front/Ajax/SettingsController.php
#	src/Jobs/DeployJob.php
#	src/LaravelDeployServiceProvider.php
  • Loading branch information
kg-bot committed Jun 23, 2018
2 parents da2697c + 68eeba7 commit e52eb76
Show file tree
Hide file tree
Showing 18 changed files with 130 additions and 151 deletions.
18 changes: 8 additions & 10 deletions src/Console/Commands/NewClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
* Created by PhpStorm.
* User: kgbot
* Date: 6/4/18
* Time: 1:29 AM
* Time: 1:29 AM.
*/

namespace KgBot\LaravelDeploy\Console\Commands;


use Illuminate\Console\Command;
use KgBot\LaravelDeploy\Models\Client;

Expand Down Expand Up @@ -45,14 +44,13 @@ public function __construct()
*/
public function handle()
{
$name = $this->argument('name');
$token = $this->argument('token');
$script_source = $this->argument('script_source');
$source = $this->argument('source');

$name = $this->argument( 'name' );
$token = $this->argument( 'token' );
$script_source = $this->argument( 'script_source' );
$source = $this->argument( 'source' );

$client = Client::create( compact( 'name', 'token', 'script_source', 'source' ) );
$client = Client::create(compact('name', 'token', 'script_source', 'source'));

$this->info( 'New client created, token has been encrypted and it is: ' . $token );
$this->info('New client created, token has been encrypted and it is: '.$token);
}
}
}
17 changes: 8 additions & 9 deletions src/Events/LaravelDeployFailed.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
* Created by PhpStorm.
* User: kgbot
* Date: 6/4/18
* Time: 1:18 AM
* Time: 1:18 AM.
*/

namespace KgBot\LaravelDeploy\Events;


use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
use KgBot\LaravelDeploy\Models\Client;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;

class LaravelDeployFailed
{
Expand All @@ -27,9 +26,9 @@ class LaravelDeployFailed
*
* @return void
*/
public function __construct( Client $client, string $message )
public function __construct(Client $client, string $message)
{
$this->client = $client;
$this->client = $client;
$this->message = $message;
}

Expand All @@ -40,6 +39,6 @@ public function __construct( Client $client, string $message )
*/
public function broadcastOn()
{
return new PrivateChannel( config( 'laravel-deploy.events.channel', 'channel-name' ) );
return new PrivateChannel(config('laravel-deploy.events.channel', 'channel-name'));
}
}
}
17 changes: 8 additions & 9 deletions src/Events/LaravelDeployFinished.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
* Created by PhpStorm.
* User: kgbot
* Date: 6/4/18
* Time: 1:18 AM
* Time: 1:18 AM.
*/

namespace KgBot\LaravelDeploy\Events;


use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
use KgBot\LaravelDeploy\Models\Client;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;

class LaravelDeployFinished
{
Expand All @@ -27,9 +26,9 @@ class LaravelDeployFinished
*
* @return void
*/
public function __construct( Client $client, $message )
public function __construct(Client $client, $message)
{
$this->client = $client;
$this->client = $client;
$this->message = $message;
}

Expand All @@ -40,6 +39,6 @@ public function __construct( Client $client, $message )
*/
public function broadcastOn()
{
return new PrivateChannel( config( 'laravel-deploy.events.channel', 'channel-name' ) );
return new PrivateChannel(config('laravel-deploy.events.channel', 'channel-name'));
}
}
}
17 changes: 8 additions & 9 deletions src/Events/LaravelDeployStarted.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
* Created by PhpStorm.
* User: kgbot
* Date: 6/4/18
* Time: 1:18 AM
* Time: 1:18 AM.
*/

namespace KgBot\LaravelDeploy\Events;


use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
use KgBot\LaravelDeploy\Models\Client;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;

class LaravelDeployStarted
{
Expand All @@ -27,9 +26,9 @@ class LaravelDeployStarted
*
* @return void
*/
public function __construct( Client $client, string $command )
public function __construct(Client $client, string $command)
{
$this->client = $client;
$this->client = $client;
$this->command = $command;
}

Expand All @@ -40,6 +39,6 @@ public function __construct( Client $client, string $command )
*/
public function broadcastOn()
{
return new PrivateChannel( config( 'laravel-deploy.events.channel', 'channel-name' ) );
return new PrivateChannel(config('laravel-deploy.events.channel', 'channel-name'));
}
}
}
6 changes: 2 additions & 4 deletions src/Exceptions/InvalidClientException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
* Created by PhpStorm.
* User: kgbot
* Date: 6/4/18
* Time: 12:32 AM
* Time: 12:32 AM.
*/

namespace KgBot\LaravelDeploy\Exceptions;

use Exception;


class InvalidClientException extends Exception
{

}
}
6 changes: 2 additions & 4 deletions src/Exceptions/UnableToReadScriptFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
* Created by PhpStorm.
* User: kgbot
* Date: 6/4/18
* Time: 12:55 AM
* Time: 12:55 AM.
*/

namespace KgBot\LaravelDeploy\Exceptions;

use Exception;


class UnableToReadScriptFile extends Exception
{

}
}
9 changes: 4 additions & 5 deletions src/Http/Controllers/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
* Created by PhpStorm.
* User: kgbot
* Date: 6/4/18
* Time: 12:44 AM
* Time: 12:44 AM.
*/

namespace KgBot\LaravelDeploy\Http\Controllers;


use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Routing\Controller;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

class BaseController extends Controller
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}
}
7 changes: 3 additions & 4 deletions src/Http/Controllers/Front/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Created by PhpStorm.
* User: kgbot
* Date: 6/4/18
* Time: 12:40 AM
* Time: 12:40 AM.
*/

namespace KgBot\LaravelDeploy\Http\Controllers\Front;
Expand All @@ -12,9 +12,8 @@

class DashboardController extends BaseController
{

public function index()
{
return view( 'laravel-deploy::dashboard' );
return view('laravel-deploy::dashboard');
}
}
}
29 changes: 13 additions & 16 deletions src/Http/Middleware/IsValidToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
* Created by PhpStorm.
* User: kgbot
* Date: 6/4/18
* Time: 12:25 AM
* Time: 12:25 AM.
*/

namespace KgBot\LaravelDeploy\Http\Middleware;

use Closure;
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
use KgBot\LaravelDeploy\Exceptions\InvalidClientException;
use KgBot\LaravelDeploy\Models\Client;

use KgBot\LaravelDeploy\Exceptions\InvalidClientException;
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;

class IsValidToken extends Middleware
{
Expand All @@ -24,24 +23,22 @@ class IsValidToken extends Middleware
*
* @return mixed
*/
public function handle( $request, Closure $next )
public function handle($request, Closure $next)
{
$token = $request->get( '_token' );

if ( $token ) {

$client = Client::where( [
$token = $request->get('_token');

[ 'token', $token ],
[ 'active', true ],
] )->first();
if ($token) {
$client = Client::where([

if ( !$client ) {
['token', $token],
['active', true],
])->first();

if (! $client) {
throw new InvalidClientException();
}

return $next( $request );
return $next($request);
}
}
}
}
23 changes: 11 additions & 12 deletions src/Models/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
* Created by PhpStorm.
* User: kgbot
* Date: 6/4/18
* Time: 12:29 AM
* Time: 12:29 AM.
*/

namespace KgBot\LaravelDeploy\Models;


use Illuminate\Database\Eloquent\Model;

class Client extends Model
Expand All @@ -31,29 +30,29 @@ class Client extends Model
'auto_deploy' => 'boolean',
];

public function setTokenAttribute( $value )
public function setTokenAttribute($value)
{
$this->attributes[ 'token' ] = bcrypt( $value );
$this->attributes['token'] = bcrypt($value);
}

public function changeStatus()
{
$this->update( [
$this->update([

'active' => !$this->active,
] );
'active' => ! $this->active,
]);
}

public function changeAutoDeploy()
{
$this->update( [
$this->update([

'auto_deploy' => !$this->auto_deploy,
] );
'auto_deploy' => ! $this->auto_deploy,
]);
}

public function scopeActive()
{
return $this->where( 'active', true );
return $this->where('active', true);
}
}
}
Loading

0 comments on commit e52eb76

Please sign in to comment.