43 lines
912 B
PHP
43 lines
912 B
PHP
<?php
|
|
/**
|
|
* Created by Pensare Software.
|
|
* User: Theo Weijmer
|
|
* Date: 21/12/2017
|
|
* Time: 18:05
|
|
*/
|
|
|
|
|
|
class Project extends BaseModel {
|
|
|
|
protected $table = "projects";
|
|
|
|
public function offers()
|
|
{
|
|
return $this->hasMany( 'Offer' );
|
|
}
|
|
|
|
public function projectleader()
|
|
{
|
|
return $this->belongsTo( 'User', 'projectleader_id' );
|
|
}
|
|
|
|
public function customer()
|
|
{
|
|
return $this->belongsTo( 'Customer' );
|
|
}
|
|
|
|
public static function getAllProjects( $archive = 'F' )
|
|
{
|
|
$projects = Project::with( [
|
|
'projectleader' => function ( $q ) {
|
|
$q->selectRaw( "id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" );
|
|
}] )
|
|
->with( 'customer' );
|
|
|
|
if($archive == 'F') $projects = $projects->whereArchive('F');
|
|
|
|
$projects = $projects->get();
|
|
|
|
return $projects;
|
|
}
|
|
} |