[ 'type' => 'bigint', ], 'user_id' => [ 'type' => 'bigint', 'nullable' => true, ], 'ad_type' => [ 'type' => 'string', 'length' => 10, 'required' => true, ], 'title' => [ 'type' => 'string', 'length' => 100, 'required' => true, ], 'slug' => [ 'type' => 'string', 'length' => 255, ], 'hide_title' => [ 'type' => 'bool', 'default' => 0, ], 'description' => [ 'type' => 'text', 'nullable' => true, ], 'target_url' => [ 'type' => 'string', 'length' => 2083, 'nullable' => true, ], 'media_url' => [ 'type' => 'string', 'length' => 2083, 'nullable' => true, ], 'media_id' => [ 'type' => 'bigint', 'nullable' => true, ], 'script_html' => [ 'type' => 'raw_html', 'nullable' => true, ], 'cta' => [ 'type' => 'string', 'length' => 100, 'nullable' => true, ], 'cta_type' => [ 'type' => 'string', 'length' => 10, 'default' => 'link', ], 'cta_position' => [ 'type' => 'string', 'length' => 10, 'default' => 'left', ], 'link_to' => [ 'type' => 'string', 'length' => 10, 'default' => 'link', ], 'status' => [ 'type' => 'enum', 'enum' => [ 'active', 'paused', 'deleted', 'draft', 'pending' ], 'default' => 'draft', ], 'created_at' => [ 'type' => 'datetime', 'nullable' => true, ], 'updated_at' => [ 'type' => 'datetime', 'nullable' => true, ], ]; } public static function table() { return static::TABLE; } /** * Fetch a single active Ad by ID, returning all fields * needed by AdRendererController. * * @param int $id * * @return array|null */ public static function findActive( int $id ): ?array { $row = DB::get( TableName::ADFUZ_ADS() ) ->where( 'status', 'active' ) ->find( $id ); return $row ?: null; } /** * Get all active ads for use in dropdowns / selects. * * @return array [ [ 'id', 'title', 'ad_type' ], ... ] */ public static function allActive(): array { return DB::get( TableName::ADFUZ_ADS() ) ->select( 'id', 'title', 'ad_type' ) ->where( 'status', 'active' ) ->orderBy( 'title', 'ASC' ) ->get(); } }