$array, array $array1) */ class PlatformChannelPost extends Model { protected $fillable = [ 'platform', 'channel_id', 'channel_name', 'post_id', 'url', 'title', 'posted_at', ]; /** * @return array */ protected function casts(): array { return [ 'posted_at' => 'datetime', 'platform' => PlatformEnum::class, ]; } public static function urlExists(PlatformEnum $platform, string $channelId, string $url): bool { return self::where('platform', $platform) ->where('channel_id', $channelId) ->where('url', $url) ->exists(); } public static function storePost(PlatformEnum $platform, string $channelId, ?string $channelName, string $postId, ?string $url, ?string $title, ?\DateTime $postedAt = null): self { return self::updateOrCreate( [ 'platform' => $platform, 'channel_id' => $channelId, 'post_id' => $postId, ], [ 'channel_name' => $channelName, 'url' => $url, 'title' => $title, 'posted_at' => $postedAt ?? now(), ] ); } }