array( 'type' => 'bigint', ), 'user_id' => array( 'type' => 'bigint', 'nullable' => true, ), 'ad_type' => array( 'type' => 'string', 'length' => 10, 'required' => true, ), 'title' => array( 'type' => 'string', 'length' => 100, 'required' => true, ), 'slug' => array( 'type' => 'string', 'length' => 255, ), 'hide_title' => array( 'type' => 'bool', 'default' => 0, ), 'hide_link_name' => array( 'type' => 'bool', 'default' => false, ), 'description' => array( 'type' => 'text', 'nullable' => true, ), 'target_url' => array( 'type' => 'string', 'length' => 2083, 'nullable' => true, ), 'media_url' => array( 'type' => 'string', 'length' => 2083, 'nullable' => true, ), 'media_id' => array( 'type' => 'bigint', 'nullable' => true, ), 'script_html' => array( 'type' => 'raw_html', 'nullable' => true, ), 'cta' => array( 'type' => 'string', 'length' => 100, 'nullable' => true, ), 'cta_type' => array( 'type' => 'string', 'length' => 10, 'default' => 'link', ), 'cta_position' => array( 'type' => 'string', 'length' => 10, 'default' => 'left', ), 'link_to' => array( 'type' => 'string', 'length' => 10, 'default' => 'link', ), 'status' => array( 'type' => 'enum', 'enum' => array( 'active', 'paused', 'deleted', 'draft', 'pending' ), 'default' => 'draft', ), 'created_at' => array( 'type' => 'datetime', 'nullable' => true, ), 'updated_at' => array( '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(); } }