1. Go to this page and download the library: Download farsi/nova-command-center 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/ */
farsi / nova-command-center example snippets
use Farsi\NovaCommandCenter\CommandCenter;
public function tools(): array
{
return [
(new CommandCenter)->canSee(function ($request) {
return $request->user()?->isAdmin() ?? false;
}),
];
}
'source' => [
'driver' => 'config', // 'config' (default), 'database', or a custom class-string
'model' => \Farsi\NovaCommandCenter\Models\Command::class,
],
use Farsi\NovaCommandCenter\Contracts\CommandSource;
final class YamlCommandSource implements CommandSource
{
public function definitions(): iterable
{
return yaml_parse_file(base_path('commands.yaml'));
}
}
// config/nova-command-center.php
'source' => ['driver' => YamlCommandSource::class],
'source' => ['driver' => 'database'],
use Farsi\NovaCommandCenter\Nova\Command;
Nova::resources([Command::class]);
use Farsi\NovaCommandCenter\Concerns\InteractsWithProgress;
class RebuildSearchIndex extends Command
{
use InteractsWithProgress;
public function handle(): int
{
$this->novaProgressStart($items->count());
foreach ($items as $item) {
// ...
$this->novaProgressAdvance();
}
$this->novaProgressFinish('Done');
return self::SUCCESS;
}
}