Skip to content

Commit

Permalink
Fix db, add markdown filters to all views
Browse files Browse the repository at this point in the history
  • Loading branch information
tdiam committed Feb 20, 2018
1 parent 743e968 commit 54f2789
Show file tree
Hide file tree
Showing 9 changed files with 941 additions and 58 deletions.
6 changes: 4 additions & 2 deletions app/Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@

class Schedule extends Model
{
// other fields: time,img_src,type
// type: workshop or talk
// other fields: time, img_src, type
// type: talk, performance or workshop
use HasTranslations;
public $translatable = ['event_title','event_prev','subtitle'];
public $timestamps = false;

/* Define the inverse relationship to be able to get the Speaker of a talk */
public function speaker() {
return $this->belongsTo('App\Speaker')->withDefault();
}
Expand All @@ -30,6 +31,7 @@ public function toArray() {
return $attributes;
}

/* Talks in schedule need to have links pointing to the Speakers page */
public function getEventTitleLinkAttribute() {
if($this->type == "talk") {
return '<a href="/speakers#' . $this->speaker->sid . '">' . $this->speaker->name . '</a>';
Expand Down
9 changes: 7 additions & 2 deletions app/Speaker.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@

class Speaker extends Model
{
// other fields: id,img_src,schedule_id;
// other fields: id, img_src, schedule_id;
use HasTranslations;
public $translatable = ['name','bio','talk_title','talk_prev'];
public $translatable = ['name','bio'];
public $timestamps = false;

// speakers are linked to talks (Schedule class) with the schedule_id field
// example:
// $speaker = App\Speaker::find(1);
// $talk = $speaker->talk;
// the last command will return the talk object along with its attributes (e.g. $talk->event_name, $talk->event_title, etc.)
public function talk() {
return $this->hasOne('App\Schedule');
}
Expand Down
5 changes: 3 additions & 2 deletions database/seeds/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ class DatabaseSeeder extends Seeder
*/
public function run()
{
/* Speakers are seeded through the Schedule seeder */
/* Speakers are seeded through the Schedule seeder,
so that the relationship Speaker->Schedule can be seeded properly
*/
$this->call(ScheduleSeeder::class);
$this->call(PeopleTableSeeder::class);
$this->call(SpeakersSeeder::class);
}
}
9 changes: 7 additions & 2 deletions database/seeds/ScheduleSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public function run()
'el' => 'Ερμηνεία-Επεξήγηση'
]
]),
/* When creating a schedule with type TALK, you have to create the Speaker object along with it
see below for example
*/
App\Schedule::create([
'hour' => '14:00',
'img_src' => 'styllas.jpeg',
Expand All @@ -44,9 +47,10 @@ public function run()
'el' => 'Το τέλος του χάους στο everest!'
],
'subtitle' => [
'en' => 'Chaos is extreme weather, chaos is extreme love!',
'el'=> 'Χάος είναι ο ακραίος καιρός του έβερεστ, χάος είναι η αγάπη'
'en' => 'Chaos is **extreme weather**, chaos is extreme love!',
'el'=> 'Χάος είναι ο **ακραίος καιρός** του έβερεστ, χάος είναι η αγάπη'
],
/* This is where the Speaker object is created with its proper attributes */
'speaker_id' => App\Speaker::create([
'name' => [
'en' => 'Michail Styllas',
Expand All @@ -58,6 +62,7 @@ public function run()
'en' => 'dede',
'el'=> 'δεδεδ',
]
/* Create the object and return its id */
])->id
])
];
Expand Down
35 changes: 0 additions & 35 deletions database/seeds/SpeakersSeeder.php

This file was deleted.

Loading

0 comments on commit 54f2789

Please sign in to comment.