diff --git a/app/Models/Institution.php b/app/Models/Institution.php new file mode 100644 index 0000000..afd5738 --- /dev/null +++ b/app/Models/Institution.php @@ -0,0 +1,41 @@ +hasMany(Collections::class, 'collid', 'collid'); + } +} diff --git a/app/Models/Occurrence.php b/app/Models/Occurrence.php index ced0293..ce0e801 100644 --- a/app/Models/Occurrence.php +++ b/app/Models/Occurrence.php @@ -2,9 +2,10 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Factories\HasFactory; class Occurrence extends Model{ - + use HasFactory; protected $table = 'omoccurrences'; protected $primaryKey = 'occid'; public $timestamps = false; @@ -71,4 +72,4 @@ public function annotationInternalColl(){ public function portalPublications(){ return $this->belongsToMany(PortalPublication::class, 'portaloccurrences', 'occid', 'pubid')->withPivot('remoteOccid');; } -} \ No newline at end of file +} diff --git a/database/factories/CollectionFactory.php b/database/factories/CollectionFactory.php new file mode 100644 index 0000000..89d7b09 --- /dev/null +++ b/database/factories/CollectionFactory.php @@ -0,0 +1,25 @@ + + */ +class CollectionFactory extends Factory { + protected $model = Collection::class; + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array { + return [ + 'institutionCode' => null, + 'iid' => null, + 'collectionName' => fake()->name() . ' Collection', + ]; + } +} diff --git a/database/factories/InstitutionFactory.php b/database/factories/InstitutionFactory.php new file mode 100644 index 0000000..9986505 --- /dev/null +++ b/database/factories/InstitutionFactory.php @@ -0,0 +1,26 @@ + + */ +class InstitutionFactory extends Factory { + + protected $model = Institution::class; + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array { + return [ + 'InstitutionCode' => Str::random(4), + 'InstitutionName' => fake()->name(), + ]; + } +} diff --git a/database/factories/OccurrenceFactory.php b/database/factories/OccurrenceFactory.php new file mode 100644 index 0000000..c2da1e8 --- /dev/null +++ b/database/factories/OccurrenceFactory.php @@ -0,0 +1,25 @@ + + */ +class OccurrenceFactory extends Factory { + protected $model = Occurrence::class; + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array { + return [ + //This is required and must be passed in + 'collid' => null, + 'locality' => fake()->country(), + ]; + } +} diff --git a/database/seeders/OccurrenceSeeder.php b/database/seeders/OccurrenceSeeder.php index df843f5..805f47f 100644 --- a/database/seeders/OccurrenceSeeder.php +++ b/database/seeders/OccurrenceSeeder.php @@ -3,15 +3,14 @@ namespace Database\Seeders; use Illuminate\Database\Console\Seeds\WithoutModelEvents; +use App\Models\Occurrence; use Illuminate\Database\Seeder; -class OccurrenceSeeder extends Seeder -{ +class OccurrenceSeeder extends Seeder { /** * Run the database seeds. */ - public function run(): void - { - // + public function run(): void { + Occurrence::factory()->create(); } }