74 lines
1.5 KiB
PHP
74 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Merchant;
|
|
|
|
use App\Models\MerchantRatio;
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Controllers\Controller;
|
|
|
|
class BaseDefaultController extends BaseController
|
|
{
|
|
//
|
|
public function index()
|
|
{
|
|
|
|
return $this->display($this->indexData());
|
|
}
|
|
public function apiJson(Request $request){
|
|
$json = [
|
|
'total' => 0,
|
|
'rows' => []
|
|
];
|
|
return response($json);
|
|
}
|
|
public function store(Request $request)
|
|
{
|
|
$permission = $this->setModel();
|
|
return $this->saveData($request,$permission);
|
|
|
|
}
|
|
public function show($id)
|
|
{
|
|
return $this->getShow($id);
|
|
}
|
|
public function create(){
|
|
return $this->display($this->shareData());
|
|
}
|
|
|
|
/**
|
|
* 查看和编辑都需要设置这个,还有更新
|
|
* @param $show
|
|
* @return bool
|
|
*/
|
|
public function checkSelf($show){
|
|
|
|
//
|
|
|
|
$pids=MerchantRatio::where('merchant_id', $show->id)->pluck('parent_id')->toArray();
|
|
|
|
|
|
|
|
if(in_array($this->getMerchantId(),$pids))
|
|
{
|
|
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
public function edit($id){
|
|
|
|
return $this->getShow($id);
|
|
}
|
|
public function update(Request $request, $id)
|
|
{
|
|
$model = $this->setModel();
|
|
$model = $model->findOrFail($id);
|
|
//检查是否是自己的不
|
|
if(!$this->checkSelf($model)){
|
|
return abort(404);
|
|
}
|
|
return $this->saveData($request,$model,$id);
|
|
|
|
}
|
|
}
|