function show() { $venues = Venue::all(); $select_timings = Timing::lists('artist_name', 'artist_name'); $title = "Plan by Time"; $user = Auth::user(); $already_selected_timings = []; // if logged in then set this to an actual array if ($user !== null) { $already_selected_timings = $user->timings->lists('artist_name', 'artist_name')->toArray(); } return view('bytime', compact('venues', 'select_timings', 'already_selected_timings', 'title')); }
function show() { $timings = Timing::orderBy('artist_name', 'asc')->get(); $select_timings = Timing::lists('artist_name', 'artist_name'); $title = "Plan by Artist"; $user = Auth::user(); $already_selected_timings = []; // if logged in then set this to an actual array if ($user !== null) { $already_selected_timings = $user->timings->lists('artist_name', 'artist_name')->toArray(); } return view('byartist', compact('timings', 'select_timings', 'already_selected_timings', 'title')); }
private function syncTimings(User $user, array $selected_timings) { $timings = Timing::whereIn('artist_name', $selected_timings)->get(); $user->timings()->sync($timings); }
public function timings() { return Timing::where('venue_name', '=', $this->name)->get(); }