Read time to article resource

This commit is contained in:
2020-08-09 02:10:14 +05:00
parent a254315c77
commit d461084d1c
15 changed files with 186 additions and 4 deletions

View File

@@ -5,6 +5,7 @@ namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
use App\Http\Resources\SourceResource;
use App\Http\Resources\TopicResource;
use Mtownsend\ReadTime\ReadTime;
class ArticleResource extends JsonResource
{
@@ -22,6 +23,7 @@ class ArticleResource extends JsonResource
"author" => $this->author,
"featured_image" => $this->featured_image,
"body" => $this->body,
"readtime" => (new ReadTime($this->body))->get(),
"source" => new SourceResource($this->source),
"topics" => TopicResource::collection($this->topics),
"link" => url(route('article.show',$this->id)),