Make Enum

2024-09-07 وقت القراءه : 1 دقائق

واحدة من الأوامر المهمة التي ظهرت في Laravel 11 هي  Make Enum.

لإنشاء enum يمكن لنا إستخدام الأمر make:enum وهنا لارافيل سوف يسألنا عن إسم enum الذي نريد إنشاءه، وكذلك يمكن لنا إضافة إسم enum مباشرة.

إنشاء enum دون تحديد الإسم

etharshrouf@Ethars-MacBook-Pro test % php artisan make:enum


 ┌ What should the enum be named? ──────────────────────────────┐
 │ OrderStatus                                                  │
 └──────────────────────────────────────────────────────────────┘


 ┌ Which type of enum would you like? ──────────────────────────┐
 │ Pure enum                                                    │
 └──────────────────────────────────────────────────────────────┘


   INFO  Enum [app/OrderStatus.php] created successfully.  


etharshrouf@Ethars-MacBook-Pro test % 

بعد تنفيذ الأمر، يسأل بداية عن الإسم ، ثم نوع enum.

<?php
namespace App;
enum OrderStatus
{
    //
}


كذلك يمكن إنشاء enum مع تحديد الإسم مباشرة

php artisan make:enum StudentStatus

هذه الـ enum يتم إنشاؤها مباشرة في المجلد app وكذلك يمكن لنا إنشاء مجلد للـ enum ووضعها بداخل هذا المجلد

php artisan make:enum Enums/CourseEnum

ولمعرفة جميع الخيارات التي يمكن إستخدامها عند إنشاء enum يمكن لنا تمرير الخيار --help

php artisan make:enum --help          


Description:
  Create a new enum


Usage:
  make:enum [options] [--] <name>


Arguments:
  name                  The name of the enum


Options:
  -s, --string          Generate a string backed enum.
  -i, --int             Generate an integer backed enum.
  -f, --force           Create the enum even if the enum already exists
  -h, --help            Display help for the given command. When no command is given display help for the list command
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi|--no-ansi  Force (or disable --no-ansi) ANSI output
  -n, --no-interaction  Do not ask any interactive question
      --env[=ENV]       The environment the command should run under
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug


إضافة تعليق
Loading...