Skip to content

Commit

Permalink
🔥 Updated for the talks section
Browse files Browse the repository at this point in the history
  • Loading branch information
neoighodaro committed Jul 2, 2017
1 parent 714e197 commit 271e385
Show file tree
Hide file tree
Showing 22 changed files with 22,804 additions and 22,488 deletions.
12 changes: 0 additions & 12 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,4 @@ public function index(Meetup $meetup)

return view('index', compact('group', 'next_event', 'sponsors', 'tweet'));
}

/**
* Returns a list of talks past and present.
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function talks()
{
$talks = Talk::groupedByEvent();

return view('talks', compact('talks'));
}
}
22 changes: 22 additions & 0 deletions app/Http/Controllers/TalksController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace App\Http\Controllers;

use App\Meetup;
use App\Talk;

class TalksController extends Controller {

/**
* Returns a list of talks past and present.
*
* @param Meetup $meetup
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index(Meetup $meetup)
{
$meetups = Talk::organisedByMeetup();

return view('talks', compact('meetups'));
}
}
39 changes: 20 additions & 19 deletions app/Meetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Meetup extends Eloquent\Model
/**
* @var integer
*/
const CACHE_MINUTES = 5;
const CACHE_MINUTES = 15;

/**
* {@inheritDoc}
Expand Down Expand Up @@ -58,24 +58,9 @@ public function groupDetailsWithNextEvent()

return Cache::remember('meetup.group_with_next_event', static::CACHE_MINUTES, function () use ($group) {
if ($group->get('next_event')) {
$event_id = (int) $group->get('next_event')['id'];
$id = (int) $group->get('next_event')['id'];

$event = $this->getEventDetails($event_id, ['omit' => 'group']);

$timezone = $group->get('timezone');

$created_timestamp = $event->get('created') / 1000;
$event_timestamp = $event->get('time') / 1000;

$event->put('talks', $this->first()->talks->toArray());
$event->put('time_object', Carbon::createFromTimestamp($event_timestamp)->timezone($timezone));
$event->put('created_object', Carbon::createFromTimestamp($created_timestamp)->timezone($timezone));

if ($event->get('rsvp_limit')) {
$event->put('seats_left', $event->get('rsvp_limit') - $event->get('yes_rsvp_count'));
}

$group->put('next_event', $event);
$group->put('next_event', $this->getEventDetails($id, ['omit' => 'group']));
}

return $group;
Expand All @@ -94,7 +79,23 @@ public function getEventDetails(int $event_id = null, array $options = [])
$event_id = $event_id ?? $this->event_id;

return Cache::remember("meetup.event.{$event_id}", static::CACHE_MINUTES, function () use ($event_id, $options) {
return Api::getEvent($event_id, $options);
$event = Api::getEvent($event_id, $options);

$created_timestamp = $event->get('created') / 1000;
$event_timestamp = $event->get('time') / 1000;

$event->put('talks', $this->with(['talks' => function ($talks) {
$talks->accepted();
}])->first()->talks->toArray());

$event->put('time_object', Carbon::createFromTimestamp($event_timestamp));
$event->put('created_object', Carbon::createFromTimestamp($created_timestamp));

if ($event->get('rsvp_limit')) {
$event->put('seats_left', $event->get('rsvp_limit') - $event->get('yes_rsvp_count'));
}

return $event;
});
}

Expand Down
48 changes: 46 additions & 2 deletions app/Talk.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Cache;

class Talk extends Model
{
/**
* @var integer
*/
const CACHE_MINUTES = 5;

/**
* {@inheritDoc}
*/
Expand All @@ -27,10 +33,48 @@ class Talk extends Model
*/
protected $casts = ['accepted' => 'bool'];

/**
* Return all talks grouped by the event
*
* @param $query
* @return Collection
*/
public function scopeOrganisedByMeetup($query) : Collection
{
return Cache::remember('all_talks.organised', static::CACHE_MINUTES, function () use ($query) {
$talks = $query->accepted()->with('meetup')
->orderBy('meetup_id', 'desc')
->orderBy('created_at', 'desc')->get();

$meetups = [];

foreach ($talks as $talk) {
$meetups[$talk->meetup->id]['talks'][] = $talk;

if ( ! array_get($meetups[$talk->meetup->id], 'details')) {
$meetups[$talk->meetup->id]['details'] = $talk->meetup->getEventDetails();
}
}

return new Collection($meetups);
});
}

/**
* Return accepted talks only.
*
* @param $query
* @return \Illuminate\Database\Query\Builder
*/
public function scopeAccepted($query)
{
return $query->whereAccepted(true);
}

/**
* Define the relationship with the User resource.
*
* @return \Illuminate\Database\Eloquent\Relations\HasOne
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
{
Expand Down
1 change: 1 addition & 0 deletions bootstrap/app.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);

/*
|--------------------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion database/factories/ModelFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
static $event_id;

if ($event_id) {
$event_id = rand(100000000, 999999999);
$event_id = $event_id === 240522436
? 238642730
: rand(100000000, 999999999);
}

return [
Expand Down
2 changes: 2 additions & 0 deletions database/migrations/2017_06_15_224148_create_talks_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public function up()
$table->string('topic');
$table->text('overview');
$table->unsignedInteger('meetup_id');
$table->string('link_video')->nullable();
$table->string('link_slides')->nullable();
$table->boolean('accepted')->default(false);
$table->timestamps();

Expand Down
98 changes: 90 additions & 8 deletions public/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -5157,26 +5157,46 @@ fieldset[disabled] .navbar-inverse .btn-link:focus {
width: 100%;
margin-bottom: 0;
max-height: 900px;
padding: 100px 0;
position: relative;
background-size: cover;
background: url(../img/jumbo.jpg) center;
}

.jumbo.home {
padding: 100px 0;
}

@media only screen and (min-width: 992px) {
.jumbo {
.jumbo.home {
padding: 200px 0;
overflow: hidden;
}
}

@media only screen and (min-width: 1440px) {
.jumbo {
.jumbo.home {
padding: 283px 0;
overflow: hidden;
}
}

.jumbo.pages {
padding: 100px 0;
}

.jumbo.pages h1 {
margin-bottom: 10px;
}

.jumbo.pages h2 {
font-size: 16px;
}

@media only screen and (min-width: 768px) {
.jumbo.pages h2 {
font-size: 20px;
}
}

.jumbo .container {
position: relative;
}
Expand All @@ -5189,7 +5209,7 @@ fieldset[disabled] .navbar-inverse .btn-link:focus {
top: 0;
}

.jumbo span.event, .jumbo h1, .jumbo .guests-count {
.jumbo span.event, .jumbo h1, .jumbo .guests-count, .jumbo h2 {
color: #fff;
font-weight: 600;
text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
Expand Down Expand Up @@ -5362,10 +5382,8 @@ section.section .title-subtitle h4 {
}

section.section.speak {
background: url("../img/speaker.jpg") no-repeat center;
background-size: cover;
background-repeat: no-repeat;
background-image: url("../img/speaker.jpg");
background-position: center;
position: relative;
}

Expand Down Expand Up @@ -5549,6 +5567,66 @@ section.section.slack #CommunityInviter button#CommunityInviterSend:hover {
background-color: #00abab !important;
}

section.section.speakers.single {
padding-top: 0;
}

section.section.speakers.single .meetup-title {
text-align: center;
padding: 50px 0 40px;
}

@media only screen and (min-width: 768px) {
section.section.speakers.single .meetup-title {
padding: 120px 0 70px;
}
}

section.section.speakers.single .meetup-title h3 {
font-weight: 600;
color: rgba(0, 186, 186, 0.9);
}

@media only screen and (min-width: 768px) {
section.section.speakers.single .meetup-title h3 {
font-size: 30px;
}
}

section.section.speakers.single .meetup-title span.event-date {
text-transform: uppercase;
font-size: 13px;
color: #999;
}

section.section.speakers .links ul {
list-style-type: none;
padding: 0;
margin-top: 20px;
}

section.section.speakers .links ul li {
display: inline-block;
margin-right: 15px;
}

section.section.speakers .links ul li:last-child {
margin-right: 0;
}

section.section.speakers .links ul li a {
color: #b9b9b9;
transition: color .3s ease;
}

section.section.speakers .links ul li a:hover {
color: #00BABA;
}

section.section.speakers .links ul li i.fa {
font-size: 20px;
}

section.section.speakers .btn.old-talks {
background: #F0F0F0;
border-radius: 10px;
Expand All @@ -5559,6 +5637,9 @@ section.section.speakers .btn.old-talks {
font-weight: 600;
color: #898989;
transition: all .3s ease;
display: block;
z-index: 9999;
position: relative;
}

section.section.speakers .btn.old-talks:hover {
Expand Down Expand Up @@ -5829,6 +5910,7 @@ section.section.sponsors .sponsor {
section.section.sponsors .sponsor a {
display: inline-block;
outline: none;
text-decoration: none;
}

footer.main {
Expand Down
Binary file added public/img/talks.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 271e385

Please sign in to comment.