The error "Data missing" is being thrown because the format 'my' is expecting a string with both month and year values, separated by a delimiter. Since the expiration date doesn't have a delimiter, Carbon is unable to parse it correctly.
To fix this, you can manually add the delimiter to the expiration date string before passing it to Carbon. For example, if the expiration date is in the format 'mY' (month and year without delimiter), you can add the delimiter like this:
$exp_date = '0622'; // example expiration date without delimiter
$exp_date_with_delimiter = substr($exp_date, 0, 2) . '/' . substr($exp_date, 2);
// $exp_date_with_delimiter is now '06/22'
Carbon::createFromFormat('m/Y', $exp_date_with_delimiter)->lt(now()->startOfMonth()) ? 'Expired' : 'OK';
This code adds a '/' delimiter between the first two characters (month) and the last two characters (year) of the expiration date string. Then, it passes the formatted string to Carbon using the 'm/Y' format, which expects a string with month and year values separated by a '/' delimiter.