PHP code example of daniel-de-wit / nova-single-record-resource

1. Go to this page and download the library: Download daniel-de-wit/nova-single-record-resource 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/ */

    

daniel-de-wit / nova-single-record-resource example snippets




namespace App\Nova;

use DanielDeWit\NovaSingleRecordResource\Contracts\SingleRecordResourceInterface;
use DanielDeWit\NovaSingleRecordResource\Traits\SupportSingleRecordNavigationLinks;
use Laravel\Nova\Resource as NovaResource;

abstract class Resource extends NovaResource implements SingleRecordResourceInterface
{
    use SupportSingleRecordNavigationLinks;

    ...
}

class MyResource extends Resource
{
    public static function singleRecord(): bool
    {
        return true;
    }
}

class MyResource extends Resource
{
    /**
     * @return string|int
     */
    public static function singleRecordId()
    {
        return 1;
    }
}

@if ($resource::singleRecord())
    <router-link :to="{
    name: 'detail',
    params: {
        resourceName: '{{ $resource::uriKey() }}',
        resourceId: {{ $resource::singleRecordId() }}
    }
}" class="text-white text-justify no-underline dim">
        {{ $resource::label() }}
    </router-link>
@else
    <router-link :to="{
    name: 'index',
    params: {
        resourceName: '{{ $resource::uriKey() }}'
    }
}" class="text-white text-justify no-underline dim">
        {{ $resource::label() }}
    </router-link>
@endif

$ php artisan vendor:publish --provider="DanielDeWit\NovaSingleRecordResource\Providers\NovaSingleRecordResourceServiceProvider"

rm resources/views/vendor/nova/resources/navigation.blade.php