-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from pashaapsky/dev
Dev
- Loading branch information
Showing
34 changed files
with
66,838 additions
and
27,186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace App\Broadcasting; | ||
|
||
use App\User; | ||
|
||
class AdminChatChannel | ||
{ | ||
/** | ||
* Create a new channel instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Authenticate the user's access to the channel. | ||
* | ||
* @param \App\User $user | ||
* @return array|bool | ||
*/ | ||
public function join(User $user) | ||
{ | ||
return $user->hasRole('admin'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace App\Events; | ||
|
||
use Illuminate\Broadcasting\Channel; | ||
use Illuminate\Broadcasting\InteractsWithSockets; | ||
use Illuminate\Broadcasting\PresenceChannel; | ||
use Illuminate\Broadcasting\PrivateChannel; | ||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast; | ||
use Illuminate\Foundation\Events\Dispatchable; | ||
use Illuminate\Queue\SerializesModels; | ||
|
||
class ChannelEvent implements ShouldBroadcast | ||
{ | ||
use Dispatchable, InteractsWithSockets, SerializesModels; | ||
|
||
public $user; | ||
public $data; | ||
|
||
public function __construct($user, $data) | ||
{ | ||
$this->user = $user; | ||
$this->data = $data; | ||
} | ||
|
||
/** | ||
* Get the channels the event should broadcast on. | ||
* | ||
* @return \Illuminate\Broadcasting\Channel|array | ||
*/ | ||
public function broadcastOn() | ||
{ | ||
return new Channel('test-channel'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace App\Events; | ||
|
||
use Illuminate\Broadcasting\InteractsWithSockets; | ||
use Illuminate\Broadcasting\PrivateChannel; | ||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast; | ||
use Illuminate\Foundation\Events\Dispatchable; | ||
use Illuminate\Queue\SerializesModels; | ||
|
||
class PostUpdatedAdminChat implements ShouldBroadcast | ||
{ | ||
use Dispatchable, InteractsWithSockets, SerializesModels; | ||
|
||
public $post; | ||
public $data; | ||
|
||
public function __construct($post, $data) | ||
{ | ||
$this->post = $post; | ||
$this->data = $data; | ||
} | ||
|
||
public function broadcastOn() | ||
{ | ||
return new PrivateChannel('admin-chat-channel'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
namespace App\Jobs; | ||
|
||
use App\Comment; | ||
use App\Mail\ResultingOrderSend; | ||
use App\News; | ||
use App\Post; | ||
use App\Tag; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Foundation\Bus\Dispatchable; | ||
use Illuminate\Queue\InteractsWithQueue; | ||
use Illuminate\Queue\SerializesModels; | ||
use Illuminate\Support\Facades\Mail; | ||
use Throwable; | ||
|
||
class GenerateResultingOrder implements ShouldQueue | ||
{ | ||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; | ||
|
||
protected $requestData; | ||
protected $user; | ||
|
||
public function __construct($requestData, $user) | ||
{ | ||
$this->requestData = $requestData; | ||
$this->user = $user; | ||
} | ||
|
||
public function handle() | ||
{ | ||
$data = []; | ||
|
||
if ($this->requestData) { | ||
if (array_key_exists ( 'news' , $this->requestData )) { | ||
$data['news'] = 'Новостей: ' . News::count() . PHP_EOL; | ||
} | ||
|
||
if (array_key_exists ( 'posts' , $this->requestData )) { | ||
$data['posts'] = 'Статей: ' . Post::count() . PHP_EOL; | ||
} | ||
|
||
if (array_key_exists ( 'comments' , $this->requestData )) { | ||
$data['comments'] = 'Комментариев: ' . Comment::count() . PHP_EOL; | ||
} | ||
|
||
if (array_key_exists ( 'tags' , $this->requestData )) { | ||
$data['tags'] = 'Тегов: ' . Tag::count() . PHP_EOL; | ||
} | ||
|
||
if (array_key_exists ( 'users' , $this->requestData )) { | ||
$data['users'] = 'Пользователей: ' . News::count() . PHP_EOL; | ||
} | ||
} | ||
|
||
Mail::to($this->user->email)->send( | ||
new ResultingOrderSend($data) | ||
); | ||
} | ||
|
||
public function failed(Throwable $exception) | ||
{ | ||
// Send user notification of failure, etc... | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace App\Mail; | ||
|
||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Mail\Mailable; | ||
use Illuminate\Queue\SerializesModels; | ||
use phpDocumentor\Reflection\Types\This; | ||
|
||
class ResultingOrderSend extends Mailable | ||
{ | ||
use Queueable, SerializesModels; | ||
|
||
protected $data; | ||
|
||
public function __construct($data) | ||
{ | ||
$this->data = $data; | ||
} | ||
|
||
/** | ||
* Build the message. | ||
* | ||
* @return $this | ||
*/ | ||
public function build() | ||
{ | ||
return $this->markdown('mail.order-send', ['data' => $this->data]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.