public function getActiveEvents() { if (is_null($this->userParentOrganizationId)) { return $this->model->where('end_date', '>=', BaseDateTime::now())->where('published', true)->orderBy('start_date', 'asc')->get(); } else { return PartnerOrganization::find($this->userOrganizationId)->events()->orderBy('start_date', 'asc')->get(); } }
private function goToModeratorDashboard() { $organizationId = Auth::user()->organization_id; // If the moderator belongs to a Partner Organization if (Auth::user()->organization()->first()->isChild()) { $events = PartnerOrganization::find($organizationId)->events()->get(); } else { $events = $this->events->getActiveEvents(); //$events = Event::where('organization_id', $organizationId)->get(); } return view('admin.dashboard.index', compact('events')); }
private function updateEvent() { if ($this->request->hasFile('image')) { $extension = $this->request->file('image')->getClientOriginalExtension(); $image_path = 'images/public/' . $this->banner_img_prefix . $this->event->id . '.' . $extension; // Set Image Path in DB $this->event->img_url = $image_path; $image_path = public_path() . '/' . $image_path; $thumbnail_path = 'images/public/' . $this->banner_thumbnail_prefix . $this->event->id . '.' . $extension; $thumbnail_path = public_path() . '/' . $thumbnail_path; // Delete any existing files first File::delete($thumbnail_path); File::delete($image_path); $banner = Image::make($this->request->file('image'))->save($image_path); $thumbnail = Image::make($this->request->file('image'))->resize(450, 300)->save($thumbnail_path); } $this->event->title = $this->request->input('event.title'); $this->event->description = $this->request->input('event.description'); $this->event->start_date = $this->request->input('event.start_date'); $this->event->end_date = $this->request->input('event.end_date'); $this->event->start_time = $this->request->input('event.start_time'); $this->event->end_time = $this->request->input('event.end_time'); $this->event->price = $this->request->input('event.cost'); $this->event->capacity = $this->request->input('event.capacity'); $this->event->private = $this->request->input('event_privacy') == 'private'; $this->event->published = $this->publish; $this->event->save(); // 2. Save Event Location Information $eventSite = $this->event->eventsite()->first(); $eventSite->name = $this->request->input('eventsite.name'); $eventSite->address = $this->request->input('eventsite.address'); $eventSite->city = $this->request->input('eventsite.city'); $eventSite->state = $this->request->input('eventsite.state'); $eventSite->zipcode = $this->request->input('eventsite.zipcode'); $eventSite->save(); // 3. Detach all Partner Organizations set for this Event $orgRepo = new OrganizationRepository(new Organization()); $partnerOrganizations = $orgRepo->getPartnerOrganizations($this->event->organization()->first()->id); foreach ($partnerOrganizations as $partnerOrg) { $this->event->partners()->detach($partnerOrg); } // 4. Add select Partner Organizations to the Event if (!is_null($this->request->input('partners'))) { foreach ($this->request->input('partners') as $selectedPartners) { $partner = PartnerOrganization::find($selectedPartners); $this->event->partners()->attach($partner); } } }
public function testPartnerOrganization() { $org = PartnerOrganization::find(2); }