generated from liutk/owl-admin-base
41 lines
999 B
PHP
41 lines
999 B
PHP
<?php
|
|
|
|
namespace App\Admin\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Arr;
|
|
use Slowlyo\OwlAdmin\Controllers\AdminController as Controller;
|
|
use App\Traits\CustomActionTrait;
|
|
|
|
/**
|
|
* @property \App\Admin\Services\BaseService $service
|
|
*/
|
|
abstract class AdminController extends Controller
|
|
{
|
|
use CustomActionTrait;
|
|
|
|
public function update(Request $request)
|
|
{
|
|
$input = Arr::except($request->all(), $this->service->primaryKey());
|
|
|
|
if ($request->filled('_fields')) {
|
|
$input = Arr::only($input, explode(',', $request->input('_fields')));
|
|
}
|
|
|
|
$result = $this->service->update($this->getPrimaryValue($request), $input);
|
|
|
|
return $this->autoResponse($result, __('admin.save'));
|
|
}
|
|
|
|
public function getQuickEditItemPath(array $fields = ['*'])
|
|
{
|
|
$path = $this->getUpdatePath();
|
|
|
|
if ($fields != ['*']) {
|
|
$path .= '?_fields='.implode(',', $fields);
|
|
}
|
|
|
|
return $path;
|
|
}
|
|
}
|