Skip to content

Commit

Permalink
first commit 🔥
Browse files Browse the repository at this point in the history
  • Loading branch information
3x1io committed Sep 4, 2022
0 parents commit ba7f262
Show file tree
Hide file tree
Showing 51 changed files with 2,152 additions and 0 deletions.
Empty file added Config/.gitkeep
Empty file.
51 changes: 51 additions & 0 deletions Config/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

use App\Models\User;

return [
'name' => 'Notifications',

'types' => [
[
"name" => "Alert",
"id" => "alert",
"color" => "#fff",
"icon" => "bx bxs-user"
],
[
"name" => "Info",
"id" => "info",
"color" => "#fff",
"icon" => "bx bxs-user"
],
[
"name" => "Danger",
"id" => "danger",
"color" => "#fff",
"icon" => "bx bxs-user"
],
[
"name" => "Success",
"id" => "success",
"color" => "#fff",
"icon" => "bx bxs-user"
],
[
"name" => "Warring",
"id" => "warring",
"color" => "#fff",
"icon" => "bx bxs-user"
],
],

'provider' => "pusher",

'models' => [
User::class
],

'slack' => [
"hook" => env('SLACK_HOOK', null),
"reporting" => env('SLACK_REPORTING', false),
]
];
Empty file added Console/.gitkeep
Empty file.
71 changes: 71 additions & 0 deletions Console/InstallNotifications.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

namespace Modules\Notifications\Console;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;

class InstallNotifications extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $name = 'notifications:install';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Install notifications permissions';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->info('Install Permissions');
Artisan::call('roles:generate user_notifications');
Artisan::call('roles:generate notifiactions_templates');
Artisan::call('roles:generate notifications_logs');
$this->info('Your Notifications is ready now');

return Command::SUCCESS;
}

/**
* Get the console command arguments.
*
* @return array
*/
protected function getArguments()
{
return [];
}

/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
{
return [];
}
}
Empty file added Database/Migrations/.gitkeep
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('user_notifications', function (Blueprint $table) {
$table->id();

//If Selected Record On the model
$table->string('model_type')->nullable();
$table->unsignedBigInteger('model_id')->nullable();

//Else on public
$table->string('title')->nullable();
$table->string('url')->nullable();
$table->string('icon')->default('bx bx-user')->nullable();
$table->string('description')->nullable();
$table->string('type')->default('info');
$table->string('privacy')->default('public');

//If Created By
$table->unsignedBigInteger('created_by')->nullable();

$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('user_notifications');
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('user_has_notifications', function (Blueprint $table) {
$table->id();

//If Selected Record On the model
$table->string('model_type');
$table->unsignedBigInteger('model_id');

$table->string('provider')->default('pusher')->nullable();
$table->string('provider_token')->nullable();

$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('user_has_notifications');
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('user_read_notifications', function (Blueprint $table) {
$table->id();

//If Selected Record On the model
$table->string('model_type');
$table->unsignedBigInteger('model_id');
$table->unsignedBigInteger('notification_id');

$table->boolean('read')->default(false);
$table->boolean('open')->default(false);

$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('user_read_notifications');
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('user_notifications', function (Blueprint $table) {
$table->foreign('created_by')->references('id')->on('users')->onDelete('cascade');
});

Schema::table('user_read_notifications', function (Blueprint $table) {
$table->foreign('notification_id')->references('id')->on('user_notifications')->onDelete('cascade');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('foreign_notifications');
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('notifiactions_templates', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('key')->unique();
$table->text('body');
$table->string('title')->nullable();
$table->string('url')->nullable();
$table->string('icon')->nullable();
$table->string('type')->default('info')->nullable();
$table->timestamps();
});

Schema::table('user_notifications', function (Blueprint $table) {
if (Schema::hasColumn('notifiactions_templates', 'template_id')) {
$table->unsignedBigInteger('template_id');
}
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('notifiactions_templates');
Schema::table('user_notifications', function (Blueprint $table) {
if (Schema::hasColumn('notifiactions_templates', 'template_id')) {
$table->dropColumn('template_id');
}
});
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (!Schema::hasColumn('user_notifications', 'template_id')) {
Schema::table('user_notifications', function (Blueprint $table) {
$table->unsignedBigInteger('template_id');
});
}
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
if (!Schema::hasColumn('user_notifications', 'template_id')) {
Schema::table('user_notifications', function (Blueprint $table) {
$table->dropColumn('template_id');
});
}
}
};
Loading

0 comments on commit ba7f262

Please sign in to comment.