PHP code example of nova-kit / helpers

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

    

nova-kit / helpers example snippets


NovaKit\column_name(string|\Illuminate\Database\Eloquent\Model $model, string $attribute): string;

use function NovaKit\column_name;

return column_name(App\Models\User::class, 'email');

NovaKit\eloquent_exists(\Illuminate\Database\Eloquent\Model|mixed $model): bool;

use App\Models\User;
use function NovaKit\eloquent_exists;

$user = User::find(5);

return eloquent_exists($user);

NovaKit\table_name(string|\Illuminate\Database\Eloquent\Model $model): string;

use function NovaKit\table_name;

return table_name(App\Models\User::class);

NovaKit\has_ordering(\Laravel\Nova\Http\Requests\NovaRequest $request): bool;

use Laravel\Nova\Http\Requests\NovaRequest;
use function NovaKit\has_ordering;

public static function indexQuery(NovaRequest $request, $query)
{
    if (! has_ordering($request)) {
        $query->orderBy('name');
    }
}

NovaKit\running_action(\Illuminate\Http\Request $request, ?string $action): bool;

use Illuminate\Http\Request;
use Laravel\Nova\Http\Requests\NovaRequest;

public function authorizedToUpdate(Request $request)
{
    if (running_action($request, 'open-on-platform')) {
        return $request->user()->canModerateResources();
    }

    return $this->authorizedTo($request, 'update');
}

NovaKit\is_column_name(mixed $column): bool;

use function NovaKit\is_column_name;

if (is_column_name($request->query('sortBy'))) {
    $query->latest($request->query('sortBy'));
}

NovaKit\safe_int(mixed $value): int|string;

use function NovaKit\safe_int;

return safe_int(9007199254741001); // will return "9007199254741001"

NovaKit\schemaless_url(string $url): string;