Create Select Options from Enums, Laravel Models, and more

Published on : July 27,2022
Create Select Options from Enums, Laravel Models, and more

Laravel Options by Spatie is a package to create lists of options from different sources:

A typical web application always has many select fields with options. This package makes it simple to transform enums, models, states, and arrays to a unified option structure.

An example from the readme illustrates how this package can help ease working with select options in Laravel applications. Given an enum, you can use this package to build options:

enum Hobbit: string
    case Frodo = 'frodo';
    case Sam = 'sam';
    case Merry = 'merry';
    case Pippin = 'pippin';
/* returns the following array
    ['label' => 'Frodo', 'value' => 'frodo'],
    ['label' => 'Sam', 'value' => 'sam'],
    ['label' => 'Merry', 'value' => 'merry'],
    ['label' => 'Pippin', 'value' => 'pippin'],
// Or return JSON

Not only can you use Enums, but this package also supports data from various sources, including:

  • Models
  • Model States (via Spatie Model States)
  • Arrays
  • Manually

Another neat feature is that you can turn your options into a validation rule:

    // ['in:frodo,sam,merry,pippin']
    'hobbit' => Options::forEnum(Hobbit::class)->toValidationRule()



Categories : Laravel PHP

Tags : Laravel Packages Laravel 9

Praful Sangani
Praful Sangani
I'm a passionate full-stack developer with expertise in PHP, Laravel, Angular, React Js, Vue, Node, Javascript, JQuery, Codeigniter, and Bootstrap. I enjoy sharing my knowledge by writing tutorials and providing tips to others in the industry. I prioritize consistency and hard work, and I always aim to improve my skills to keep up with the latest advancements. As the owner of Open Code Solution, I'm committed to providing high-quality services to help clients achieve their business goals.


fenofibrate 160mg sale oral fenofibrate order tricor 200mg for sale

ketotifen 1mg usa buy cheap geodon tofranil over the counter

cialis 40mg for sale sildenafil pharmacy sildenafil 100mg brand

acarbose over the counter order repaglinide online fulvicin 250mg pill

aspirin 75 mg us zovirax tubes zovirax brand

purchase meloset for sale order melatonin 3mg pills danocrine 100mg ca

buy florinef generic pill florinef buy imodium 2 mg generic

prasugrel online buy detrol for sale order tolterodine 2mg for sale

monograph 600 mg us purchase monograph generic buy generic cilostazol

pyridostigmine sale order maxalt 5mg without prescription purchase rizatriptan for sale

purchase enalapril generic order duphalac for sale lactulose for sale online

order betahistine 16 mg betahistine 16mg canada purchase probenecid generic

purchase latanoprost online cheap generic xalatan purchase rivastigmine generic

omeprazole 10mg canada omeprazole order online buy cheap generic metoprolol

premarin 600 mg price buy generic premarin online sildenafil fast shipping

micardis 20mg generic buy telmisartan 20mg pills movfor order

cenforce 50mg usa order chloroquine 250mg without prescription buy cheap generic aralen

cialis 20mg pill buy viagra pills buy viagra 100mg online cheap

modafinil 200mg price promethazine medication prednisone 5mg canada

buy cefdinir 300 mg generic order lansoprazole 30mg generic order lansoprazole generic

cheap isotretinoin buy accutane zithromax order

buy lipitor generic order albuterol 100mcg online cheap buy generic amlodipine over the counter

order azithromycin 500mg without prescription order azithromycin pills order neurontin 600mg pill

blackjack vegas free online games gambling casino furosemide 40mg tablet

order protonix 20mg pill phenazopyridine 200mg tablet where can i buy phenazopyridine

online casino for real cash order ventolin 2mg without prescription order ventolin online cheap

online poker real money play slots ivermectin 12 mg over counter

symmetrel where to buy symmetrel 100mg pill buy avlosulfon medication

hard rock casino online buy synthroid online how to get synthroid without a prescription

buy methylprednisolone cheap buy triamcinolone online cheap triamcinolone 4mg without prescription

clomid 50mg pill buy azathioprine 25mg generic azathioprine 50mg uk

levitra online order buy generic levitra 20mg buy generic zanaflex

buy coversyl paypal desloratadine price fexofenadine 120mg over the counter

where can i buy dilantin brand cyclobenzaprine buy oxybutynin 2.5mg pill

loratadine over the counter claritin online order priligy 60mg usa

lioresal tablet order baclofen without prescription buy ketorolac cheap

buy baclofen for sale order baclofen online cheap buy toradol pill

fosamax price buy alendronate 70mg for sale furadantin 100 mg without prescription

buy amaryl 1mg without prescription etoricoxib 60mg generic order arcoxia generic

inderal 20mg generic buy generic clopidogrel online plavix 75mg brand

buy pamelor 25 mg online where can i buy pamelor acetaminophen drug

orlistat canada order diltiazem generic buy diltiazem

order generic coumadin order paxil 20mg generic buy reglan online

buy azelastine 10ml without prescription avapro 300mg brand buy avalide without a prescription

purchase famotidine online losartan 25mg cheap order prograf 5mg pills

buy nexium 40mg purchase mirtazapine for sale topamax 200mg without prescription

order zyloprim 100mg buy clobetasol paypal cost rosuvastatin 10mg

oral imitrex order dutasteride for sale buy avodart online

buy buspirone 5mg online cordarone 200mg usa amiodarone 200mg us

zantac 300mg usa zantac 150mg oral buy generic celebrex

motilium 10mg tablet order domperidone online cheap tetracycline 500mg without prescription

write me a paper buying a term paper cheap essay help

buy generic aldactone online cost finasteride 5mg where can i buy finasteride

oral sildenafil aurogra tablet cheap yasmin

diflucan 200mg us forcan online order order ciprofloxacin 1000mg sale

lamictal 50mg cost buy lamictal online order vermox 100mg

buy flagyl 200mg pill flagyl uk keflex over the counter

order cleocin 300mg for sale cleocin order order fildena 50mg generic

tretinoin gel canada purchase retin online avanafil pills

tamoxifen pill buy nolvadex 20mg pill cheap budesonide

purchase tadacip online cheap indocin 50mg over the counter buy indomethacin 75mg capsule

buy generic axetil ceftin for sale buy methocarbamol medication

terbinafine online buy online casino real cash payout play roulette

order desyrel 100mg pill clindamycin generic buy clindac a sale

aspirin 75 mg pill aspirin 75 mg price casino world

buy an essay online cheap health dissertation buy generic suprax over the counter

pay for assignments australia do my research paper free blackjack games

purchase amoxicillin online cost macrobid biaxin 500mg pills

rocaltrol us order generic fenofibrate 200mg fenofibrate 200mg price

clonidine 0.1 mg canada spiriva 9mcg uk tiotropium bromide drug

best topical acne medication prescription most common medication prescribed acne buy trileptal 300mg generic

minocycline 50mg cheap ropinirole 2mg oral requip oral

uroxatral 10mg us strongest otc for acid reflux heartburn medication before food

buy femara 2.5 mg generic cheap abilify 30mg aripiprazole price

strongest sleeping pills over counter best gnc weight loss supplements newest prescription weight loss medication

medroxyprogesterone 5mg drug order praziquantel 600 mg pill buy microzide without prescription

medicine to stop smoking cigarettes free medication to stop smoking online doctor consultation pain prescription

cyproheptadine over the counter ketoconazole 200mg drug nizoral us

list of antivireal drugs least expensive inhaled steroid generic rx for diabetes

order cymbalta 40mg modafinil 100mg pills buy modafinil pills for sale

what kills skin fungus fast 4 most dangerous blood pressure drugs getting blood pressur meds online

where can i buy phenergan stromectol where to buy ivermectin 12mg over the counter

best antacid for stomach ulcer erosion of stomach lining virtual visit for uti

same day birth control prescription antibiotics taken for prostate infection male enhancement pills increase size permanently

buy deltasone 40mg sale amoxicillin where to buy amoxil 1000mg tablet

best otc heartburn medicine reviews heartburn pills over the counter bowel cramps smelly gas nhs

purchase zithromax neurontin 100mg cheap buy gabapentin tablets

actigall pills order actigall sale cetirizine medication

strattera 10mg price sertraline order online buy zoloft pills for sale

buy furosemide no prescription purchase ventolin inhaler buy ventolin inhalator

escitalopram 20mg over the counter purchase escitalopram generic brand revia

clavulanate canada order augmentin pill clomid 100mg pill

combivent us buy dexamethasone 0,5 mg purchase linezolid without prescription

buy vardenafil 10mg without prescription generic levitra 10mg order generic hydroxychloroquine 200mg

buy nateglinide sale buy capoten no prescription candesartan ca

order carbamazepine pills buy generic lincocin 500mg buy lincomycin medication

order cenforce pill chloroquine 250mg brand buy metformin 500mg online

lipitor 20mg cheap prinivil us buy generic zestril 10mg

duricef price purchase epivir online cheap purchase epivir generic

prilosec 20mg over the counter buy omeprazole 10mg pill order atenolol 50mg pill

buy generic dostinex over the counter buy cabergoline 0.5mg online dapoxetine 90mg oral

buy cheap depo-medrol purchase medrol clarinex 5mg sale

nootropil 800 mg us buy nootropil cheap clomipramine where to buy

oral zovirax buy zyloprim generic buy rosuvastatin generic

order sporanox 100mg for sale tindamax 300mg without prescription buy tinidazole 300mg pills

buy ezetimibe cheap motilium brand tetracycline cheap

buy zyprexa 10mg generic nebivolol 5mg generic valsartan 160mg cheap

order cyclobenzaprine 15mg generic cyclobenzaprine tablet ketorolac pills

order colchicine 0.5mg pill colchicine canada buy methotrexate for sale

acne treatment recommended by dermatologists buy clearasil adult acne medication expensive zit pills

behind the counter allergy medicine order azelastine 10ml sprayer skin allergy tablets list

best medication for stomqch cramps perindopril online

prednisone pills prednisone order online

strongest medicine for gerd generic lincocin

most effective acne pills ranked omnicef 300 mg sale best contraceptive pills for acne

most effective heartburn medicine metformin 500mg pills

order accutane 20mg online order isotretinoin 20mg generic cost isotretinoin

Хотел выразить благодарность коллеге за поддержку. Заказал на "Цветов.ру" стильный букет, чтобы подчеркнуть профессионализм и теплоту отношений. Рекомендую всем, кто ценит красоту в мелочах! Советую! Вот ссылка - купить букет

sleeping tablets without a prescription modafinil usa

amoxil 250mg brand buy generic amoxil over the counter amoxil canada

azithromycin buy online azithromycin 500mg without prescription buy generic azithromycin 250mg

gabapentin 600mg ca buy neurontin 600mg pills

azithromycin 500mg for sale cheap azithromycin 250mg order azipro 500mg generic

oral furosemide generic lasix 100mg

prednisolone for sale buy omnacortil 20mg for sale buy prednisolone 10mg online cheap

buy generic prednisone prednisone 5mg oral

purchase amoxil pills order amoxicillin 1000mg online buy amoxicillin online cheap

purchase monodox pills purchase acticlate pills

buy generic ventolin ventolin for sale online what to do when allergy medicine doesn't work

order augmentin 625mg generic order augmentin generic

generic synthroid 100mcg buy synthroid 75mcg order synthroid 100mcg without prescription

levitra 20mg without prescription order levitra 20mg sale

buy clomid 50mg generic buy serophene online buy serophene pill

order semaglutide 14 mg for sale rybelsus 14 mg generic rybelsus cheap

buy tizanidine paypal order tizanidine online buy tizanidine 2mg pill

С того дня, как я начал правильно питаться, моя жизнь изменилась. Я благодарю компанию 'все соки' за их - соковыжималку для граната. Теперь каждое утро начинается с бодрящего гранатового сока!

deltasone 20mg uk order prednisone 5mg online cheap prednisone 20mg sale

purchase semaglutide pill order rybelsus generic generic rybelsus 14 mg

purchase isotretinoin pill buy absorica sale buy accutane 20mg generic

buy albuterol 4mg inhaler buy albuterol pill cost albuterol

buy amoxicillin 250mg generic amoxicillin pill amoxil 1000mg drug

amoxiclav buy online augmentin 625mg brand augmentin 375mg canada

order zithromax online azithromycin without prescription zithromax uk

levothyroxine cost buy levothyroxine paypal buy levoxyl pill

omnacortil 5mg oral buy omnacortil 10mg pills order omnacortil generic

gambling meaning casino card games best online gambling sites

vardenafil 20mg over the counter levitra price order levitra 20mg online

where can i buy lyrica pregabalin pills lyrica online

order hydroxychloroquine 400mg online hydroxychloroquine medication oral hydroxychloroquine 200mg

purchase aristocort online triamcinolone 10mg sale purchase triamcinolone sale

order tadalafil 20mg sale cialis pills 20mg tadalafil 20mg generic

buy clarinex online cheap buy clarinex pills clarinex 5mg drug

buy cenforce 100mg pills buy cenforce pill buy generic cenforce online

buy loratadine 10mg for sale order generic claritin order loratadine sale

chloroquine 250mg us buy aralen 250mg for sale order chloroquine pill

order glycomet 1000mg online purchase metformin metformin order

buy xenical 60mg generic orlistat 120mg without prescription purchase diltiazem generic

lipitor 80mg for sale atorvastatin 20mg us lipitor 20mg cheap

Leave a comment

We'll never share your email with anyone else. Required fields are marked *

Related Articles

Access specifier in php
Praful Sangani By Praful Sangani - July 20,2022