use App\Mail\DeferredDownload;
use App\Models\User;
+use App\Notifications\DownloadReady;
use App\Services\ScormCloud;
use App\Slack\Message;
use App\Slack\Slack;
public function sendNotification($subject, $text, $actions = [])
{
+ if ($this->getUser()->id == 5) {
+ $this->getUser()->notify(new DownloadReady($subject, $text, $actions));
+ return;
+ }
+
if ($this->getUser()->slack) {
if ($this->sendSlack($subject, $text, $actions)) {
return;
--- /dev/null
+<?php
+
+namespace App\Notifications;
+
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Notifications\Messages\MailMessage;
+use Illuminate\Notifications\Notification;
+
+class DownloadReady extends Notification
+{
+ use Queueable;
+
+ protected $subject;
+ protected $text;
+ protected $actions = [];
+
+ /**
+ * Create a new notification instance.
+ *
+ * @return void
+ */
+ public function __construct($subject = '', $text = '', $actions = [])
+ {
+ $this->subject = $subject;
+ $this->text = $text;
+ $this->actions = $actions;
+ }
+
+ /**
+ * Get the notification's delivery channels.
+ *
+ * @param mixed $notifiable
+ * @return array
+ */
+ public function via($notifiable)
+ {
+ if ($notifiable->slack) {
+ return ['database', FluidbookslackChannel::class];
+ } else {
+ return ['database', 'mail'];
+ }
+ }
+
+ /**
+ * Get the mail representation of the notification.
+ *
+ * @param mixed $notifiable
+ * @return \Illuminate\Notifications\Messages\MailMessage
+ */
+ public function toMail($notifiable)
+ {
+ return (new MailMessage)
+ ->line('The introduction to the notification.')
+ ->action('Notification Action', url('/'))
+ ->line('Thank you for using our application!');
+ }
+
+ /**
+ * Get the array representation of the notification.
+ *
+ * @param mixed $notifiable
+ * @return array
+ */
+ public function toArray($notifiable)
+ {
+ return [
+ 'subject' => $this->subject,
+ 'text' => $this->text,
+ 'actions' => $this->actions,
+ ];
+ }
+}
--- /dev/null
+<?php
+
+namespace App\Notifications;
+
+use App\Slack\Slack;
+use Illuminate\Notifications\Notification;
+
+class FluidbookslackChannel
+{
+ /**
+ * Send the given notification.
+ *
+ * @param mixed $notifiable
+ * @param \Illuminate\Notifications\Notification $notification
+ * @return void
+ */
+ public function send($notifiable, Notification $notification)
+ {
+ $message = $notification->toArray($notifiable);
+ Slack::send($notifiable->slack, $message['subject'], $message['text'], $message['actions']);
+ }
+}
class Widgets
{
- public static function fluidbookQuoteWidgets()
+ public static function fluidbookQuoteWidgets($class = '', $wrapper = null)
{
if (can('fluidbook-quote:admin')) {
$nottreated = FluidbookQuote::where('status', '0')->count();
if ($nottreated > 0 && request()->get('status', null) == null) {
Widget::add([
'type' => 'alert',
- 'class' => 'alert alert-dark mb-2',
+ 'class' => 'alert alert-dark mb-2 ' . $class,
'heading' => __('Des demandes de devis n\'ont pas été traitées'),
'content' => __(':awaiting demandes de devis doivent être confiées à un revendeur ou un chef de projet', ['awaiting' => $nottreated]) . '. <p><a class="btn btn-primary" href="' . backpack_url('fluidbook-quote?status=0') . '">' . __('Voir toutes les demandes à traiter') . '</a></p>',
'close_button' => false, // show close button or not
+ 'wrapper' => $wrapper
]);
}
}
}
Widget::add([
'type' => 'alert',
- 'class' => 'alert alert-danger mb-2',
+ 'class' => 'alert alert-danger mb-2 ' . $class,
'heading' => $heading,
'content' => $content . '. <p><a class="btn btn-warning" href="' . backpack_url('fluidbook-quote?status=1') . '">' . __('Voir toutes les demandes en attente') . '</a></p>',
'close_button' => false, // show close button or not
+ 'wrapper' => $wrapper
]);
}
}
- public static function teamWidgets()
+ public static function teamWidgets($wrapper = null, $class = '', $heading = '')
{
- Widget::add([
- 'type' => 'view',
- 'view' => 'team.leave.calendar',
- ]);
+ if (can('team-leave:read')) {
+ Widget::add([
+ 'type' => 'view',
+ 'view' => 'team.leave.calendar',
+ 'wrapper' => $wrapper,
+ 'class' => $class,
+ 'heading' => $heading,
+ ]);
+ }
}
}
--- /dev/null
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+
+class CreateRevisionsTable extends Migration
+{
+ /**
+ * Run the migrations.
+ *
+ * @return void
+ */
+ public function up()
+ {
+ Schema::create('revisions', function ($table) {
+ $table->increments('id');
+ $table->string('revisionable_type');
+ $table->integer('revisionable_id');
+ $table->integer('user_id')->nullable();
+ $table->string('key');
+ $table->text('old_value')->nullable();
+ $table->text('new_value')->nullable();
+ $table->timestamps();
+
+ $table->index(array('revisionable_id', 'revisionable_type'));
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::drop('revisions');
+ }
+}
--- /dev/null
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreatePermissionTables extends Migration
+{
+ /**
+ * Run the migrations.
+ *
+ * @return void
+ */
+ public function up()
+ {
+ $tableNames = config('permission.table_names');
+ $columnNames = config('permission.column_names');
+
+ Schema::create($tableNames['permissions'], function (Blueprint $table) {
+ $table->bigIncrements('id');
+ $table->string('name');
+ $table->string('guard_name');
+ $table->timestamps();
+ });
+
+ Schema::create($tableNames['roles'], function (Blueprint $table) {
+ $table->bigIncrements('id');
+ $table->string('name');
+ $table->string('guard_name');
+ $table->timestamps();
+ });
+
+ Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames) {
+ $table->unsignedBigInteger('permission_id');
+
+ $table->string('model_type');
+ $table->unsignedBigInteger($columnNames['model_morph_key']);
+ $table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index');
+
+ $table->foreign('permission_id')
+ ->references('id')
+ ->on($tableNames['permissions'])
+ ->onDelete('cascade');
+
+ $table->primary(['permission_id', $columnNames['model_morph_key'], 'model_type'],
+ 'model_has_permissions_permission_model_type_primary');
+ });
+
+ Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames) {
+ $table->unsignedBigInteger('role_id');
+
+ $table->string('model_type');
+ $table->unsignedBigInteger($columnNames['model_morph_key']);
+ $table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index');
+
+ $table->foreign('role_id')
+ ->references('id')
+ ->on($tableNames['roles'])
+ ->onDelete('cascade');
+
+ $table->primary(['role_id', $columnNames['model_morph_key'], 'model_type'],
+ 'model_has_roles_role_model_type_primary');
+ });
+
+ Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames) {
+ $table->unsignedBigInteger('permission_id');
+ $table->unsignedBigInteger('role_id');
+
+ $table->foreign('permission_id')
+ ->references('id')
+ ->on($tableNames['permissions'])
+ ->onDelete('cascade');
+
+ $table->foreign('role_id')
+ ->references('id')
+ ->on($tableNames['roles'])
+ ->onDelete('cascade');
+
+ $table->primary(['permission_id', 'role_id'], 'role_has_permissions_permission_id_role_id_primary');
+ });
+
+ app('cache')
+ ->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null)
+ ->forget(config('permission.cache.key'));
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ $tableNames = config('permission.table_names');
+
+ Schema::drop($tableNames['role_has_permissions']);
+ Schema::drop($tableNames['model_has_roles']);
+ Schema::drop($tableNames['model_has_permissions']);
+ Schema::drop($tableNames['roles']);
+ Schema::drop($tableNames['permissions']);
+ }
+}
--- /dev/null
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateMediaTable extends Migration
+{
+ /**
+ * Run the migrations.
+ */
+ public function up()
+ {
+ Schema::create('media', function (Blueprint $table) {
+ $table->bigIncrements('id');
+ $table->morphs('model');
+ $table->string('collection_name');
+ $table->string('name');
+ $table->string('file_name');
+ $table->string('mime_type')->nullable();
+ $table->string('disk');
+ $table->unsignedBigInteger('size');
+ $table->json('manipulations');
+ $table->json('custom_properties');
+ $table->json('responsive_images');
+ $table->unsignedInteger('order_column')->nullable();
+ $table->nullableTimestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down()
+ {
+ Schema::dropIfExists('media');
+ }
+}
--- /dev/null
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateJobsTable extends Migration
+{
+ /**
+ * Run the migrations.
+ *
+ * @return void
+ */
+ public function up()
+ {
+ Schema::create('jobs', function (Blueprint $table) {
+ $table->bigIncrements('id');
+ $table->string('queue')->index();
+ $table->longText('payload');
+ $table->unsignedTinyInteger('attempts');
+ $table->unsignedInteger('reserved_at')->nullable();
+ $table->unsignedInteger('available_at');
+ $table->unsignedInteger('created_at');
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('jobs');
+ }
+}
--- /dev/null
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateNotificationsTable extends Migration
+{
+ /**
+ * Run the migrations.
+ *
+ * @return void
+ */
+ public function up()
+ {
+ Schema::create('notifications', function (Blueprint $table) {
+ $table->uuid('id')->primary();
+ $table->string('type');
+ $table->morphs('notifiable');
+ $table->text('data');
+ $table->timestamp('read_at')->nullable();
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('notifications');
+ }
+}
<style>
#leave-calendar {
max-width: 600px;
- margin: 40px auto;
+ margin: 40px 0;
+ }
+ #leave-calendar.dashboard{
+ max-width: none;
+ }
+
+ .leave-calendar-wrapper{
+ background-color: #ffffff;
+ padding: 20px;
+ border-radius: 2px;
}
</style>
<link href='https://cdn.jsdelivr.net/npm/fullcalendar@5.11.3/main.min.css' rel='stylesheet'/>
format: 'ics'
}
],
- locale: 'fr',
+ locale: '{{backpack_user()->locale}}',
});
calendar.render();
});
</script>
-<div id='leave-calendar'></div>
+@if($widget['heading'])
+ <h4 class="leave-calendar">{{$widget['heading']}}</h4>
+@endif
+<div id='leave-calendar' class="{{$widget['class']}}"></div>
+
@php
\App\Widgets::fluidbookQuoteWidgets();
- $widgets['before_content'][] = [
- 'type' => 'jumbotron',
- 'heading' => trans('backpack::base.welcome'),
- 'content' => trans('backpack::base.use_sidebar'),
- 'button_link' => backpack_url('logout'),
- 'button_text' => trans('backpack::base.logout'),
- ];
-@endphp
-@section('content')
- {{-- <div class="row">--}}
- {{-- <div class="col-md-12">--}}
- {{-- <div class="box">--}}
- {{-- <div class="box-header with-border">--}}
- {{-- <div class="box-title">{{ trans('backpack::base.login_status') }}</div>--}}
- {{-- </div>--}}
+ \App\Widgets::teamWidgets(['class' => 'col-sm-4 leave-calendar-wrapper'],'dashboard',__('Planning de l\'équipe'));
- {{-- <div class="box-body">{{ trans('backpack::base.logged_in') }}</div>--}}
- {{-- <div class="box-body">--}}
- {{-- Permissions: {{ backpack_user()->getAllPermissions()}}</div>--}}
- {{-- <div class="box-body">Roles: {{ backpack_user()->getRoleNames()->implode('name',', ') }}</div>--}}
- {{-- </div>--}}
- {{-- </div>--}}
- {{-- </div>--}}
-@endsection
+@endphp
<li class="nav-item"><a class="nav-link" href="{{ backpack_url('dashboard') }}"><i
class='nav-icon la la-dashboard'></i>{{ trans('backpack::base.dashboard') }}
</a></li>
+<li class="nav-item"><a class="nav-link" href="{{ backpack_url('tasks') }}"><i
+ class='nav-icon la la-bell'></i>{{ __('Tâches et notifications') }}
+ </a></li>
@can('files:read')
<li class="nav-item"><a class="nav-link" href="{{ backpack_url('file') }}"><i
<li class="nav-item"><a class="nav-link" href="{{ backpack_url('fluidbook-collection') }}"><i
class="la la-university nav-icon"></i> {{__('Collections')}}</a></li>
@endcan
- @can('fluibook-translate:write')
+ @can('fluidbook-translate:write')
<li class="nav-item"><a class="nav-link"
href='{{ backpack_url('fluidbook-translate/1/edit/?locale=en') }}'><i
class='la la-language nav-icon'></i>