<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class BreakHistory extends Model
{
    //
    protected $table = 'breaks';

    const NOT_DO = 0;
    const DOING = 1;
    const DONE = 2;

    protected $fillable = [
        'item_id',
        'content',
        'status',
        'room_id',
        'hostel_id',
        'created_at',
        'updated_at',
        'deleted_at',
        'item_id',
        'user_id',
        'user_repair',
        'day_repair',
        'cost',
        'created_at',
        'updated_at',
        'deleted_at'
    ];

    protected $dates = [
        'created_at',
        'updated_at',
        'deleted_at',
       // 'day_repair'
    ];

    public function getStatusTextAttribute()
    {
        $status = $this->attributes['status'];

        if ($status == BreakHistory::NOT_DO) {
            return '<label class="label label-danger">Chưa xử lý</label>';
        }

        if ($status == BreakHistory::DOING) {
            return '<label class="label label-warning">Đang thực hiện</label>';
        }

        if ($status == BreakHistory::DONE) {
            return '<label class="label label-success">Đã hoàn thành</label>';
        }

    }

}
