mirror of
https://gh.wpcy.net/https://github.com/LJPc-solutions/freescout-calendar-module.git
synced 2026-07-15 21:36:37 +08:00
62 lines
1.4 KiB
PHP
62 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Modules\LJPcCalendarModule\Entities;
|
|
|
|
use App\User;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use JsonSerializable;
|
|
|
|
class CalendarItem extends Model implements JsonSerializable {
|
|
public const ACTION_TYPE_ADD_TO_CALENDAR = 186;
|
|
|
|
protected $table = 'calendar_items';
|
|
protected $fillable = [
|
|
'calendar_id',
|
|
'author_id',
|
|
'is_all_day',
|
|
'is_private',
|
|
'is_read_only',
|
|
'title',
|
|
'body',
|
|
'state',
|
|
'location',
|
|
'start',
|
|
'end',
|
|
];
|
|
|
|
public function calendar(): BelongsTo {
|
|
return $this->belongsTo( Calendar::class );
|
|
}
|
|
|
|
public function jsonSerialize(): array {
|
|
$retArr = [
|
|
'id' => $this->id,
|
|
'title' => $this->title,
|
|
'location' => $this->location,
|
|
'body' => $this->body,
|
|
'state' => $this->state,
|
|
'start' => $this->start,
|
|
'end' => $this->end,
|
|
'isAllDay' => $this->is_all_day,
|
|
'category' => $this->is_all_day ? 'allday' : 'time',
|
|
'isPrivate' => $this->is_private,
|
|
'isReadOnly' => $this->is_read_only,
|
|
'calendarId' => $this->calendar_id,
|
|
'raw' => [],
|
|
];
|
|
|
|
$creator = User::where( 'id', $this->author_id )->first();
|
|
if ( $creator !== null ) {
|
|
$retArr['raw']['creator'] = [
|
|
'id' => $this->author_id,
|
|
'name' => $creator->getFullName(),
|
|
'email' => $creator->email,
|
|
'avatar' => $creator->getPhotoUrl(),
|
|
'phone' => $creator->phone,
|
|
];
|
|
}
|
|
|
|
return $retArr;
|
|
}
|
|
}
|