public function update($id) { $user = User::find($id); if (!$user) { return $this->store(); } $data = Input::all(); if (!isset($data['username'])) { $data['username'] = $data['gebruikersnaam']; } if ($data['username'] == $user->username) { unset($data['username']); } $validator = Validator::make($data, User::$rulesUpdate); $validator->sometimes('function', 'unique:users', function ($input) { return $input->function != ""; }); if ($validator->fails()) { Session::flash('error', 'Er waren fouten met het opslaan'); Debugbar::log($validator->messages()); return Redirect::action('user.edit', $id)->withErrors($validator)->withInput(); } else { $user->username = Input::get('username'); $user->function = Input::get('function'); $user->save(); Session::flash('success', 'Gebruiker is aangepast!'); return Redirect::action('user.edit', $id); } }
function getSongs($perPage = 5) { Debugbar::log(isVoteRunning()); global $artist; $artist = Input::get("artist"); $title = Input::get("title"); $data = Song::where(function ($q) { global $artist; $q->where('artist', 'LIKE', "%{$artist}%"); })->where('title', 'LIKE', "%{$title}%", 'AND')->orderBy('updated_at', 'DESC')->paginate($perPage); return Response::json($data); }
function isVoteRunning() { $vote = Voting::where('created_at', '<', 'date(\'now\')')->whereNull('ended')->first(); Debugbar::log($vote); return !is_null($vote); }