-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
585 add functional areas to mrf (#599)
* initial backend code complete * imporve validation before manuscript can be submitted * initial front-end progress * refactor to use defineModel * frontend functional area
- Loading branch information
1 parent
adbcab9
commit 6eb893a
Showing
25 changed files
with
2,400 additions
and
2,537 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Http\Resources\FunctionalAreaResource; | ||
use App\Models\FunctionalArea; | ||
use Illuminate\Http\Resources\Json\ResourceCollection; | ||
|
||
class FunctionalAreaController extends Controller | ||
{ | ||
/** | ||
* Display a listing of the resource. | ||
*/ | ||
public function index(): ResourceCollection | ||
{ | ||
return FunctionalAreaResource::collection(FunctionalArea::all()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace App\Http\Resources; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Http\Resources\Json\JsonResource; | ||
|
||
class FunctionalAreaResource extends JsonResource | ||
{ | ||
/** | ||
* Transform the resource into an array. | ||
* | ||
* @return array<string, mixed> | ||
*/ | ||
public function toArray(Request $request): array | ||
{ | ||
return [ | ||
'data' => [ | ||
'id' => $this->id, | ||
'name_en' => $this->name_en, | ||
'name_fr' => $this->name_fr, | ||
], | ||
'can' => [ | ||
'update' => false, | ||
'delete' => false, | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\Relations\HasMany; | ||
|
||
class FunctionalArea extends Model | ||
{ | ||
use HasFactory; | ||
|
||
public function manuscriptRecords(): HasMany | ||
{ | ||
return $this->hasMany('App\Models\ManuscriptRecord'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Database\Factories; | ||
|
||
use Illuminate\Database\Eloquent\Factories\Factory; | ||
|
||
/** | ||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\FunctionalArea> | ||
*/ | ||
class FunctionalAreaFactory extends Factory | ||
{ | ||
/** | ||
* Define the model's default state. | ||
* | ||
* @return array<string, mixed> | ||
*/ | ||
public function definition(): array | ||
{ | ||
return [ | ||
'name_en' => $this->faker->word, | ||
'name_fr' => $this->faker->word, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
database/migrations/2024_04_24_133453_create_functional_areas_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?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('functional_areas', function (Blueprint $table) { | ||
$table->id(); | ||
$table->timestamps(); | ||
$table->string('name_en'); | ||
$table->string('name_fr'); | ||
}); | ||
|
||
// seed the table | ||
Artisan::call('db:seed', ['--class' => 'FunctionalAreaSeeder']); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::dropIfExists('functional_areas'); | ||
} | ||
}; |
18 changes: 18 additions & 0 deletions
18
database/migrations/2024_04_24_170533_add_functional_area_to_manuscript_records_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?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::table('manuscript_records', function (Blueprint $table) { | ||
$table->foreignId('functional_area_id')->nullable()->constrained(); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace Database\Seeders; | ||
|
||
use Illuminate\Database\Seeder; | ||
|
||
class FunctionalAreaSeeder extends Seeder | ||
{ | ||
/** | ||
* Run the database seeds. | ||
*/ | ||
public function run(): void | ||
{ | ||
/** | ||
* Functional Areas | ||
* | ||
* Fisheries Science | ||
* Aquatic Ecosystem Science | ||
* Aquatic Animal Health | ||
* Biotechnology and Genomics | ||
* Aquaculture Science | ||
* Oceans and Climate Change Science | ||
* Hydrographic Services, Data and Science | ||
* Aquatic invasive species | ||
* | ||
*/ | ||
$functionalAreas = [ | ||
['name_en' => 'Fisheries Science', 'name_fr' => 'Sciences halieutiques'], | ||
['name_en' => 'Aquatic Ecosystem Science', 'name_fr' => 'Science écosystèmes aquatiques'], | ||
['name_en' => 'Aquatic Animal Health', 'name_fr' => 'Santé animaux aquatiques'], | ||
['name_en' => 'Biotechnology and Genomics', 'name_fr' => 'Biotechnologie et génomique'], | ||
['name_en' => 'Aquaculture Science', 'name_fr' => 'Science de l\'aquaculture'], | ||
['name_en' => 'Oceans and Climate Change Science', 'name_fr' => 'Science des océans & changements climatiques'], | ||
['name_en' => 'Hydrographic Services, Data and Science', 'name_fr' => 'Services hydrographiques, données et science'], | ||
['name_en' => 'Aquatic invasive species', 'name_fr' => 'Espèces aquatiques envahissantes'], | ||
['name_en' => 'Species at Risk', 'name_fr' => 'Espèces en péril'] | ||
]; | ||
|
||
foreach ($functionalAreas as $functionalArea) { | ||
\App\Models\FunctionalArea::create($functionalArea); | ||
} | ||
} | ||
} |
Oops, something went wrong.