create PM v0.5
This commit is contained in:
parent
9b47296cea
commit
d2ba22c0cf
25 changed files with 2155 additions and 72 deletions
|
|
@ -6,6 +6,7 @@ use App\Enums\Portal;
|
|||
use App\Enums\PressReleaseStatus;
|
||||
use App\Models\Concerns\HasUniqueSlug;
|
||||
use App\Scopes\PortalScope;
|
||||
use App\Services\PressRelease\PressReleaseHtmlSanitizer;
|
||||
use Database\Factories\PressReleaseFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
|
@ -13,6 +14,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
class PressRelease extends Model
|
||||
{
|
||||
|
|
@ -45,8 +47,10 @@ class PressRelease extends Model
|
|||
'category_id',
|
||||
'language',
|
||||
'title',
|
||||
'subtitle',
|
||||
'slug',
|
||||
'text',
|
||||
'boilerplate_override',
|
||||
'backlink_url',
|
||||
'keywords',
|
||||
'status',
|
||||
|
|
@ -55,6 +59,8 @@ class PressRelease extends Model
|
|||
'teaser_end',
|
||||
'no_export',
|
||||
'published_at',
|
||||
'scheduled_at',
|
||||
'embargo_at',
|
||||
'legacy_portal',
|
||||
'legacy_id',
|
||||
];
|
||||
|
|
@ -69,6 +75,8 @@ class PressRelease extends Model
|
|||
'teaser_end' => 'integer',
|
||||
'no_export' => 'boolean',
|
||||
'published_at' => 'datetime',
|
||||
'scheduled_at' => 'datetime',
|
||||
'embargo_at' => 'datetime',
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
|
@ -93,6 +101,11 @@ class PressRelease extends Model
|
|||
return $this->hasMany(PressReleaseImage::class);
|
||||
}
|
||||
|
||||
public function attachments(): HasMany
|
||||
{
|
||||
return $this->hasMany(PressReleaseAttachment::class);
|
||||
}
|
||||
|
||||
public function contacts(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Contact::class, 'press_release_contact');
|
||||
|
|
@ -102,4 +115,18 @@ class PressRelease extends Model
|
|||
{
|
||||
return $this->hasMany(PressReleaseStatusLog::class)->orderByDesc('created_at');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display-ready text. Returns sanitized HTML for Phase-7+ PMs and
|
||||
* <p>/<br>-wrapped legacy plain text for older imports.
|
||||
*/
|
||||
public function renderedText(): HtmlString
|
||||
{
|
||||
return app(PressReleaseHtmlSanitizer::class)->render($this->text);
|
||||
}
|
||||
|
||||
public function plainTextLength(): int
|
||||
{
|
||||
return app(PressReleaseHtmlSanitizer::class)->plainTextLength($this->text);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue