Meta data and article resources in topic,source
This commit is contained in:
@@ -6,6 +6,7 @@ use Illuminate\Http\Request;
|
||||
use App\Topic;
|
||||
use App\Http\Resources\TopicResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use App\Http\Resources\ArticleResource;
|
||||
|
||||
class TopicsController extends Controller
|
||||
{
|
||||
@@ -30,7 +31,7 @@ class TopicsController extends Controller
|
||||
{
|
||||
return response()->json([
|
||||
'topic' => new TopicResource($topic),
|
||||
'articles' => $topic->articles()->paginate(8)
|
||||
'articles' => ArticleResource::collection($topic->articles()->paginate(8))
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@@ -28,7 +28,8 @@ class ArticleResource extends JsonResource
|
||||
"source" => new SourceResource($this->source),
|
||||
"topics" => TopicResource::collection($this->topics),
|
||||
"link" => url(route('article.show',$this->id)),
|
||||
"published_date" => $this->published_date
|
||||
"published_date" => $this->published_date,
|
||||
"meta" => $this->meta
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -63,6 +63,7 @@ class MihaaruScraper
|
||||
$data = [
|
||||
'source' => 'Mihaaru',
|
||||
'title' => $this->title,
|
||||
'og_title' => $crawler->filter('meta[property*="og:title"]')->first()->attr('content'),
|
||||
'image' => $this->image,
|
||||
'content' => $this->content,
|
||||
'url' => $url,
|
||||
|
@@ -23,6 +23,7 @@ class CreateArticlesTable extends Migration
|
||||
$table->string("guid")->nullable();
|
||||
$table->unsignedBigInteger('source_id');
|
||||
$table->dateTime('published_date');
|
||||
$table->json('meta')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user