Files
kulakpos_web/public/restaurant/app/Console/Commands/NewDataTableMakeCommand.php

47 lines
1.0 KiB
PHP
Raw Normal View History

2026-03-15 17:08:23 +07:00
<?php
namespace App\Console\Commands;
use Illuminate\Console\GeneratorCommand;
use Symfony\Component\Console\Input\InputOption;
class NewDataTableMakeCommand extends GeneratorCommand
{
protected $name = 'make:datatable-file';
protected $description = 'Create a new yajra DataTables class';
protected $type = 'DataTable';
protected function getStub()
{
return resource_path('stubs/datatable.stub');
}
protected function getDefaultNamespace($rootNamespace)
{
return $rootNamespace.'\\DataTables';
}
protected function buildClass($name)
{
$stub = parent::buildClass($name);
$model = $this->option('model');
$namespaceModel = 'App\\Models\\'.$model;
return str_replace(
['DummyModel', 'DummyModelNamespace'],
[$model, $namespaceModel],
$stub
);
}
protected function getOptions()
{
return [
['model', null, InputOption::VALUE_REQUIRED, 'The name of the model'],
];
}
}