Conversie codeigniter 4
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 23/01/2018
|
||||
* Time: 11:37
|
||||
*/
|
||||
|
||||
class Projectcost extends BaseModel {
|
||||
|
||||
public function project()
|
||||
{
|
||||
return $this->belongsTo( 'Project' );
|
||||
}
|
||||
|
||||
public function external()
|
||||
{
|
||||
return $this->belongsTo( 'External' );
|
||||
}
|
||||
|
||||
public static function saveProjectcost( $projectID, $project )
|
||||
{
|
||||
$project = (array) $project;
|
||||
|
||||
if ( $projectID == 0 )
|
||||
{
|
||||
$project = Self::create( $project );
|
||||
$projectID = $project['id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
Self::whereId( $projectID )->update( $project );
|
||||
}
|
||||
|
||||
return $projectID;
|
||||
}
|
||||
|
||||
public static function getCostsPerPerProject( $projectID )
|
||||
{
|
||||
$projectCosts = Projectcost::selectraw( 'ROUND(COALESCE(SUM(costs), 0), 0) AS costs')
|
||||
->whereProjectId($projectID)
|
||||
->first();
|
||||
|
||||
return $projectCosts->costs;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user