Skip to content

Commit

Permalink
1.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur LORENT committed Sep 13, 2019
1 parent 97023d9 commit cc9953b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
# Changelog

## [1.2.3](https://github.com/Okipa/laravel-table/releases/tag/1.2.3)
2019-09-13
- The model is now directly passed to the route during the table `show`, `edit` and `destroy` routes generation instead of its id.
```php
// assuming your declared your edit route like this :
(new Table)->model(User::class)->routes([
// ...
'edit' => ['name'=> 'user.edit', 'params' => ['foo' => 'bar']],
//...
])
// the route will be generated like this during the table instantiation :
route('user.edit, [$user, 'foo' => 'bar']);
// instead of this way
route('user.edit, [$user->id, 'foo' => 'bar']);
```

## [1.2.2](https://github.com/Okipa/laravel-table/releases/tag/1.2.2)
2019-09-13
- Fixed params order when generating the table routes. The table model id was not positioned at first when declaring other parameters.

```php
// with a route declared like this :
Route::get('user/edit/{user}/{foo}', 'UsersController@edit')->name('user.edit');
Expand Down
1 change: 1 addition & 0 deletions src/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
use Okipa\LaravelTable\Test\Models\User;
use Okipa\LaravelTable\Traits\TableClassesCustomizations;
use Okipa\LaravelTable\Traits\TableColumnsValidationChecks;
use Okipa\LaravelTable\Traits\TableInteractions;
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/RoutesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public function testSetRouteDefinitionWithProvidedId()
return null;
},
]);
app('router')->get('/user/destroy/{id}/{foo}', [
app('router')->post('/user/destroy/{id}/{foo}', [
'as' => 'user.destroy', function () {
return null;
},
Expand Down Expand Up @@ -277,7 +277,7 @@ public function testSetImplicitBindingRoutes()
return null;
},
]);
app('router')->get('/user/destroy/{user}/{foo}', [
app('router')->post('/user/destroy/{user}/{foo}', [
'as' => 'user.destroy', function () {
return null;
},
Expand Down
12 changes: 6 additions & 6 deletions views/bootstrap/tbody.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,34 +77,34 @@
<div class="d-flex justify-content-end">
{{-- show button --}}
@if($table->isRouteDefined('show'))
<form id="show-{{ $model->id }}"
<form id="show-{{ $model->getKey() }}"
role="form"
method="GET"
action="{{ $table->route('show', [$model->id]) }}">
action="{{ $table->route('show', [$model]) }}">
<button{{ classTag('btn', 'btn-link', 'p-0', 'text-primary', $model->disabledClasses ? 'disabled' : null) }} type="submit" title="@lang('laravel-table::laravel-table.show')"{{ htmlAttributes($model->disabledClasses ? ['disabled' => 'disabled'] : null) }}>
{!! config('laravel-table.icon.show') !!}
</button>
</form>
@endif
{{-- edit button --}}
@if($table->isRouteDefined('edit'))
<form id="edit-{{ $model->id }}"
<form id="edit-{{ $model->getKey() }}"
class="ml-2"
role="form"
method="GET"
action="{{ $table->route('edit', [$model->id]) }}">
action="{{ $table->route('edit', [$model]) }}">
<button{{ classTag('btn', 'btn-link', 'p-0', 'text-primary', $model->disabledClasses ? 'disabled' : null) }} type="submit" title="@lang('laravel-table::laravel-table.edit')"{{ htmlAttributes($model->disabledClasses ? ['disabled' => 'disabled'] : null) }}>
{!! config('laravel-table.icon.edit') !!}
</button>
</form>
@endif
{{-- destroy button --}}
@if($table->isRouteDefined('destroy'))
<form id="destroy-{{ $model->id }}"
<form id="destroy-{{ $model->getKey() }}"
class="ml-2 destroy"
role="form"
method="POST"
action="{{ $table->route('destroy', [$model->id]) }}">
action="{{ $table->route('destroy', [$model]) }}">
@csrf()
@method('DELETE')
<button{{ classTag('btn', 'btn-link', 'p-0', 'text-danger', $model->disabledClasses ? 'disabled' : null) }} type="submit" title="@lang('laravel-table::laravel-table.destroy')"{{ htmlAttributes($model->destroyConfirmationAttributes, $model->disabledClasses ? ['disabled' => 'disabled'] : null) }}>
Expand Down

0 comments on commit cc9953b

Please sign in to comment.