/** * Define your route model bindings, pattern filters, etc. * * @param \Illuminate\Routing\Router $router * @return void */ public function boot(Router $router) { parent::boot($router); \Route::bind('category', function ($value) { return \App\Model\Option::where('id', $value)->first(); }); }
public function postLunbo() { $options = $this->request()->only(['lb_image1', 'lb_url1', 'lb_title1', 'lb_image2', 'lb_url2', 'lb_title2', 'lb_image3', 'lb_url3', 'lb_title3']); try { transaction(); foreach ($options as $key => $option) { Option::where('key', $key)->update(['value' => $option]); } commit(); return $this->success('保存成功'); } catch (\Exception $exception) { rollback(); } return $this->error('修改失败,请稍后再试'); }