40 lines
1.4 KiB
PHP
40 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Modules\ProfessionalProject\Entities;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class PpTaskStatus extends Model
|
|
{
|
|
protected $table = 'pp_task_statuses';
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
protected $casts = [
|
|
'is_completed' => 'boolean',
|
|
];
|
|
|
|
public function tasks()
|
|
{
|
|
return $this->hasMany(PpTask::class, 'status_id');
|
|
}
|
|
|
|
public static function seedDefaults($business_id, $user_id = null)
|
|
{
|
|
$defaults = [
|
|
['title' => __('professionalproject::lang.status_new'), 'color' => '#95a5a6', 'position' => 1, 'is_completed' => false],
|
|
['title' => __('professionalproject::lang.status_in_progress'), 'color' => '#3498db', 'position' => 2, 'is_completed' => false],
|
|
['title' => __('professionalproject::lang.status_testing'), 'color' => '#f39c12', 'position' => 3, 'is_completed' => false],
|
|
['title' => __('professionalproject::lang.status_feedback'), 'color' => '#9b59b6', 'position' => 4, 'is_completed' => false],
|
|
['title' => __('professionalproject::lang.status_completed'), 'color' => '#27ae60', 'position' => 5, 'is_completed' => true],
|
|
];
|
|
|
|
foreach ($defaults as $status) {
|
|
self::firstOrCreate(
|
|
['business_id' => $business_id, 'title' => $status['title']],
|
|
array_merge($status, ['business_id' => $business_id, 'created_by' => $user_id])
|
|
);
|
|
}
|
|
}
|
|
}
|