PHP code example of dillingham / nova-attach-many

1. Go to this page and download the library: Download dillingham/nova-attach-many 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/ */

    

dillingham / nova-attach-many example snippets


use NovaAttachMany\AttachMany;

public function fields(Request $request)
{
    return [
        AttachMany::make('Permissions'),
    ];
}

AttachMany::make('Field Name', 'relationshipName', RelatedResource::class);

public function fields(Request $request)
{
    return [
        AttachMany::make('Permissions'),
        BelongsToMany::make('Permissions'),
    ];
}

->rules('min:5', 'max:10', 'size:10', new CustomRule)

public function fields(Request $request)
{
    return [
        AttachMany::make('Permissions'),
    ];
}

public function permissionsSynced(array $changes)
{
    $changes['attached']; // An array of IDs of attached models
    $changes['detached']; // An array of IDs of detached models
    $changes['updated']; // An array of IDs of updated models
}