This commit is contained in:
2023-11-28 04:39:36 +08:00
parent a9ac0e48b3
commit dc37274b6c
86 changed files with 2106 additions and 191 deletions

View File

@@ -7,12 +7,14 @@
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Storage;
/**
* Class AiTool
*
*
* @property int $id
* @property int $category_id
* @property int $url_to_crawl_id
@@ -27,56 +29,72 @@
* @property string|null $qna
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
*
* @property Category $category
* @property UrlToCrawl $url_to_crawl
* @property Collection|SearchEmbedding[] $search_embeddings
* @property Collection|AiToolKeyword[] $ai_tool_keywords
*
* @package App\Models
*/
class AiTool extends Model
{
protected $table = 'ai_tools';
protected $table = 'ai_tools';
protected $casts = [
'category_id' => 'int',
'url_to_crawl_id' => 'int',
'is_ai_tool' => 'bool',
'qna' => 'object'
];
protected $casts = [
'category_id' => 'int',
'url_to_crawl_id' => 'int',
'view_count' => 'int',
'is_ai_tool' => 'bool',
'qna' => 'object',
];
protected $fillable = [
'category_id',
'url_to_crawl_id',
'screenshot_img',
'is_ai_tool',
'tool_name',
'is_app_web_both',
'tagline',
'summary',
'pricing_type',
'keyword_string',
'qna'
];
protected $fillable = [
'category_id',
'url_to_crawl_id',
'screenshot_img',
'is_ai_tool',
'tool_name',
'slug',
'is_app_web_both',
'tagline',
'summary',
'pricing_type',
'keyword_string',
'view_count',
'qna',
'external_url
',
];
public function category()
{
return $this->belongsTo(Category::class);
}
protected function screenshotImg(): Attribute
{
return Attribute::make(
get: function ($value = null) {
if (! is_empty($value)) {
public function url_to_crawl()
{
return $this->belongsTo(UrlToCrawl::class);
}
return Storage::disk(config('platform.uploads.ai_tools.screenshot.driver'))->url(config('platform.uploads.ai_tools.screenshot.path').$value);
}
public function search_embeddings()
{
return $this->hasMany(SearchEmbedding::class);
}
return null;
}
);
}
public function ai_tool_keywords()
{
return $this->hasMany(AiToolKeyword::class);
}
public function category()
{
return $this->belongsTo(Category::class);
}
public function url_to_crawl()
{
return $this->belongsTo(UrlToCrawl::class);
}
public function search_embeddings()
{
return $this->hasMany(SearchEmbedding::class);
}
public function keywords()
{
return $this->hasMany(AiToolKeyword::class);
}
}