-
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.
Introduce a new Contract MVC for managing Contracts. Modify the element table to meet the updated requirements, ensuring proper data handling and integrity.
Showing
6 changed files
with
109 additions
and
1 deletion.
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\Contract; | ||
|
||
class ContractController implements BaseController | ||
{ | ||
public function get() | ||
{ | ||
$contracts = Contract::findAll(); | ||
View::render([ | ||
"view" => "Contracts", | ||
"title" => "Contracts", | ||
"layout" => "MainLayout", | ||
"data" => ["contracts" => $contracts] | ||
]); | ||
} | ||
|
||
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,34 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use App\Core\BaseModel; | ||
|
||
class Contract extends BaseModel | ||
{ | ||
public $name; | ||
public $start_date; | ||
public $end_date; | ||
public $invoice_proposed; | ||
public $invoice_agreed; | ||
public $invoice_paid; | ||
public $created_at; | ||
|
||
protected static function getTableName() | ||
{ | ||
return 'contracts'; | ||
} | ||
|
||
protected static function mapDataToModel($data) { | ||
$contract = new Contract(); | ||
$contract->id = $data['id']; | ||
$contract->name = $data['name']; | ||
$contract->start_date = $data['start_date']; | ||
$contract->end_date = $data['end_date']; | ||
$contract->invoice_proposed = $data['invoice_proposed']; | ||
$contract->invoice_agreed = $data['invoice_agreed']; | ||
$contract->invoice_paid = $data['invoice_paid']; | ||
$contract->created_at = $data['created_at']; | ||
return $contract; | ||
} | ||
} |
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,30 @@ | ||
<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">Start Date</th> | ||
<th class="px-4 py-2 border-b">End Date</th> | ||
<th class="px-4 py-2 border-b">Invoice proposed</th> | ||
<th class="px-4 py-2 border-b">Invoice agreed</th> | ||
<th class="px-4 py-2 border-b">Invoice paid</th> | ||
<th class="px-4 py-2 border-b">Created at</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<?php foreach ($contracts as $contract): ?> | ||
<tr class="hover:bg-gray-50"> | ||
<td class="px-4 py-2 border-b"><?php echo $contract->getId(); ?></td> | ||
<td class="px-4 py-2 border-b"><?php echo $contract->name; ?></td> | ||
<td class="px-4 py-2 border-b"><?php echo $contract->start_date; ?></td> | ||
<td class="px-4 py-2 border-b"><?php echo $contract->end_date; ?></td> | ||
<td class="px-4 py-2 border-b"><?php echo $contract->invoice_proposed; ?></td> | ||
<td class="px-4 py-2 border-b"><?php echo $contract->invoice_agreed; ?></td> | ||
<td class="px-4 py-2 border-b"><?php echo $contract->invoice_paid; ?></td> | ||
<td class="px-4 py-2 border-b"><?php echo $contract->created_at; ?></td> | ||
</tr> | ||
<?php endforeach; ?> | ||
</tbody> | ||
</table> | ||
</div> |