/**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     //
     parent::boot($router);
     $router->bind('houselight', function ($id) {
         return \App\HouseLight::findOrFail($id);
     });
     $router->bind('lightsettings', function ($id) {
         return \App\LightSetting::findOrFail($id);
     });
 }
Пример #2
0
 public function testLightColorChange()
 {
     $this->initialise();
     $this->testLightOn();
     $light = HouseLight::where('light_id', 1)->first();
     $this->assertInstanceOf('App\\HouseLight', $light);
     $color = LightSetting::all()->random(1);
     $this->assertInstanceOf('App\\LightSetting', $color);
     $job = new SetLightColor($light->light_id, $color->x, $color->y);
     $this->dispatch($job);
     $this->seeInDatabase('lights', ['light_id' => $light->light_id, 'state' => '1', 'xy' => $color->x . ',' . $color->y]);
     $this->testLightOff();
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(LightSetting $lightsetting, LightSettingRequest $request)
 {
     $lightsetting->update($request->all());
     return redirect('lightsettings');
 }
 public function colorchange_setting(Request $request, HouseLight $houselight)
 {
     $setting = LightSetting::findOrFail($request->input('lightsetting'));
     return $this->colorchange_xy($houselight, $setting->x, $setting->y);
 }