Files
monica/app/Day.php
T

74 lines
1.6 KiB
PHP

<?php
namespace App;
use App\Traits\Journalable;
use Illuminate\Database\Eloquent\Model;
use App\Interfaces\IsJournalableInterface;
class Day extends Model implements IsJournalableInterface
{
use Journalable;
/**
* The attributes that aren't mass assignable.
*
* @var array
*/
protected $guarded = ['id'];
protected $dates = [
'date',
];
/**
* Get the account record associated with the debt.
*/
public function account()
{
return $this->belongsTo(Account::class);
}
/**
* Get the day's rate.
*
* @param int $value
* @return int
*/
public function getRateAttribute($value)
{
return $value;
}
/**
* Get the day's comment.
*
* @param string $value
* @return string
*/
public function getCommentAttribute($value)
{
return $value;
}
/**
* Get all the information of the Entry for the journal.
* @return array
*/
public function getInfoForJournalEntry()
{
return [
'type' => 'day',
'id' => $this->id,
'rate' => $this->rate,
'comment' => $this->comment,
'day' => $this->date->day,
'day_name' => mb_convert_case(\App\Helpers\DateHelper::getShortDay($this->date), MB_CASE_TITLE, 'UTF-8'),
'month' => $this->date->month,
'month_name' => mb_convert_case(\App\Helpers\DateHelper::getShortMonth($this->date), MB_CASE_UPPER, 'UTF-8'),
'year' => $this->date->year,
'happens_today' => $this->date->isToday(),
];
}
}