Mikail.Net

Yazılımcı günlüğü

php artisan nova:field

PHP Artisan Nova field komutu, Laravel Nova’da özel bir alan oluşturmanızı sağlar. Laravel Nova, Laravel uygulamaları için güçlü bir yönetici arayüzüdür. İşte etkileyici, işlevsel, kullanım oranı yüksek ve basit bir örnek uygulama:

php artisan nova:field netz/product-price

Oluşturulan app/nova-components/ProductPrice/resources/js/components/IndexField.vue dosyasını düzenleyin ve özel bir para birimi alanı oluşturun:

<template>
  <span>{{ fieldValueWithCurrency }}</span>
</template>

<script>
export default {
  props: ['resourceName', 'field'],

  computed: {
    fieldValue() {
      return this.field.displayedAs || this.field.value
    },
    fieldValueWithCurrency() {
      return this.fieldValue + ' €';
    }
  }
}
</script>

DetailField.vue ve FormField.vue dosyalarını isteginize gore degistirebilirsiniz.

Son olarak, app/Nova/Product.php dosyasını veya herhangi bir resource dosyasını düzenleyin ve ProductPrice alanını kullanın:

use Netz\ProductPrice\ProductPrice;
// ...
public function fields(NovaRequest $request)
    {
        return [
            ID::make()->sortable(),
            Text::make('Name'),
            Text::make('Description'),
            ProductPrice::make('Price'),
        ];
    }
// ...