Add (rss post): domain
This commit is contained in:
@@ -43,6 +43,7 @@ public function handle(): void
|
|||||||
if (is_null($rss_post)) {
|
if (is_null($rss_post)) {
|
||||||
$rss_post = new RssPost;
|
$rss_post = new RssPost;
|
||||||
$rss_post->post_url = $raw_post->link;
|
$rss_post->post_url = $raw_post->link;
|
||||||
|
$rss_post->post_domain = get_domain_from_url($raw_post->link);
|
||||||
$rss_post->source = $raw_post->source;
|
$rss_post->source = $raw_post->source;
|
||||||
$rss_post->source_url = $raw_post->source_url;
|
$rss_post->source_url = $raw_post->source_url;
|
||||||
$rss_post->title = remove_newline($raw_post->title);
|
$rss_post->title = remove_newline($raw_post->title);
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ class RssPost extends Model implements Feedable
|
|||||||
'source',
|
'source',
|
||||||
'source_url',
|
'source_url',
|
||||||
'post_url',
|
'post_url',
|
||||||
|
'post_domain',
|
||||||
'title',
|
'title',
|
||||||
'slug',
|
'slug',
|
||||||
'body',
|
'body',
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('rss_posts', function (Blueprint $table) {
|
||||||
|
$table->string('post_domain')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('rss_posts', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('post_domain');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -53,6 +53,23 @@
|
|||||||
|
|
||||||
Route::get('/crawlTask', [App\Http\Controllers\Tests\TestController::class, 'crawlTask']);
|
Route::get('/crawlTask', [App\Http\Controllers\Tests\TestController::class, 'crawlTask']);
|
||||||
|
|
||||||
|
Route::get('/set_domain', function (Request $request) {
|
||||||
|
|
||||||
|
$last_record = RssPost::whereNull('post_domain')->orderBy('id', 'DESC')->first();
|
||||||
|
|
||||||
|
for ($i = 1; $i <= $last_record->id; $i++) {
|
||||||
|
$rss_post = RssPost::find($i);
|
||||||
|
|
||||||
|
if (!is_null($rss_post))
|
||||||
|
{
|
||||||
|
$rss_post->post_domain = get_domain_from_url($rss_post->post_url);
|
||||||
|
$rss_post->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'ok';
|
||||||
|
});
|
||||||
|
|
||||||
Route::get('/set_keywords', function (Request $request) {
|
Route::get('/set_keywords', function (Request $request) {
|
||||||
|
|
||||||
$last_record = RssPost::where('keyword_saved', false)->orderBy('id', 'DESC')->first();
|
$last_record = RssPost::where('keyword_saved', false)->orderBy('id', 'DESC')->first();
|
||||||
|
|||||||
Reference in New Issue
Block a user