Example #1
0
 /**
  * Display the specified resource.
  *
  * @param $slug
  * @return \Illuminate\Http\Response
  */
 public function show($slug)
 {
     $guild = Guild::where('slug', $slug)->firstOrFail();
     $now = Carbon::now();
     if (Input::has('month')) {
         $now->month = Input::get('month');
     }
     if (Input::has('year')) {
         $now->year = Input::get('year');
     }
     $startOfMonth = $now->copy()->startOfMonth();
     $endOfMonth = $now->copy()->endOfMonth();
     $occurrences = EventOccurrence::where('begin_at', '<', $endOfMonth)->where('end_at', '>', $startOfMonth)->whereHas('event', function ($query) use($guild) {
         $query->where('guild_id', $guild->id);
     })->with('event')->get();
     $events = [];
     foreach ($occurrences as $occurrence) {
         $events[$occurrence->begin_at->day][] = $occurrence;
     }
     $monthNames = [1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
     $dayNames = [1 => 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
     $month = $this->makeMonth($monthNames, $now);
     $lastRaids = EventOccurrence::with(['event', 'event.guild'])->whereHas('event.guild', function ($query) use($guild) {
         $query->where('id', $guild->id);
     })->where('begin_at', '<', Carbon::now())->orderBy('begin_at', 'desc')->limit(2)->get();
     $lastRaids = $lastRaids->reverse();
     $nextRaids = EventOccurrence::with(['event', 'event.guild'])->whereHas('event.guild', function ($query) use($guild) {
         $query->where('id', $guild->id);
     })->where('begin_at', '>', Carbon::now())->orderBy('begin_at')->limit(2)->get();
     return view('guilds.show', compact('guild', 'events', 'now', 'month', 'monthNames', 'dayNames', 'lastRaids', 'nextRaids'));
 }
 /**
  * Display the specified resource.
  *
  * @param $guildSlug
  * @param $occurrenceId
  * @return \Illuminate\Http\Response
  */
 public function show($guildSlug, $occurrenceId)
 {
     $guild = Guild::where('slug', $guildSlug)->firstOrFail();
     $occurrence = EventOccurrence::with(['event', 'event.guild'])->whereHas('event.guild', function ($query) use($guild) {
         $query->where('id', $guild->id);
     })->findOrFail($occurrenceId);
     $event = $occurrence->event;
     $guild = $event->guild;
     $signups = Signup::where(['event_occurrence_id' => $occurrence->id])->orderBy('created_at')->get();
     $comments = Comment::where(['event_occurrence_id' => $occurrence->id])->orderBy('created_at')->get();
     $character = Character::whereHas('guilds', function ($query) use($guild) {
         $query->where('guilds.id', $guild->id);
     })->where(['user_id' => Auth::user()->id])->firstOrFail();
     $ownSignup = null;
     $isSigned = false;
     foreach ($signups as $signup) {
         if ($signup->character_id == $character->id) {
             $ownSignup = $signup;
             $isSigned = true;
         }
     }
     if ($ownSignup == null) {
         $ownSignup = new Signup();
     }
     $statistic = new \stdClass();
     foreach (['YES', 'MAYBE', 'NO'] as $status) {
         $name = strtolower($status);
         $statistic->{$name} = $signups->filter(function ($signup) use($status) {
             return $signup->status == $status;
         })->count();
     }
     return view('guilds.events.show', compact('occurrence', 'event', 'guild', 'signups', 'comments', 'ownSignup', 'isSigned', 'statistic'));
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Character::findOrFail(1)->guilds()->attach(Guild::findOrFail(1));
     $guilds = Guild::all();
     $users = User::with('characters')->get();
     foreach ($users as $i => $user) {
         if ($i == 0) {
             continue;
         }
         $user->characters->random()->guilds()->attach($guilds->random());
     }
 }
Example #4
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $guilds = Guild::all();
     foreach ($guilds as $guild) {
         factory(Event::class, mt_rand(1, 3))->create(['guild_id' => $guild->id]);
         $events = Event::where('guild_id', $guild->id)->get();
         foreach ($events as $event) {
             $day = Carbon::now()->startOfMonth();
             $day->setTime(20, 0, 0);
             $day->addDays(mt_rand(0, 6));
             $end = $day->copy()->endOfMonth();
             do {
                 factory(EventOccurrence::class)->create(['event_id' => $event->id, 'begin_at' => $day, 'end_at' => $day->copy()->addHours(2)]);
                 $day->addWeek();
             } while ($day->lte($end));
         }
     }
 }
Example #5
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Guild::create(['slug' => 'arctic-circle-darkspear', 'name' => 'Arctic Circle', 'realm' => 'Darkspear', 'faction' => 'ALLIANCE', 'emblem_icon' => 134, 'emblem_icon_color' => '#dfa55a', 'emblem_border' => 2, 'emblem_border_color' => '#f9cc30', 'emblem_background_color' => '#006391']);
     factory(Guild::class, 3)->create();
 }