Skip to content

Commit f58ff76

Browse files
committed
- Update namespace
- Add components (button and link)
1 parent 2a0d873 commit f58ff76

24 files changed

+502
-31
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ namespace App\Http\Livewire;
3131

3232
use App\User;
3333
use Illuminate\Database\Eloquent\Builder;
34-
use Rappasoft\LivewireTables\Http\Livewire\Column;
35-
use Rappasoft\LivewireTables\Http\Livewire\TableComponent;
34+
use Rappasoft\LaravelLivewireTables\Views\Column;
35+
use Rappasoft\LaravelLivewireTables\TableComponent;
3636

3737
class UsersTable extends TableComponent
3838
{

composer.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,25 @@
2727
},
2828
"autoload": {
2929
"psr-4": {
30-
"Rappasoft\\LivewireTables\\": "src"
30+
"Rappasoft\\LaravelLivewireTables\\": "src"
3131
}
3232
},
3333
"autoload-dev": {
3434
"psr-4": {
35-
"Rappasoft\\LivewireTables\\Tests\\": "tests"
35+
"Rappasoft\\LaravelLivewireTables\\Tests\\": "tests"
3636
}
3737
},
3838
"scripts": {
3939
"test": "vendor/bin/phpunit",
4040
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"
41-
4241
},
4342
"config": {
4443
"sort-packages": true
4544
},
4645
"extra": {
4746
"laravel": {
4847
"providers": [
49-
"Rappasoft\\LivewireTables\\LivewireTablesServiceProvider"
48+
"Rappasoft\\LaravelLivewireTables\\LivewireTablesServiceProvider"
5049
]
5150
}
5251
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<button type="button"
2+
@foreach ($attributes as $key => $value)
3+
{{ $key }}="{{ $value }}"
4+
@endforeach
5+
>
6+
@if (array_key_exists('icon', $options))
7+
<i class="{{ $options['icon'] }}"></i>
8+
@endif
9+
10+
{{ $options['text'] ?? '' }}
11+
</button>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<a
2+
@foreach ($attributes as $key => $value)
3+
@if ($key === 'href' && is_callable($value))
4+
{{ $key }}="{{ app()->call($value, ['model' => $model]) }}"
5+
@else
6+
{{ $key }}="{{ $value }}"
7+
@endif
8+
@endforeach
9+
>
10+
@if (array_key_exists('icon', $options))
11+
<i class="{{ $options['icon'] }}"></i>
12+
@endif
13+
14+
{{ $options['text'] ?? '' }}
15+
</a>

resources/views/includes/_body.blade.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
<tr
77
class="{{ $this->setTableRowClass($model) }}"
88
id="{{ $this->setTableRowId($model) }}"
9-
@foreach ($this->setTableRowAttributes($model) as $key => $value) {{ $key . '="'.$value.'"' }} @endforeach
9+
@foreach ($this->setTableRowAttributes($model) as $key => $value)
10+
{{ $key }}="{{ $value }}"
11+
@endforeach
1012
>
1113
@if($checkbox && $checkboxLocation === 'left')
1214
@include('laravel-livewire-tables::includes._checkbox-row')
@@ -16,9 +18,25 @@ class="{{ $this->setTableRowClass($model) }}"
1618
<td
1719
class="{{ $this->setTableDataClass($column->attribute, Arr::get($model->toArray(), $column->attribute)) }}"
1820
id="{{ $this->setTableDataId($column->attribute, Arr::get($model->toArray(), $column->attribute)) }}"
19-
@foreach ($this->setTableDataAttributes($column->attribute, Arr::get($model->toArray(), $column->attribute)) as $key => $value) {{ $key . '="'.$value.'"' }} @endforeach
21+
@foreach ($this->setTableDataAttributes($column->attribute, Arr::get($model->toArray(), $column->attribute)) as $key => $value)
22+
{{ $key }}="{{ $value }}"
23+
@endforeach
2024
>
21-
@if ($column->isView())
25+
@if ($column->hasComponents())
26+
@if ($column->componentsAreHiddenForModel($model))
27+
@if ($message = $column->componentsHiddenMessageForModel($model))
28+
{{ $message }}
29+
@else
30+
&nbsp;&nbsp;
31+
@endif
32+
@else
33+
@foreach($column->getComponents() as $component)
34+
@if (! $component->isHidden())
35+
@include($component->view(), ['model' => $model, 'attributes' => $component->getAttributes(), 'options' => $component->getOptions()])
36+
@endif
37+
@endforeach
38+
@endif
39+
@elseif ($column->isView())
2240
@include($column->view)
2341
@else
2442
@if ($column->isHtml())

resources/views/includes/_columns.blade.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
<th
77
class="{{ $this->setTableHeadClass($column->attribute) }}"
88
id="{{ $this->setTableHeadId($column->attribute) }}"
9-
@foreach ($this->setTableHeadAttributes($column->attribute) as $key => $value) {{ $key . '="'.$value.'"' }} @endforeach
9+
@foreach ($this->setTableHeadAttributes($column->attribute) as $key => $value)
10+
{{ $key }}="{{ $value }}"
11+
@endforeach
1012
>
1113
@if($column->sortable)
1214
<span style="cursor: pointer;" wire:click="sort('{{ $column->attribute }}')">

src/LivewireTablesServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Rappasoft\LivewireTables;
3+
namespace Rappasoft\LaravelLivewireTables;
44

55
use Illuminate\Support\ServiceProvider;
66

src/Http/Livewire/TableComponent.php renamed to src/TableComponent.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<?php
22

3-
namespace Rappasoft\LivewireTables\Http\Livewire;
3+
namespace Rappasoft\LaravelLivewireTables;
44

55
use Illuminate\Database\Eloquent\Builder;
66
use Illuminate\Support\Str;
77
use Illuminate\View\View;
88
use Livewire\Component;
99
use Livewire\WithPagination;
10-
use Rappasoft\LivewireTables\Http\Livewire\Traits\Checkboxes;
11-
use Rappasoft\LivewireTables\Http\Livewire\Traits\Loading;
12-
use Rappasoft\LivewireTables\Http\Livewire\Traits\Offline;
13-
use Rappasoft\LivewireTables\Http\Livewire\Traits\Pagination;
14-
use Rappasoft\LivewireTables\Http\Livewire\Traits\Search;
15-
use Rappasoft\LivewireTables\Http\Livewire\Traits\Sorting;
16-
use Rappasoft\LivewireTables\Http\Livewire\Traits\Table;
17-
use Rappasoft\LivewireTables\Http\Livewire\Traits\Yajra;
10+
use Rappasoft\LaravelLivewireTables\Traits\Checkboxes;
11+
use Rappasoft\LaravelLivewireTables\Traits\Loading;
12+
use Rappasoft\LaravelLivewireTables\Traits\Offline;
13+
use Rappasoft\LaravelLivewireTables\Traits\Pagination;
14+
use Rappasoft\LaravelLivewireTables\Traits\Search;
15+
use Rappasoft\LaravelLivewireTables\Traits\Sorting;
16+
use Rappasoft\LaravelLivewireTables\Traits\Table;
17+
use Rappasoft\LaravelLivewireTables\Traits\Yajra;
1818

1919
/**
2020
* Class TableComponent.

src/Traits/CanBeHidden.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
namespace Rappasoft\LaravelLivewireTables\Traits;
4+
5+
/**
6+
* Trait CanBeHidden.
7+
*/
8+
trait CanBeHidden
9+
{
10+
11+
/**
12+
* @var bool
13+
*/
14+
protected $hidden = false;
15+
16+
/**
17+
* @param $condition
18+
*
19+
* @return $this
20+
*/
21+
public function hideIf($condition) : self {
22+
$this->hidden = $condition === true;
23+
24+
return $this;
25+
}
26+
27+
/**
28+
* @param bool $hidden
29+
*
30+
* @return $this
31+
*/
32+
public function hide($hidden = true) : self {
33+
$this->hidden = $hidden;
34+
35+
return $this;
36+
}
37+
38+
/**
39+
* @return bool
40+
*/
41+
public function isHidden() : bool {
42+
return $this->hidden;
43+
}
44+
}

src/Http/Livewire/Traits/Checkboxes.php renamed to src/Traits/Checkboxes.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Rappasoft\LivewireTables\Http\Livewire\Traits;
3+
namespace Rappasoft\LaravelLivewireTables\Traits;
44

55
/**
66
* Trait Checkboxes.
@@ -46,6 +46,9 @@ trait Checkboxes
4646
*/
4747
public $checkboxValues = [];
4848

49+
/**
50+
*
51+
*/
4952
public function updatedCheckboxAll()
5053
{
5154
$this->checkboxValues = [];
@@ -57,6 +60,9 @@ public function updatedCheckboxAll()
5760
}
5861
}
5962

63+
/**
64+
*
65+
*/
6066
public function updatedCheckboxValues()
6167
{
6268
$this->checkboxAll = false;

0 commit comments

Comments
 (0)