Skip to content

Commit

Permalink
add some mising models, factories, and seeders
Browse files Browse the repository at this point in the history
  • Loading branch information
MuchQuak committed Sep 28, 2024
1 parent bfeed69 commit 9a8c784
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 7 deletions.
41 changes: 41 additions & 0 deletions app/Models/Institution.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Institution extends Model {
use HasFactory;

protected $primaryKey = 'iid';

// TODO (Logan) fix typo in legacy create timestamp
const CREATED_AT = 'IntialTimeStamp';
const UPDATED_AT = 'modifiedTimeStamp';

protected $fillable = [
'institutionID',
'InstitutionCode',
'InstitutionName',
'InstitutionName2',
'Address1',
'Address2',
'City',
'StateProvince',
'PostalCode',
'Country',
'Phone',
'Contact',
'Email',
'Url',
'Notes',
'modifieduid',
'modifiedTimeStamp',
'IntialTimeStamp',
];

public function collections() {
return $this->hasMany(Collections::class, 'collid', 'collid');
}
}
5 changes: 3 additions & 2 deletions app/Models/Occurrence.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -71,4 +72,4 @@ public function annotationInternalColl(){
public function portalPublications(){
return $this->belongsToMany(PortalPublication::class, 'portaloccurrences', 'occid', 'pubid')->withPivot('remoteOccid');;
}
}
}
25 changes: 25 additions & 0 deletions database/factories/CollectionFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Database\Factories;

use App\Models\Collection;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Collection>
*/
class CollectionFactory extends Factory {
protected $model = Collection::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array {
return [
'institutionCode' => null,
'iid' => null,
'collectionName' => fake()->name() . ' Collection',
];
}
}
26 changes: 26 additions & 0 deletions database/factories/InstitutionFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Database\Factories;

use App\Models\Institution;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Institution>
*/
class InstitutionFactory extends Factory {

protected $model = Institution::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array {
return [
'InstitutionCode' => Str::random(4),
'InstitutionName' => fake()->name(),
];
}
}
25 changes: 25 additions & 0 deletions database/factories/OccurrenceFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;
use App\Models\Occurrence;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Occurrence>
*/
class OccurrenceFactory extends Factory {
protected $model = Occurrence::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array {
return [
//This is required and must be passed in
'collid' => null,
'locality' => fake()->country(),
];
}
}
9 changes: 4 additions & 5 deletions database/seeders/OccurrenceSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

0 comments on commit 9a8c784

Please sign in to comment.