stub of the row editor

This commit is contained in:
2018-08-05 14:45:43 +02:00
parent e17548e5e7
commit bb8bc459dc
34 changed files with 724 additions and 175 deletions
+22 -9
View File
@@ -22,7 +22,9 @@ use Illuminate\Database\Eloquent\Collection;
* @property string $origin
* @property int $visits
* @property-read string $viewRoute
* @property-read string $draftRoute
* @property-read string $settingsRoute
* @property-read string $deleteRoute
* @property-read User $owner
* @property-read Table $parentTable
* @property-read Table[]|Collection $forks
@@ -123,21 +125,32 @@ class Table extends BaseModel
public function __get($name)
{
if ($name == 'viewRoute') {
return route('table.view', ['user' => $this->cachedOwner()->name, 'table' => $this->name]);
}
if (ends_with($name, 'Route')) {
$arg = [
'user' => $this->cachedOwner()->name,
'table' => $this->name
];
if ($name == 'settingsRoute') {
return route('table.conf', ['user' => $this->cachedOwner()->name, 'table' => $this->name]);
}
if ($name == 'deleteRoute') {
return route('table.delete', ['user' => $this->cachedOwner()->name, 'table' => $this->name]);
switch ($name) {
case 'viewRoute': return route('table.view', $arg);
case 'settingsRoute': return route('table.conf', $arg);
case 'draftRoute': return route('table.draft', $arg);
case 'deleteRoute': return route('table.delete', $arg);
}
}
return parent::__get($name);
}
public function getDraftRoute($tab=null)
{
return route('table.draft', [
'user' => $this->cachedOwner()->name,
'table' => $this->name,
'tab' => $tab,
]);
}
public function scopeForList(Builder $query)
{
return $query->with('revision:id,row_count')->with('owner:id,name,title')