2017-01-30 20:40:43 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
2016-11-29 18:47:26 +01:00
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
use Laracasts\Presenter\PresentableTrait;
|
|
|
|
|
|
|
|
/**
|
2017-01-30 20:40:43 +01:00
|
|
|
* Class ExpenseCategory.
|
2016-11-29 18:47:26 +01:00
|
|
|
*/
|
|
|
|
class Project extends EntityModel
|
|
|
|
{
|
|
|
|
// Expense Categories
|
|
|
|
use SoftDeletes;
|
|
|
|
use PresentableTrait;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $dates = ['deleted_at'];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $fillable = [
|
|
|
|
'name',
|
2017-10-17 12:57:20 +02:00
|
|
|
'task_rate',
|
2017-12-24 16:13:47 +01:00
|
|
|
'private_notes',
|
|
|
|
'due_date',
|
|
|
|
'budgeted_hours',
|
2018-04-04 21:08:37 +02:00
|
|
|
'custom_value1',
|
|
|
|
'custom_value2',
|
2016-11-29 18:47:26 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
2017-12-24 16:34:17 +01:00
|
|
|
protected $presenter = 'App\Ninja\Presenters\ProjectPresenter';
|
2016-11-29 18:47:26 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function getEntityType()
|
|
|
|
{
|
|
|
|
return ENTITY_PROJECT;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getRoute()
|
|
|
|
{
|
2017-12-24 20:17:21 +01:00
|
|
|
return "/projects/{$this->public_id}";
|
2016-11-29 18:47:26 +01:00
|
|
|
}
|
|
|
|
|
2017-12-24 16:34:17 +01:00
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
|
|
*/
|
|
|
|
public function account()
|
|
|
|
{
|
|
|
|
return $this->belongsTo('App\Models\Account');
|
|
|
|
}
|
|
|
|
|
2016-11-29 18:47:26 +01:00
|
|
|
/**
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function client()
|
|
|
|
{
|
|
|
|
return $this->belongsTo('App\Models\Client')->withTrashed();
|
|
|
|
}
|
2017-11-30 12:46:30 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
|
|
|
*/
|
|
|
|
public function tasks()
|
|
|
|
{
|
|
|
|
return $this->hasMany('App\Models\Task');
|
|
|
|
}
|
2017-12-24 16:34:17 +01:00
|
|
|
|
|
|
|
public function scopeDateRange($query, $startDate, $endDate)
|
|
|
|
{
|
|
|
|
return $query->where(function ($query) use ($startDate, $endDate) {
|
|
|
|
$query->whereBetween('due_date', [$startDate, $endDate]);
|
|
|
|
});
|
|
|
|
}
|
2017-12-26 14:59:37 +01:00
|
|
|
|
|
|
|
public function getDisplayName()
|
|
|
|
{
|
|
|
|
return $this->name;
|
|
|
|
}
|
2016-11-29 18:47:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Project::creating(function ($project) {
|
|
|
|
$project->setNullValues();
|
|
|
|
});
|
|
|
|
|
|
|
|
Project::updating(function ($project) {
|
|
|
|
$project->setNullValues();
|
|
|
|
});
|