Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
rappasoft committed Jun 16, 2020
2 parents 97576bb + 32a289e commit fc3014e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to `laravel-livewire-tables` will be documented in this file

## [Unreleased]

## [0.1.6] - 2020-06-15

### Changed

- Add second parameter to view method for the name of the model variable available in the view.

## [0.1.5] - 2020-05-26

### Changed
Expand Down Expand Up @@ -40,7 +46,8 @@ All notable changes to `laravel-livewire-tables` will be documented in this file

- Initial release

[Unreleased]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.5...development
[Unreleased]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.6...development
[0.1.6]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.5...v0.1.6
[0.1.5]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.4...v0.1.5
[0.1.4]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.3...v0.1.4
[0.1.3]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.2...v0.1.3
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function customAttribute() : self;
/**
* This view will be used for the column, can still be used with sortable and searchable.
*/
public function view($view) : self;
public function view($view, $viewModelName = 'model') : self;
```

### Properties
Expand Down
2 changes: 1 addition & 1 deletion resources/views/includes/_body.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class="{{ $this->setTableDataClass($column->attribute, Arr::get($model->toArray(
@endforeach
@endif
@elseif ($column->isView())
@include($column->view)
@include($column->view, [$column->getViewModelName() => $model])
@else
@if ($column->isHtml())
@if ($column->isCustomAttribute())
Expand Down
18 changes: 17 additions & 1 deletion src/Views/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ class Column
*/
protected $view;

/**
* The name of the model variable passed to the view
*
* @var string
*/
protected $viewModelName;

/**
* Column constructor.
*
Expand Down Expand Up @@ -215,16 +222,18 @@ public function isCustomAttribute(): bool

/**
* @param $view
* @param string $viewModelName
*
* @return $this
*/
public function view($view): self
public function view($view, $viewModelName = 'model'): self
{
if ($this->hasComponents()) {
return $this;
}

$this->view = $view;
$this->viewModelName = $viewModelName;

return $this;
}
Expand All @@ -236,4 +245,11 @@ public function isView(): bool
{
return view()->exists($this->view);
}

/**
* @return string
*/
public function getViewModelName() {
return $this->viewModelName;
}
}

0 comments on commit fc3014e

Please sign in to comment.