mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
98 lines
1.8 KiB
PHP
98 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Laracasts\Presenter\PresentableTrait;
|
|
|
|
/**
|
|
* Class ExpenseCategory.
|
|
*/
|
|
class Project extends EntityModel
|
|
{
|
|
// Expense Categories
|
|
use SoftDeletes;
|
|
use PresentableTrait;
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $dates = ['deleted_at'];
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $fillable = [
|
|
'name',
|
|
'task_rate',
|
|
'private_notes',
|
|
'due_date',
|
|
'budgeted_hours',
|
|
];
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected $presenter = 'App\Ninja\Presenters\ProjectPresenter';
|
|
|
|
/**
|
|
* @return mixed
|
|
*/
|
|
public function getEntityType()
|
|
{
|
|
return ENTITY_PROJECT;
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getRoute()
|
|
{
|
|
return "/projects/{$this->public_id}";
|
|
}
|
|
|
|
/**
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
*/
|
|
public function account()
|
|
{
|
|
return $this->belongsTo('App\Models\Account');
|
|
}
|
|
|
|
/**
|
|
* @return mixed
|
|
*/
|
|
public function client()
|
|
{
|
|
return $this->belongsTo('App\Models\Client')->withTrashed();
|
|
}
|
|
|
|
/**
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
|
*/
|
|
public function tasks()
|
|
{
|
|
return $this->hasMany('App\Models\Task');
|
|
}
|
|
|
|
public function scopeDateRange($query, $startDate, $endDate)
|
|
{
|
|
return $query->where(function ($query) use ($startDate, $endDate) {
|
|
$query->whereBetween('due_date', [$startDate, $endDate]);
|
|
});
|
|
}
|
|
|
|
public function getDisplayName()
|
|
{
|
|
return $this->name;
|
|
}
|
|
}
|
|
|
|
Project::creating(function ($project) {
|
|
$project->setNullValues();
|
|
});
|
|
|
|
Project::updating(function ($project) {
|
|
$project->setNullValues();
|
|
});
|