paper = new Paper(); } /** * get:/ * @param Request $request * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function mainView(Request $request) { $keyboard = DB::select('SELECT * FROM keyboard'); return view('settings', [ 'keyboard' => $keyboard, 'actions' => $this->getActions() ]); } public function getMappedKeys() { $keys = DB::table('keyboard')->get(); $text = ''; $actions = $this->getActions(''); foreach ($keys as $key) { $text .= '[' . $key->key . '] ' . $actions[$key->action] . "\n"; } return $text; } public function printMappedKeys() { $this->paper->sendPrint('Zmapowane klawisze', $this->getMappedKeys()); } public function save(Request $request) { foreach ($request->input('key') as $keyid => $keyValue) { DB::table('keyboard') ->where('id', $keyid) ->update([ 'action' => $keyValue, ]); } return redirect()->route('settingsList'); } private function getActions($noActionText = 'Bez akcji') { $actions = []; $actions[''] = $noActionText; $actions['separator0'] = 'separator'; $actions['settings_list'] = 'Lista zmapowanych klawiszy'; $actions['separator1'] = 'separator'; $actions['interactivemenu'] = 'Interaktywne menu'; $actions['separator2'] = 'separator'; $actions['repertoire_all_today'] = 'Repertuar wszystkie kina dzisiaj'; $actions['repertoire_all_tomorrow'] = 'Repertuar wszystkie kina jutro'; $actions['repertoire_helios_today'] = 'Repertuar Helios dzisiaj'; $actions['repertoire_helios_tomorrow'] = 'Repertuar Helios jutro'; $actions['repertoire_multikino_today'] = 'Repertuar Multikino dzisiaj'; $actions['repertoire_multikino_tomorrow'] = 'Repertuar Multikino jutro'; $actions['repertoire_cinemacity_today'] = 'Repertuar Cinema-City dzisiaj'; $actions['repertoire_cinemacity_tomorrow'] = 'Repertuar Cinema-City jutro'; $actions['repertoire_gdynskiecentrumfilmowe_today'] = 'Repertuar Gdyńskie Centrum filmowe dzisiaj'; $actions['repertoire_gdynskiecentrumfilmowe_tomorrow'] = 'Repertuar Gdyńskie Centrum filmowe jutro'; $actions['separator3'] = 'separator'; $actions['airly_all'] = 'Airly wszystkie stacje'; $actions['airly_rzeczypospolitej'] = 'Airly (Rzeczypospolitej)'; $actions['airly_grunwaldzka'] = 'Airly (Grunwaldzka)'; $actions['airly_sowinskiego'] = 'Airly (Sowińskiego)'; // $actions['separator3'] = 'separator'; // $actions['spacex_next_flight'] = 'Najbliższy lot SpaceX'; // $actions['spacex_prev_flight'] = 'Poprzedni lot SpaceX'; // $actions['spacex_all_next_summary'] = 'Wszystkie zaplanowane loty SpaceX (skrót)'; $actions['separator5'] = 'separator'; $actions['note_last'] = 'Ostatnia zapisana notatka'; $actions['separator6'] = 'separator'; $notes = DB::select('SELECT * FROM note WHERE type = "note" ORDER BY updated_at DESC'); foreach ($notes as $note) { $actions['note_' . $note->id] = 'Notatka: ' . $note->topic; } return $actions; } }