PHP code example of bitcodesa / nova-label

1. Go to this page and download the library: Download bitcodesa/nova-label library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bitcodesa / nova-label example snippets




namespace App\Nova;

use Bitcodesa\NovaLabel\ResourceLabel;
use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Resource as NovaResource;

abstract class Resource extends NovaResource
{
    use ResourceLabel;

    // ...
}

Text::make(...self::attribute('name')); // field name and attribute same

Text::make(...self::attribute('name', 'fullName')); // field name: name, attribute: fullName

Text::make(self::attribute('name', title_only: true));

BelongsTo::make(...self::relation(\App\Nova\User::class, many: false)); // One-to-one relationship

HasMany::make(...self::relation(\App\Nova\Task::class, title: "Tasks", relation: "tasks"));

public static function getLangPath()
{
    return "Users";
}

public static function getLangName()
{
    return "Admin";
}



return [
    // Resource name in singular and plural form
    "resource" => "Resource",
    "resources" => "Resources",

    // Button labels
    "buttons" => [
        "create" => "Create Resource",
        "update" => "Update Resource",
    ],

    // Attributes
    "attributes" => [
        // Translate each attribute name
        "created_at" => __("created_at"),
        // ...
    ],

    // Additional sections (optional)
];
bash
php artisan make:label ResourceName LanguageSample
bash
php artisan make:label Book ar