complete story 5.1 with qa tests
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Models;
|
||||
use App\Enums\PostStatus;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Post extends Model
|
||||
{
|
||||
@@ -62,4 +63,12 @@ class Post extends Model
|
||||
|
||||
return $this->body[$locale] ?? $this->body['ar'] ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the excerpt by stripping HTML and limiting to 150 characters.
|
||||
*/
|
||||
public function getExcerpt(?string $locale = null): string
|
||||
{
|
||||
return Str::limit(strip_tags($this->getBody($locale)), 150);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user