Changes
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\PostStatus;
|
||||
use App\Models\Category;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
@@ -33,12 +35,13 @@ class PostFactory extends Factory
|
||||
],
|
||||
];
|
||||
}, range(1, $this->faker->numberBetween(1, 5)));
|
||||
$status = $this->faker->randomElement(['verification', 'published', 'rejected']);
|
||||
$status = $this->faker->randomElement([PostStatus::VERIFICATION, PostStatus::PUBLISHED, PostStatus::REJECTED]);
|
||||
$authorsCount = $this->faker->numberBetween(1, 5);
|
||||
$authors = array_fill(0, $authorsCount, $this->faker->name);
|
||||
$imagesCount = $this->faker->numberBetween(1, 5);
|
||||
$images = array_fill(0, $imagesCount, $this->faker->uuid . '.jpg');
|
||||
$category_id = Category::inRandomOrder()->first();
|
||||
$user_id = User::inRandomOrder()->first();
|
||||
$search_data = $this->faker->words(10, true);
|
||||
$reading_time = $this->faker->numberBetween(5, 30);
|
||||
|
||||
@@ -46,6 +49,7 @@ class PostFactory extends Factory
|
||||
return [
|
||||
'title' => $title,
|
||||
'slug' => $slug,
|
||||
'preview_text' => $this->faker->paragraph,
|
||||
'content' => $content,
|
||||
'status' => $status,
|
||||
'authors' => $authors,
|
||||
@@ -53,6 +57,8 @@ class PostFactory extends Factory
|
||||
'search_data' => $search_data,
|
||||
'reading_time' => $reading_time,
|
||||
'category_id' => $category_id,
|
||||
'user_id' => $user_id,
|
||||
'publish_at' => ($status == PostStatus::PUBLISHED) ? now() : null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
];
|
||||
|
||||
+29
-30
@@ -3,20 +3,19 @@
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Spatie\Permission\PermissionRegistrar;
|
||||
|
||||
class CreatePermissionTables extends Migration
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
public function up(): void
|
||||
{
|
||||
$teams = config('permission.teams');
|
||||
$tableNames = config('permission.table_names');
|
||||
$columnNames = config('permission.column_names');
|
||||
$teams = config('permission.teams');
|
||||
$pivotRole = $columnNames['role_pivot_key'] ?? 'role_id';
|
||||
$pivotPermission = $columnNames['permission_pivot_key'] ?? 'permission_id';
|
||||
|
||||
if (empty($tableNames)) {
|
||||
throw new \Exception('Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||
@@ -26,22 +25,24 @@ class CreatePermissionTables extends Migration
|
||||
}
|
||||
|
||||
Schema::create($tableNames['permissions'], function (Blueprint $table) {
|
||||
//$table->engine('InnoDB');
|
||||
$table->bigIncrements('id'); // permission id
|
||||
$table->string('name'); // For MySQL 8.0 use string('name', 125);
|
||||
$table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125);
|
||||
$table->string('name'); // For MyISAM use string('name', 225); // (or 166 for InnoDB with Redundant/Compact row format)
|
||||
$table->string('guard_name'); // For MyISAM use string('guard_name', 25);
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['name', 'guard_name']);
|
||||
});
|
||||
|
||||
Schema::create($tableNames['roles'], function (Blueprint $table) use ($teams, $columnNames) {
|
||||
//$table->engine('InnoDB');
|
||||
$table->bigIncrements('id'); // role id
|
||||
if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable();
|
||||
$table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index');
|
||||
}
|
||||
$table->string('name'); // For MySQL 8.0 use string('name', 125);
|
||||
$table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125);
|
||||
$table->string('name'); // For MyISAM use string('name', 225); // (or 166 for InnoDB with Redundant/Compact row format)
|
||||
$table->string('guard_name'); // For MyISAM use string('guard_name', 25);
|
||||
$table->timestamps();
|
||||
if ($teams || config('permission.testing')) {
|
||||
$table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']);
|
||||
@@ -50,14 +51,14 @@ class CreatePermissionTables extends Migration
|
||||
}
|
||||
});
|
||||
|
||||
Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames, $teams) {
|
||||
$table->unsignedBigInteger(PermissionRegistrar::$pivotPermission);
|
||||
Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames, $pivotPermission, $teams) {
|
||||
$table->unsignedBigInteger($pivotPermission);
|
||||
|
||||
$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(PermissionRegistrar::$pivotPermission)
|
||||
$table->foreign($pivotPermission)
|
||||
->references('id') // permission id
|
||||
->on($tableNames['permissions'])
|
||||
->onDelete('cascade');
|
||||
@@ -65,23 +66,23 @@ class CreatePermissionTables extends Migration
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key']);
|
||||
$table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index');
|
||||
|
||||
$table->primary([$columnNames['team_foreign_key'], PermissionRegistrar::$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
||||
$table->primary([$columnNames['team_foreign_key'], $pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_permissions_permission_model_type_primary');
|
||||
} else {
|
||||
$table->primary([PermissionRegistrar::$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
||||
$table->primary([$pivotPermission, $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, $teams) {
|
||||
$table->unsignedBigInteger(PermissionRegistrar::$pivotRole);
|
||||
Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames, $pivotRole, $teams) {
|
||||
$table->unsignedBigInteger($pivotRole);
|
||||
|
||||
$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(PermissionRegistrar::$pivotRole)
|
||||
$table->foreign($pivotRole)
|
||||
->references('id') // role id
|
||||
->on($tableNames['roles'])
|
||||
->onDelete('cascade');
|
||||
@@ -89,29 +90,29 @@ class CreatePermissionTables extends Migration
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key']);
|
||||
$table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index');
|
||||
|
||||
$table->primary([$columnNames['team_foreign_key'], PermissionRegistrar::$pivotRole, $columnNames['model_morph_key'], 'model_type'],
|
||||
$table->primary([$columnNames['team_foreign_key'], $pivotRole, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_roles_role_model_type_primary');
|
||||
} else {
|
||||
$table->primary([PermissionRegistrar::$pivotRole, $columnNames['model_morph_key'], 'model_type'],
|
||||
$table->primary([$pivotRole, $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(PermissionRegistrar::$pivotPermission);
|
||||
$table->unsignedBigInteger(PermissionRegistrar::$pivotRole);
|
||||
Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames, $pivotRole, $pivotPermission) {
|
||||
$table->unsignedBigInteger($pivotPermission);
|
||||
$table->unsignedBigInteger($pivotRole);
|
||||
|
||||
$table->foreign(PermissionRegistrar::$pivotPermission)
|
||||
$table->foreign($pivotPermission)
|
||||
->references('id') // permission id
|
||||
->on($tableNames['permissions'])
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->foreign(PermissionRegistrar::$pivotRole)
|
||||
$table->foreign($pivotRole)
|
||||
->references('id') // role id
|
||||
->on($tableNames['roles'])
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->primary([PermissionRegistrar::$pivotPermission, PermissionRegistrar::$pivotRole], 'role_has_permissions_permission_id_role_id_primary');
|
||||
$table->primary([$pivotPermission, $pivotRole], 'role_has_permissions_permission_id_role_id_primary');
|
||||
});
|
||||
|
||||
app('cache')
|
||||
@@ -121,10 +122,8 @@ class CreatePermissionTables extends Migration
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
public function down(): void
|
||||
{
|
||||
$tableNames = config('permission.table_names');
|
||||
|
||||
@@ -138,4 +137,4 @@ class CreatePermissionTables extends Migration
|
||||
Schema::drop($tableNames['roles']);
|
||||
Schema::drop($tableNames['permissions']);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -15,15 +15,19 @@ return new class extends Migration
|
||||
$table->id();
|
||||
$table->string('title');
|
||||
$table->string('slug')->unique();
|
||||
$table->text('preview_text')->nullable();
|
||||
$table->text('content');
|
||||
$table->string('status');
|
||||
$table->text('authors');
|
||||
$table->text('images')->nullable();
|
||||
$table->unsignedBigInteger('category_id')->nullable();
|
||||
$table->foreign('category_id')->references('id')->on('categories');
|
||||
$table->string('preview')->nullable();
|
||||
$table->text('search_data')->nullable();
|
||||
$table->text('reading_time')->nullable();
|
||||
$table->unsignedBigInteger('category_id')->nullable();
|
||||
$table->foreign('category_id')->references('id')->on('categories');
|
||||
$table->unsignedBigInteger('user_id')->nullable();
|
||||
$table->foreign('user_id')->references('id')->on('users')->cascadeOnUpdate()->nullOnDelete();;
|
||||
$table->dateTime('publish_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -13,10 +13,11 @@ return new class extends Migration
|
||||
{
|
||||
Schema::create('schedules', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('title');
|
||||
$table->text('days');
|
||||
$table->string('type');
|
||||
// $table->string('title');
|
||||
$table->boolean('is_zaoch');
|
||||
$table->text('file');
|
||||
// $table->text('days');
|
||||
// $table->string('type');
|
||||
$table->unsignedBigInteger('educational_group_id');
|
||||
$table->foreign('educational_group_id')->references('id')->on('educational_groups')->onDelete('cascade');
|
||||
$table->timestamps();
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('invitations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('email');
|
||||
$table->unsignedBigInteger('user_id')->nullable();
|
||||
$table->foreign('user_id')->references('id')->on('users');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('invitations');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('accepted_invitations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('sender_id')->constrained('users')->onDelete('cascade');
|
||||
$table->foreignId('receiver_id')->constrained('users')->onDelete('cascade');
|
||||
$table->integer('post_limit');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('accepted_invitations');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('seos', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('title')->nullable();
|
||||
$table->text('description')->nullable();
|
||||
$table->string('image')->nullable();
|
||||
$table->morphs('seoable');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('seos');
|
||||
}
|
||||
};
|
||||
@@ -28,7 +28,7 @@ class DatabaseSeeder extends Seeder
|
||||
User::create([
|
||||
'name' => 'Failj',
|
||||
'email' => 'Failj@bk.ru',
|
||||
'password' => Hash::make('2288'),
|
||||
'password' => "$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi",
|
||||
]);
|
||||
User::factory()->count(50)->has(UserDetail::factory())->create();
|
||||
EventCategory::factory()->count(10)->create();
|
||||
|
||||
Reference in New Issue
Block a user