New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

ferdiunal/nova-editable-field

A Laravel Nova package to make fields editable.
5,676 11
Install
composer require ferdiunal/nova-editable-field
Latest Version:v1.0.1
PHP:^8.2
Laravel:10 · 11
License:MIT
Last Updated:Sep 16, 2024
Links: GitHub  ·  Packagist
Maintainer: ferdiunal

Nova Editable Field

The purpose of this Laravel Nova Field is to allow easy updates to records within tables (development and testing for the Detail view are still in progress). So far, I haven't tested it with third-party components. It's very easy to use and can be seamlessly integrated with form fields and BelongsTo fields.

Installation

composer require ferdiunal/nova-editable-field

Usage

It is very easy to use, the first parameter is NovaRequest, the second one allows us to dynamically change the width of the Popover.

<?php

namespace App\Nova;

use Illuminate\Http\Request;
use Laravel\Nova\Fields\Email;
use Laravel\Nova\Fields\Gravatar;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;

class User extends Resource
{
    /**
     * The model the resource corresponds to.
     *
     * @var class-string<\App\Models\User>
     */
    public static $model = \App\Models\User::class;

    /**
     * The single value that should be used to represent the resource when being displayed.
     *
     * @var string
     */
    public static $title = 'name';

    /**
     * The columns that should be searched.
     *
     * @var array
     */
    public static $search = [
        'id', 'name', 'email',
    ];

    /**
     * Get the fields displayed by the resource.
     *
     * @return array
     */
    public function fields(NovaRequest $request)
    {
        return [
            ID::make()->sortable()->hideFromIndex(),
            Gravatar::make()->maxWidth(50),
            Text::make('Name')
                ->sortable()
                ->maxlength(255)
                ->enforceMaxlength()
                ->rules('required', 'max:255')
                ->editable($request, '300px'),
            Email::make('Email')
                ->sortable()
                ->rules('required', 'email', 'max:254')
                ->maxlength(254)
                ->enforceMaxlength()
                ->creationRules('unique:users,email')
                ->updateRules('unique:users,email,{{resourceId}}')
                ->editable($request),
        ];
    }
}

Screenshots

License This package is open-sourced software licensed under the MIT license.

Related Packages

timothyasp/nova-color-field

A Laravel Nova Color Picker field.

1,864,197 76
alexwenzel/nova-dependency-container

A Laravel Nova 4 form container for grouping fields that depend on other field v...

1,392,119 46
inspheric/nova-url-field

A Laravel Nova URL field.

1,363,468 102
davidpiesse/nova-toggle

A Boolean Toggle Switch Field

1,149,364 85
oneduo/nova-time-field

A Laravel Nova time field

197,513 13

Version History

Version Released PHP Laravel License
v1.0.1 ^8.2 ^10.0|^11.0 MIT
v1.0.0 ^8.2 ^10.0|^11.0 MIT