2020-01-20 11:10:33 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
2024-03-22 05:16:22 +01:00
|
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
2020-01-20 11:10:33 +01:00
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
use Laracasts\Presenter\PresentableTrait;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class Project.
|
2023-03-08 08:33:42 +01:00
|
|
|
*
|
|
|
|
* @property int $id
|
|
|
|
* @property int $user_id
|
|
|
|
* @property int|null $assigned_user_id
|
|
|
|
* @property int $company_id
|
|
|
|
* @property int|null $client_id
|
|
|
|
* @property string $name
|
2023-10-13 12:35:22 +02:00
|
|
|
* @property float $task_rate
|
2023-03-08 08:33:42 +01:00
|
|
|
* @property string|null $due_date
|
|
|
|
* @property string|null $private_notes
|
2023-10-13 12:35:22 +02:00
|
|
|
* @property float $budgeted_hours
|
2023-03-08 08:33:42 +01:00
|
|
|
* @property string|null $custom_value1
|
|
|
|
* @property string|null $custom_value2
|
|
|
|
* @property string|null $custom_value3
|
|
|
|
* @property string|null $custom_value4
|
|
|
|
* @property int|null $created_at
|
|
|
|
* @property int|null $updated_at
|
|
|
|
* @property int|null $deleted_at
|
|
|
|
* @property string|null $public_notes
|
2023-10-13 12:35:22 +02:00
|
|
|
* @property bool $is_deleted
|
2023-03-08 08:33:42 +01:00
|
|
|
* @property string|null $number
|
|
|
|
* @property string $color
|
|
|
|
* @property-read \App\Models\Client|null $client
|
|
|
|
* @property-read \App\Models\Company $company
|
|
|
|
* @property-read int|null $documents_count
|
|
|
|
* @property-read mixed $hashed_id
|
|
|
|
* @property-read Project|null $project
|
|
|
|
* @property-read int|null $tasks_count
|
|
|
|
* @property-read \App\Models\User $user
|
2024-09-02 02:35:20 +02:00
|
|
|
* @property-read \App\Models\User $assigned_user
|
2023-03-08 08:33:42 +01:00
|
|
|
* @property-read \App\Models\Vendor|null $vendor
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel company()
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel exclude($columns)
|
|
|
|
* @method static \Database\Factories\ProjectFactory factory($count = null, $state = [])
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Project filter(\App\Filters\QueryFilters $filters)
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Project newModelQuery()
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Project newQuery()
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Project onlyTrashed()
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Project query()
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel scope()
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Project withTrashed()
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Project withoutTrashed()
|
2023-03-16 05:20:38 +01:00
|
|
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
|
2023-03-24 08:02:34 +01:00
|
|
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Task> $tasks
|
2023-03-08 08:33:42 +01:00
|
|
|
* @mixin \Eloquent
|
2020-01-20 11:10:33 +01:00
|
|
|
*/
|
|
|
|
class Project extends BaseModel
|
|
|
|
{
|
|
|
|
use SoftDeletes;
|
|
|
|
use PresentableTrait;
|
2020-10-08 00:25:39 +02:00
|
|
|
use Filterable;
|
2020-10-28 11:10:49 +01:00
|
|
|
|
2020-01-20 11:10:33 +01:00
|
|
|
protected $fillable = [
|
|
|
|
'name',
|
2020-10-08 00:25:39 +02:00
|
|
|
'client_id',
|
2020-01-20 11:10:33 +01:00
|
|
|
'task_rate',
|
|
|
|
'private_notes',
|
2020-10-08 00:25:39 +02:00
|
|
|
'public_notes',
|
2020-01-20 11:10:33 +01:00
|
|
|
'due_date',
|
|
|
|
'budgeted_hours',
|
|
|
|
'custom_value1',
|
|
|
|
'custom_value2',
|
2020-10-08 00:25:39 +02:00
|
|
|
'custom_value3',
|
|
|
|
'custom_value4',
|
2020-10-29 01:09:51 +01:00
|
|
|
'assigned_user_id',
|
2021-01-05 05:41:43 +01:00
|
|
|
'color',
|
2021-03-20 01:16:29 +01:00
|
|
|
'number',
|
2020-01-21 01:32:34 +01:00
|
|
|
];
|
2020-01-20 11:10:33 +01:00
|
|
|
|
2024-02-18 06:19:09 +01:00
|
|
|
protected $with = [
|
|
|
|
'documents',
|
|
|
|
];
|
|
|
|
|
2020-05-06 13:49:42 +02:00
|
|
|
public function getEntityType()
|
|
|
|
{
|
2020-09-06 11:38:10 +02:00
|
|
|
return self::class;
|
2020-05-06 13:49:42 +02:00
|
|
|
}
|
|
|
|
|
2020-07-23 05:55:11 +02:00
|
|
|
protected $touches = [];
|
2020-07-16 13:01:39 +02:00
|
|
|
|
2023-08-07 00:26:31 +02:00
|
|
|
public function company(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
2020-01-20 11:10:33 +01:00
|
|
|
{
|
|
|
|
return $this->belongsTo(Company::class);
|
|
|
|
}
|
|
|
|
|
2023-08-07 00:26:31 +02:00
|
|
|
public function client(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
2020-01-20 11:10:33 +01:00
|
|
|
{
|
|
|
|
return $this->belongsTo(Client::class)->withTrashed();
|
|
|
|
}
|
|
|
|
|
2023-08-07 00:26:31 +02:00
|
|
|
public function vendor(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
2022-04-28 05:09:17 +02:00
|
|
|
{
|
|
|
|
return $this->belongsTo(Vendor::class)->withTrashed();
|
|
|
|
}
|
|
|
|
|
2023-08-07 00:26:31 +02:00
|
|
|
public function project(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
2022-04-28 05:09:17 +02:00
|
|
|
{
|
2022-06-21 11:57:17 +02:00
|
|
|
return $this->belongsTo(self::class)->withTrashed();
|
2022-04-28 05:09:17 +02:00
|
|
|
}
|
|
|
|
|
2020-10-11 23:34:02 +02:00
|
|
|
public function documents()
|
|
|
|
{
|
|
|
|
return $this->morphMany(Document::class, 'documentable');
|
|
|
|
}
|
|
|
|
|
2023-08-07 00:26:31 +02:00
|
|
|
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
2021-02-16 10:02:33 +01:00
|
|
|
{
|
|
|
|
return $this->belongsTo(User::class)->withTrashed();
|
|
|
|
}
|
2021-02-24 03:12:23 +01:00
|
|
|
|
2024-09-02 02:35:20 +02:00
|
|
|
public function assigned_user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
|
|
{
|
|
|
|
return $this->belongsTo(User::class, 'assigned_user_id', 'id')->withTrashed();
|
|
|
|
}
|
|
|
|
|
2023-08-07 00:26:31 +02:00
|
|
|
public function tasks(): \Illuminate\Database\Eloquent\Relations\HasMany
|
2021-02-24 03:12:23 +01:00
|
|
|
{
|
|
|
|
return $this->hasMany(Task::class);
|
|
|
|
}
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2024-03-22 05:16:22 +01:00
|
|
|
public function expenses(): HasMany
|
|
|
|
{
|
|
|
|
return $this->hasMany(Expense::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function invoices(): HasMany
|
|
|
|
{
|
2024-07-24 04:27:09 +02:00
|
|
|
return $this->hasMany(Invoice::class)->withTrashed();
|
2024-03-22 05:16:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function quotes(): HasMany
|
|
|
|
{
|
|
|
|
return $this->hasMany(Quote::class);
|
|
|
|
}
|
2024-06-14 09:09:44 +02:00
|
|
|
|
2024-03-22 05:16:22 +01:00
|
|
|
|
2022-04-06 02:38:01 +02:00
|
|
|
public function translate_entity()
|
|
|
|
{
|
|
|
|
return ctrans('texts.project');
|
|
|
|
}
|
2020-01-20 11:10:33 +01:00
|
|
|
}
|