Skip to content

Commit

Permalink
Run pint
Browse files Browse the repository at this point in the history
  • Loading branch information
rappasoft committed May 19, 2023
1 parent 3b0bf2a commit 6ad354e
Show file tree
Hide file tree
Showing 96 changed files with 409 additions and 1,840 deletions.
8 changes: 5 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
],
"require": {
"php": "^7.4|^8.0|^8.1|^8.2",
"illuminate/contracts": "^8.0|^9.0|^10.0",
"laravel/pint": "^1.10",
"livewire/livewire": "^2.6",
"spatie/laravel-package-tools": "^1.4.3",
"illuminate/contracts": "^8.0|^9.0|^10.0"
"spatie/laravel-package-tools": "^1.4.3"
},
"require-dev": {
"ext-sqlite3": "*",
Expand All @@ -43,7 +44,8 @@
"scripts": {
"psalm": "vendor/bin/psalm",
"test": "vendor/bin/phpunit --colors=always",
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"
"test-coverage": "vendor/bin/phpunit --coverage-html coverage",
"format": "vendor/bin/pint"
},
"config": {
"sort-packages": true
Expand Down
43 changes: 11 additions & 32 deletions src/Commands/MakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,9 @@

/**
* Class MakeCommand
*
* @package Rappasoft\LaravelLivewireTables\Commands
*/
class MakeCommand extends Command
{
/**
* @var ComponentParser
*/
protected ComponentParser $parser;

/**
Expand Down Expand Up @@ -75,14 +70,9 @@ public function handle(): void

$this->createClass($force);

$this->info('Livewire Datatable Created: ' . $this->parser->className());
$this->info('Livewire Datatable Created: '.$this->parser->className());
}

/**
* @param bool $force
*
* @return bool
*/
protected function createClass(bool $force = false): bool
{
$classPath = $this->parser->classPath();
Expand All @@ -101,9 +91,7 @@ protected function createClass(bool $force = false): bool
}

/**
* @param mixed $path
*
* @return void
* @param mixed $path
*/
protected function ensureDirectoryExists($path): void
{
Expand All @@ -112,9 +100,6 @@ protected function ensureDirectoryExists($path): void
}
}

/**
* @return string
*/
public function classContents(): string
{
return str_replace(
Expand All @@ -124,35 +109,29 @@ public function classContents(): string
);
}

/**
* @return string
*/
public function getModelImport(): string
{
if (File::exists(app_path('Models/' . $this->model . '.php'))) {
return 'App\Models\\' . $this->model;
if (File::exists(app_path('Models/'.$this->model.'.php'))) {
return 'App\Models\\'.$this->model;
}

if (File::exists(app_path($this->model . '.php'))) {
return 'App\\' . $this->model;
if (File::exists(app_path($this->model.'.php'))) {
return 'App\\'.$this->model;
}

if (isset($this->modelPath)) {
if (File::exists(rtrim($this->modelPath, "/")."/".$this->model . '.php')) {
if (File::exists(rtrim($this->modelPath, '/').'/'.$this->model.'.php')) {

return Str::studly(str_replace("/", "\\", $this->modelPath)) . $this->model;
return Str::studly(str_replace('/', '\\', $this->modelPath)).$this->model;
}
}


$this->error('Could not find path to model.');

return 'App\Models\\' . $this->model;
return 'App\Models\\'.$this->model;
}

/**
* @param string $modelName
* @return string
* @throws \Exception
*/
private function generateColumns(string $modelName): string
Expand All @@ -178,10 +157,10 @@ private function generateColumns(string $modelName): string

$title = Str::of($field)->replace('_', ' ')->ucfirst();

$columns .= ' Column::make("' . $title . '", "' . $field . '")' . "\n" . ' ->sortable(),' . "\n";
$columns .= ' Column::make("'.$title.'", "'.$field.'")'."\n".' ->sortable(),'."\n";
}

$columns .= " ]";
$columns .= ' ]';

return $columns;
}
Expand Down
8 changes: 2 additions & 6 deletions src/DataTableComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function boot(): void
'filters' => $this->{$this->tableName}['filters'] ?? [],
'columns' => $this->{$this->tableName}['columns'] ?? [],
];

}

/**
Expand Down Expand Up @@ -106,8 +106,6 @@ abstract public function configure(): void;

/**
* The array defining the columns of the table.
*
* @return array
*/
abstract public function columns(): array;

Expand All @@ -125,14 +123,12 @@ public function builder(): Builder

/**
* The view to add any modals for the table, could also be used for any non-visible html
*
* @return string
*/
public function customView(): string
{
return 'livewire-tables::stubs.custom';
}

/**
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
Expand Down
1 change: 1 addition & 0 deletions src/Events/ColumnsSelected.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class ColumnsSelected
use Dispatchable, SerializesModels;

public $columns;

public $key;

public function __construct($key, $columns)
Expand Down
3 changes: 0 additions & 3 deletions src/LaravelLivewireTablesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

class LaravelLivewireTablesServiceProvider extends PackageServiceProvider
{
/**
* @param Package $package
*/
public function configurePackage(Package $package): void
{
$package
Expand Down
30 changes: 27 additions & 3 deletions src/Traits/ComponentUtilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,59 @@ trait ComponentUtilities
ComponentHelpers;

public array $table = [];

public $theme = null;

protected Builder $builder;

protected $model;

protected $primaryKey;

protected array $relationships = [];

protected string $tableName = 'table';

protected ?string $dataTableFingerprint;

protected ?string $queryStringAlias;

protected bool $queryStringStatus = true;

protected bool $offlineIndicatorStatus = true;

protected bool $eagerLoadAllRelationsStatus = false;

protected array $componentWrapperAttributes = [];

protected array $tableWrapperAttributes = [];

protected array $tableAttributes = [];

protected array $theadAttributes = [];

protected array $tbodyAttributes = [];

protected $thAttributesCallback;

protected $thSortButtonAttributesCallback;

protected $trAttributesCallback;

protected $trUrlCallback;

protected $trUrlTargetCallback;

protected $tdAttributesCallback;

protected $collapsingColumnsStatus = true;

protected string $emptyMessage = 'No items found. Try to broaden your search.';

protected array $additionalSelects = [];

protected bool $hideConfigurableAreasWhenReorderingStatus = true;

protected array $configurableAreas = [
'before-tools' => null,
'toolbar-left-start' => null,
Expand Down Expand Up @@ -69,9 +96,6 @@ public function queryString(): array

/**
* Keep track of any properties on the custom query string key for this specific table
*
* @param $name
* @param $value
*/
public function updated($name, $value): void
{
Expand Down
35 changes: 0 additions & 35 deletions src/Traits/Configuration/BulkActionsConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ trait BulkActionsConfiguration
{
/**
* @param array<mixed> $bulkActions
*
* @return self
*/
public function setBulkActions(array $bulkActions): self
{
Expand All @@ -16,95 +14,62 @@ public function setBulkActions(array $bulkActions): self
return $this;
}

/**
* @param bool $status
*
* @return self
*/
public function setBulkActionsStatus(bool $status): self
{
$this->bulkActionsStatus = $status;

return $this;
}

/**
* @return self
*/
public function setBulkActionsEnabled(): self
{
$this->setBulkActionsStatus(true);

return $this;
}

/**
* @return self
*/
public function setBulkActionsDisabled(): self
{
$this->setBulkActionsStatus(false);

return $this;
}

/**
* @param bool $status
*
* @return self
*/
public function setSelectAllStatus(bool $status): self
{
$this->selectAll = $status;

return $this;
}

/**
* @return self
*/
public function setSelectAllEnabled(): self
{
$this->setSelectAllStatus(true);

return $this;
}

/**
* @return self
*/
public function setSelectAllDisabled(): self
{
$this->setSelectAllStatus(false);

return $this;
}

/**
* @param bool $status
*
* @return self
*/
public function setHideBulkActionsWhenEmptyStatus(bool $status): self
{
$this->hideBulkActionsWhenEmpty = $status;

return $this;
}

/**
* @return self
*/
public function setHideBulkActionsWhenEmptyEnabled(): self
{
$this->setHideBulkActionsWhenEmptyStatus(true);

return $this;
}

/**
* @return self
*/
public function setHideBulkActionsWhenEmptyDisabled(): self
{
$this->setHideBulkActionsWhenEmptyStatus(false);
Expand Down
Loading

0 comments on commit 6ad354e

Please sign in to comment.