-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pruning-type): add PruningType (#66)
Introduce a new PruningType MVC for managing pruning types. Create the pruning_types table to meet the requirements, ensuring proper data handling and integrity.
- Loading branch information
Showing
5 changed files
with
87 additions
and
2 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
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,25 @@ | ||
<?php | ||
|
||
namespace App\Controllers; | ||
|
||
use App\Core\BaseController; | ||
use App\Core\View; | ||
use App\Models\PruningType; | ||
|
||
class PruningTypeController implements BaseController | ||
{ | ||
public function get() | ||
{ | ||
$pruning_types = PruningType::findAll(); | ||
View::render([ | ||
"view" => "PruningType", | ||
"title" => "Pruning Types", | ||
"layout" => "MainLayout", | ||
"data" => ["pruning_types" => $pruning_types] | ||
]); | ||
} | ||
|
||
public function post() {} | ||
public function put() {} | ||
public function delete() {} | ||
} |
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,26 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use App\Core\BaseModel; | ||
use App\Core\Database; | ||
|
||
class PruningType extends BaseModel | ||
{ | ||
public string $name; | ||
public ?string $description; | ||
|
||
protected static function getTableName() | ||
{ | ||
return 'pruning_types'; | ||
} | ||
|
||
protected static function mapDataToModel($data) | ||
{ | ||
$pruning_type = new PruningType(); | ||
$pruning_type->id = $data['id']; | ||
$pruning_type->name = $data['name']; | ||
$pruning_type->description = $data['description']; | ||
return $pruning_type; | ||
} | ||
} |
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,21 @@ | ||
<div class="overflow-x-auto"> | ||
<table class="min-w-full bg-white border border-gray-300 rounded-lg shadow-md"> | ||
<thead> | ||
<tr class="bg-gray-100 text-left"> | ||
<th class="px-4 py-2 border-b">ID</th> | ||
<th class="px-4 py-2 border-b">Name</th> | ||
<th class="px-4 py-2 border-b">Description</th> | ||
|
||
</tr> | ||
</thead> | ||
<tbody> | ||
<?php foreach ($pruning_types as $pruning_type): ?> | ||
<tr class="hover:bg-gray-50"> | ||
<td class="px-4 py-2 border-b"><?php echo $pruning_type->getId(); ?></td> | ||
<td class="px-4 py-2 border-b"><?php echo $pruning_type->name; ?></td> | ||
<td class="px-4 py-2 border-b"><?php echo $pruning_type->description; ?></td> | ||
</tr> | ||
<?php endforeach; ?> | ||
</tbody> | ||
</table> | ||
</div> |