/** * Remove the specified resource from storage. * * @param int $id ID of the screen to destroy * @return \Illuminate\Http\Response */ public function destroy($id) { $user = Session::get('user'); // Only supoer users are allowed to delete screens if ($user->is_super_user == false) { abort(401, 'Unauthorized'); } // Load selected screen $screen = Screen::find($id); if ($screen == null) { return redirect()->route('dashboard.settings.screens.index')->with('message', 'Error: Screen not found'); } // Delete $screen->delete(); return redirect()->route('dashboard.settings.screens.index')->with('message', 'Screen deleted successfully'); }
/** * Calls loadPlaylist and getGlobal to pass back any changes to the client * @param int $id * @return \Illuminate\Http\Response */ public function sync($id) { // Load the selected screen $screen = Screen::find($id); if (isset($screen) == false) { return response('Not found', 404); } // Eager load playlists $data = $this->loadPlaylists($screen); $adverts = $this->applySchedule($data->location->playlist->adverts); $data = array('screen' => $screen, 'playlist' => $data->location->playlist, 'adverts' => $adverts, 'global' => $this->getGlobal()); return $data; }