public function delete($id) { \App\Event::where('id', $id)->delete(); \App\EventMedia::where('eventID', $id)->delete(); \App\EventTag::where('eventID', $id)->delete(); return redirect('/'); }
public function run() { $tags = array(array(1, 'Community Service', 'CO', 'Any service event recieves this tag. Each member must do at least 60 minutes of work to count. This includes round trip travel time. Service planning recieves an Administrative tag as well.'), array(1, 'Campus Service', 'CA', 'Service organized/completed by home campus.'), array(1, 'Continuing Service', 'CS', 'Participation in the same project with another organization that occured once a month for at least two additional months previously. On the third month an event becomes continuing. It continues to count as long as it continues to occurs at least once a month.'), array(1, 'District Service Initiative', 'DSI', 'For the 2014-2015 year, an event that falls under the "Leaping Towards Literacy" Definition.'), array(1, 'International Service Initiative', 'ISI', 'The International Service Initiative is "Focusing on the Future: Children."'), array(2, 'Administrative', 'AD', 'Administrative hours include, but are not limited to tabling, calling coordinators for events. Attending general meetings, Committee meetings & Kiwanis meetings are administrative, so all have the AD Tag. Service-based committees (ex: Single Service Committee) are both CO & AD.'), array(3, 'Social', 'SE', 'A social promotes the moral of members and is for all events that do not fall under Administrative and Community Service.'), array(4, 'Membership Development & Education', 'MD', 'Event that develops membership recruitment growth, retention & education. Ex: Workshops, tabling, recruitment fairs, education sessions. NOT ALL SOCIAL EVENTS ARE MD. Only Family, MD&E, retreats, and socials with leadership aspects count as both Social and MD.'), array(4, 'Fundraising', 'FR', 'Event that raises money for a cause either for charity or for administrative purposes.'), array(4, 'Circle K', 'CK', 'Event with 2 members from your CKI Club and another 2 from another CKI Club present.'), array(4, 'Kiwanis Family', 'KF', 'Event with 2 members from your CKI Club & 2 from another Kiwanis Family Club excluding CKI.'), array(4, 'Interclub', 'IN', 'Clubs with < 21 members need at least 2 members in attendance from your own & another KF/CK Club, 21-30 members need 3, and > 30 members need at least 4 members. The club who hosted the event does not receive an Interclub tag unless the event is service though other clubs do.'), array(4, 'Webinar', 'WB', 'Event hosted by a District Board Officer presented via online webinar. These events only receive the Webinar (WB) tag and Administrative (AD) tag.'), array(4, 'Divisional Event', 'DV', 'Event hosted by and for the Division (usually Lt. Governor).'), array(4, 'District Event', 'DE', 'Event hosted by the District.'), array(4, 'International Event', 'IE', 'Event hosted by Circle K International. Usually only LSSP & ICON.'), array(4, 'Club Hosted', 'HE', 'Event hosted by home club. Any event not hosted by another Kiwanis Family Club/Circle K.')); foreach ($tags as $tag) { EventTag::create(array('category_id' => $tag[0], 'name' => $tag[1], 'abbreviation' => $tag[2], 'description' => $tag[3])); } }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(CreateTagRequest $request) { $input = $request->all(); $tagAbbreviations = []; /* * Some events may have tags in all four categories, and while an event * event has to have a tag in at least one of the service, leadership, * or fellowship categories, an event might not have a tag in all, so * check and merge into one array with all tags for reduced code * repetition. */ if (array_key_exists('service_tags', $input)) { $tagAbbreviations = array_merge($tagAbbreviations, $input['service_tags']); } if (array_key_exists('admin_tags', $input)) { $tagAbbreviations = array_merge($tagAbbreviations, $input['admin_tags']); } if (array_key_exists('social_tags', $input)) { $tagAbbreviations = array_merge($tagAbbreviations, $input['social_tags']); } if (array_key_exists('misc_tags', $input)) { $tagAbbreviations = array_merge($tagAbbreviations, $input['misc_tags']); } /* * Iterates through all tags selected and queries database with * abbreviation to find appropriate tag ID. Each tag abbreviation is * unique, so no need to check. */ foreach ($tagAbbreviations as $abbreviation) { $tag = Tag::where('abbreviation', $abbreviation)->first(); /* * An additional cerf_id column was added to this pivot table * because there may be multiple CERFs for an event and until one * CERF is approved (so that all other CERFs are deleted) there are * duplicate event_id and tag_id combinations in the pivot table. * In order to avoid duplicate tags being listed when looking at * the tags attribute, all entries are associated with a cerf_id * foreign key. When the tags for an event looked up, the tags for * the event according to only one CERF is looked up (see tags * relation in Event model), so no duplicates are listed since the * CERF form is the only way for a user to associate an event with * a tag. */ DB::statement('insert into events_assigned_tags (event_id, tag_id, cerf_id, approved) values (' . session()->get('event_id') . ', ' . $tag->id . ', ' . session()->get('cerf_id') . ', ' . 'false);'); } return redirect()->action('ActivitiesController@create'); }
public function index() { /* Get data for timeline */ $eventDates = \App\Event::select('timelineDate')->distinct()->get()->pluck('timelineDate')->toArray(); $mediaDates = \App\Media::select('timelineDate')->distinct()->get()->pluck('timelineDate')->toArray(); $dates = array_unique(array_merge($eventDates, $mediaDates), SORT_REGULAR); usort($dates, array('\\App\\Http\\Controllers\\TimelineController', 'dateCompare')); $media = array(); $events = array(); foreach ($dates as $date) { $eventsForThisDate = \App\Event::get()->where('timelineDate', $date)->toArray(); $mediaForThisDate = \App\Media::get()->where('timelineDate', $date)->toArray(); usort($eventsForThisDate, array('\\App\\Http\\Controllers\\TimelineController', 'itemCompare')); usort($mediaForThisDate, array('\\App\\Http\\Controllers\\TimelineController', 'itemCompare')); $media[$date] = $mediaForThisDate; $events[$date] = $eventsForThisDate; } /* Get data for filters */ $mediums = \App\Media::select('medium')->distinct()->get()->pluck('medium')->toArray(); $tags = \App\EventTag::select('tag')->distinct()->get()->pluck('tag')->toArray(); $series = \App\Series::get()->pluck('seriesAbbreviation'); sort($mediums); sort($tags); $eventIDToTags = array(); $eventIDs = \App\Event::get()->pluck('id'); foreach ($eventIDs as $eventID) { $eventIDToTags[$eventID] = \App\EventTag::select('tag')->where('eventID', $eventID)->get()->pluck('tag')->toArray(); } $seriesToCollections = array(); foreach ($series as $thisSeries) { $seriesToCollections[$thisSeries] = \App\Media::select('collection')->where('series', $thisSeries)->distinct()->get()->pluck('collection')->toArray(); } /* Get event-media relationships */ $eventMediaPairs = \App\EventMedia::get(array('eventID', 'mediaID'))->toArray(); return view('timeline')->with(['seriesToCollections' => $seriesToCollections, 'eventMediaPairs' => $eventMediaPairs, 'eventIDToTags' => $eventIDToTags, 'mediums' => $mediums, 'events' => $events, 'dates' => $dates, 'media' => $media, 'tags' => $tags]); }