users and institutions route, tests fixed
This commit is contained in:
26
backend/database/factories/Lists/UserPositionFactory.php
Normal file
26
backend/database/factories/Lists/UserPositionFactory.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Lists;
|
||||
|
||||
use App\Models\Lists\UserPosition;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<UserPosition>
|
||||
*/
|
||||
class UserPositionFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected $model = UserPosition::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'value' => fake()->unique()->word(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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('user_positions', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('value', 25)->unique();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('user_positions');
|
||||
}
|
||||
};
|
||||
@@ -19,6 +19,7 @@ class DatabaseSeeder extends Seeder
|
||||
UserRoleSeeder::class,
|
||||
SystemUserSeeder::class,
|
||||
InstitutionCategorySeeder::class,
|
||||
UserPositionSeeder::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
29
backend/database/seeders/UserPositionSeeder.php
Normal file
29
backend/database/seeders/UserPositionSeeder.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Lists\UserPosition;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class UserPositionSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$positions = [
|
||||
UserPosition::PROFESSOR,
|
||||
UserPosition::RESEARCHER,
|
||||
UserPosition::PHD,
|
||||
UserPosition::STUDENT,
|
||||
UserPosition::ADMINISTRATIVE,
|
||||
];
|
||||
|
||||
foreach ($positions as $position) {
|
||||
UserPosition::updateOrCreate(
|
||||
['value' => $position]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user