55 lines
1.2 KiB
PHP
55 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use DateTimeInterface;
|
|
|
|
class ClientProjectActivities extends Model
|
|
{
|
|
protected $fillable = [
|
|
'client_id',
|
|
'activity_type',
|
|
'task_description',
|
|
'estimated_completed_at',
|
|
'completed_at',
|
|
'amount',
|
|
'notification_status',
|
|
'user_id',
|
|
];
|
|
|
|
protected $casts = [
|
|
'estimated_completed_at' => 'datetime',
|
|
'completed_at' => 'datetime',
|
|
];
|
|
|
|
protected $appends = ['activity_no'];
|
|
|
|
protected function serializeDate(DateTimeInterface $date): string
|
|
{
|
|
return $date->format('Y-m-d');
|
|
}
|
|
|
|
public function client(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Client::class);
|
|
}
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function getIsCompletedAttribute(): bool
|
|
{
|
|
return ! is_null($this->completed_at);
|
|
}
|
|
|
|
public function getActivityNoAttribute()
|
|
{
|
|
return 'ACT'.str_pad($this->id, 4, '0', STR_PAD_LEFT);
|
|
}
|
|
}
|