Palzin Track
Get 15% off with code PTRACKSIGNUP15 

Laravel Diary Logo

PHP Enums tryFrom Method

I was recently working on a project where I was receiving data from an API that had a payment_type. I converted the payment_type into the enum below: enum PaymentType: string { case CREDIT_CARD = 'credit_card'; case APPLE_PAY = 'apple_pay'; case GOOGLE_PAY = 'google_pay'; case PAYPAL = 'paypal'; case SHOP_PAY = 'shop_pay'; } Then, I use this enum in the data...