Add (image ref)
This commit is contained in:
@@ -165,6 +165,7 @@ private static function setPostImage($post)
|
|||||||
$serp_url_researches = SerpUrlResearch::where('serp_url_id', $post->serp_url_id)->get();
|
$serp_url_researches = SerpUrlResearch::where('serp_url_id', $post->serp_url_id)->get();
|
||||||
|
|
||||||
$main_image_url = null;
|
$main_image_url = null;
|
||||||
|
$image_ref_url = null;
|
||||||
|
|
||||||
foreach ($serp_url_researches as $serp_url_research) {
|
foreach ($serp_url_researches as $serp_url_research) {
|
||||||
if (! is_empty($serp_url_research->main_image)) {
|
if (! is_empty($serp_url_research->main_image)) {
|
||||||
@@ -175,6 +176,7 @@ private static function setPostImage($post)
|
|||||||
}
|
}
|
||||||
|
|
||||||
$main_image_url = $serp_url_research->main_image;
|
$main_image_url = $serp_url_research->main_image;
|
||||||
|
$image_ref_url = $serp_url_research->url;
|
||||||
|
|
||||||
$image_response = Http::timeout(300)->withHeaders([
|
$image_response = Http::timeout(300)->withHeaders([
|
||||||
'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36',
|
'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36',
|
||||||
@@ -233,6 +235,7 @@ private static function setPostImage($post)
|
|||||||
OSSUploader::uploadFile('r2', 'post_images_2/', $thumb_filename, (string) $thumb->stream('jpeg', 50));
|
OSSUploader::uploadFile('r2', 'post_images_2/', $thumb_filename, (string) $thumb->stream('jpeg', 50));
|
||||||
|
|
||||||
$post->featured_image = 'post_images_2/'.$filename;
|
$post->featured_image = 'post_images_2/'.$filename;
|
||||||
|
$post->image_ref_url = $image_ref_url;
|
||||||
|
|
||||||
$image->destroy();
|
$image->destroy();
|
||||||
|
|
||||||
|
|||||||
@@ -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('posts', function (Blueprint $table) {
|
||||||
|
$table->string('image_ref_url')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('posts', function (Blueprint $table) {
|
||||||
|
$table->dropColumn(('image_ref_url'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user