diff --git a/app/Event.php b/app/Event.php index e84b7e5..530e3c4 100644 --- a/app/Event.php +++ b/app/Event.php @@ -20,4 +20,14 @@ class Event extends Model 'duration', 'enrollable', ]; + + public function speakers() + { + return $this->hasMany('App\Speakers'); + } + + public function schedule() + { + return $this->hasMany('App\Schedule'); + } } diff --git a/app/Http/Controllers/Cms/ScheduleController.php b/app/Http/Controllers/Cms/ScheduleController.php index 94f73d9..b399d9c 100644 --- a/app/Http/Controllers/Cms/ScheduleController.php +++ b/app/Http/Controllers/Cms/ScheduleController.php @@ -4,20 +4,26 @@ use App\Http\Controllers\Controller; +use App\Event; use App\Schedule; use Illuminate\Http\Request; class ScheduleController extends Controller { - public function index() + public function index(Request $request) { + $event_id = $request->event_id; + $request->session()->flash('event_id', $event_id); + $event = Event::where('id', '=', $event_id)->get(['id', 'name'])->first(); $schedules = Schedule::all(); - return view('cms.schedule.index', compact('schedules')); + + return view('cms.schedule.index', compact('schedules', 'event')); } - public function create() + public function create(Request $request) { - return view('cms.schedule.create'); + $event_id = $request->session()->get('event_id'); + return view('cms.schedule.create', ['event_id' => $event_id]); } public function store(Request $request) @@ -27,17 +33,19 @@ public function store(Request $request) 'place' => 'required|max:255', 'description' => 'required', 'start_at' => 'date', - 'end_at' => 'nullable|date|after_or_equal:start_at' + 'end_at' => 'nullable|date|after_or_equal:start_at', + 'event_id' => 'required' ]); $schedule = Schedule::create($scheduleData); - return redirect()->route('schedule.index'); + return redirect()->route('schedule.index', ['event_id' => $schedule->event_id]); } public function show(Schedule $schedule) { - return view('cms.schedule.show', compact('schedule')); + $event = Event::where('id', '=', $schedule->event_id)->get(['name', 'id'])->first(); + return view('cms.schedule.show', compact('schedule', 'event')); } public function edit(Schedule $schedule) @@ -47,6 +55,7 @@ public function edit(Schedule $schedule) public function update(Request $request, Schedule $schedule) { + $event_id = $schedule->event_id; $scheduleData = $request->validate([ 'title' => 'required|max:255', 'place' => 'required|max:255', @@ -57,9 +66,9 @@ public function update(Request $request, Schedule $schedule) try { $schedule = $schedule->update($scheduleData); - return redirect()->route('schedule.index')->withSuccess('Programação atualizada.'); + return redirect()->route('schedule.index', ['event_id' => $event_id])->withSuccess('Programação atualizada.'); } catch (\Throwable $th) { - return redirect()->route('schedule.index')->withError('Falha ao atualizar programação.'); + return redirect()->route('schedule.index', ['event_id' => $event_id])->withError('Falha ao atualizar programação.'); } } @@ -67,9 +76,9 @@ public function destroy(Schedule $schedule) { try { $schedule->delete(); - return redirect()->route('schedule.index')->withSuccess('Progração excluída.'); + return redirect()->route('schedule.index', ['event_id' => $schedule->event_id])->withSuccess('Progração excluída.'); } catch (\Throwable $th) { - return redirect()->route('schedule.index')->withError('Erro ao excluir programação.'); + return redirect()->route('schedule.index', ['event_id' => $schedule->event_id])->withError('Erro ao excluir programação.'); } } } diff --git a/app/Http/Controllers/Cms/SpeakerController.php b/app/Http/Controllers/Cms/SpeakerController.php index c03c099..4c434c2 100644 --- a/app/Http/Controllers/Cms/SpeakerController.php +++ b/app/Http/Controllers/Cms/SpeakerController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\Cms; use App\Speaker; +use App\Event; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Storage; @@ -15,11 +16,15 @@ class SpeakerController extends Controller * * @return \Illuminate\Http\Response */ - public function index() + public function index(Request $request) { - $speakers = Speaker::all(); + $event_id = $request->event_id; + + $request->session()->flash('event_id', $event_id); + $speakers = Speaker::where('event_id', '=', $event_id)->get(); - return view('cms.speaker.index', ['speakers' => $speakers]); + $event = Event::where('id', '=', $event_id)->get(['name', 'id'])->first(); + return view('cms.speaker.index', ['speakers' => $speakers, 'event' => $event]); } /** @@ -27,9 +32,10 @@ public function index() * * @return \Illuminate\Http\Response */ - public function create() + public function create(Request $request) { - return view('cms.speaker.create'); + $event_id = $request->session()->get('event_id'); + return view('cms.speaker.create', ['event_id' => $event_id]); } /** @@ -43,6 +49,7 @@ public function store(Request $request) $name = $request->name; $biography = $request->biography; $photo = $request->file('photo'); + $eventId = $request->event_id; $fileName = ''; if ($photo) @@ -56,12 +63,13 @@ public function store(Request $request) $speaker = Speaker::create([ 'name' => $name, 'biography' => $biography, - 'photo' => $fileName + 'photo' => $fileName, + 'event_id' => $eventId ]); $speaker->save(); - return redirect()->route('speaker.index')->withStatus('Palestrante cadastrado com sucesso.'); + return redirect()->route('speaker.index', ['event_id' => $eventId])->withStatus('Palestrante cadastrado com sucesso.'); } /** @@ -111,7 +119,7 @@ public function update(Request $request, Speaker $speaker) $speaker->update(); - return redirect()->route('speaker.index')->withStatus('Palestrante atualizado com sucesso'); + return redirect()->route('speaker.index', ['event_id' => $speaker->event_id])->withStatus('Palestrante atualizado com sucesso'); } private function deletePhoto($photoName) @@ -133,6 +141,6 @@ public function destroy(Speaker $speaker) $this->deletePhoto($speaker->photo); $speaker->delete(); - return redirect()->route('speaker.index')->withStatus('Palestrante removido com sucesso'); + return redirect()->route('speaker.index', ['event_id' => $speaker->event_id])->withStatus('Palestrante removido com sucesso'); } } diff --git a/app/Schedule.php b/app/Schedule.php index 2cd2184..d282ad8 100644 --- a/app/Schedule.php +++ b/app/Schedule.php @@ -11,7 +11,8 @@ class Schedule extends Model 'description', 'place', 'start_at', - 'end_at' + 'end_at', + 'event_id' ]; protected $casts = [ diff --git a/app/Speaker.php b/app/Speaker.php index 9fb181f..f7b1e60 100644 --- a/app/Speaker.php +++ b/app/Speaker.php @@ -12,6 +12,6 @@ class Speaker extends Model * @var array */ protected $fillable = [ - 'name', 'biography', 'photo' + 'name', 'biography', 'photo', 'event_id' ]; } diff --git a/composer.lock b/composer.lock index f7cf447..076db84 100644 --- a/composer.lock +++ b/composer.lock @@ -2059,16 +2059,16 @@ }, { "name": "symfony/http-foundation", - "version": "v4.4.2", + "version": "v4.4.7", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "fcae1cff5b57b2a9c3aabefeb1527678705ddb62" + "reference": "62f92509c9abfd1f73e17b8cf1b72c0bdac6611b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/fcae1cff5b57b2a9c3aabefeb1527678705ddb62", - "reference": "fcae1cff5b57b2a9c3aabefeb1527678705ddb62", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/62f92509c9abfd1f73e17b8cf1b72c0bdac6611b", + "reference": "62f92509c9abfd1f73e17b8cf1b72c0bdac6611b", "shasum": "" }, "require": { @@ -2110,7 +2110,7 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", - "time": "2019-12-19T15:57:49+00:00" + "time": "2020-03-30T14:07:33+00:00" }, { "name": "symfony/http-kernel", @@ -2204,16 +2204,16 @@ }, { "name": "symfony/mime", - "version": "v5.0.2", + "version": "v5.0.7", "source": { "type": "git", "url": "https://github.com/symfony/mime.git", - "reference": "0e6a4ced216e49d457eddcefb61132173a876d79" + "reference": "481b7d6da88922fb1e0d86a943987722b08f3955" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mime/zipball/0e6a4ced216e49d457eddcefb61132173a876d79", - "reference": "0e6a4ced216e49d457eddcefb61132173a876d79", + "url": "https://api.github.com/repos/symfony/mime/zipball/481b7d6da88922fb1e0d86a943987722b08f3955", + "reference": "481b7d6da88922fb1e0d86a943987722b08f3955", "shasum": "" }, "require": { @@ -2262,7 +2262,7 @@ "mime", "mime-type" ], - "time": "2019-11-30T14:12:50+00:00" + "time": "2020-03-27T16:56:45+00:00" }, { "name": "symfony/polyfill-ctype", @@ -2383,22 +2383,22 @@ }, { "name": "symfony/polyfill-intl-idn", - "version": "v1.13.1", + "version": "v1.15.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-idn.git", - "reference": "6f9c239e61e1b0c9229a28ff89a812dc449c3d46" + "reference": "47bd6aa45beb1cd7c6a16b7d1810133b728bdfcf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/6f9c239e61e1b0c9229a28ff89a812dc449c3d46", - "reference": "6f9c239e61e1b0c9229a28ff89a812dc449c3d46", + "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/47bd6aa45beb1cd7c6a16b7d1810133b728bdfcf", + "reference": "47bd6aa45beb1cd7c6a16b7d1810133b728bdfcf", "shasum": "" }, "require": { "php": ">=5.3.3", "symfony/polyfill-mbstring": "^1.3", - "symfony/polyfill-php72": "^1.9" + "symfony/polyfill-php72": "^1.10" }, "suggest": { "ext-intl": "For best performance" @@ -2406,7 +2406,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.13-dev" + "dev-master": "1.15-dev" } }, "autoload": { @@ -2441,20 +2441,20 @@ "portable", "shim" ], - "time": "2019-11-27T13:56:44+00:00" + "time": "2020-03-09T19:04:49+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.13.1", + "version": "v1.15.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "7b4aab9743c30be783b73de055d24a39cf4b954f" + "reference": "81ffd3a9c6d707be22e3012b827de1c9775fc5ac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7b4aab9743c30be783b73de055d24a39cf4b954f", - "reference": "7b4aab9743c30be783b73de055d24a39cf4b954f", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/81ffd3a9c6d707be22e3012b827de1c9775fc5ac", + "reference": "81ffd3a9c6d707be22e3012b827de1c9775fc5ac", "shasum": "" }, "require": { @@ -2466,7 +2466,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.13-dev" + "dev-master": "1.15-dev" } }, "autoload": { @@ -2500,20 +2500,20 @@ "portable", "shim" ], - "time": "2019-11-27T14:18:11+00:00" + "time": "2020-03-09T19:04:49+00:00" }, { "name": "symfony/polyfill-php72", - "version": "v1.13.1", + "version": "v1.15.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php72.git", - "reference": "66fea50f6cb37a35eea048d75a7d99a45b586038" + "reference": "37b0976c78b94856543260ce09b460a7bc852747" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/66fea50f6cb37a35eea048d75a7d99a45b586038", - "reference": "66fea50f6cb37a35eea048d75a7d99a45b586038", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/37b0976c78b94856543260ce09b460a7bc852747", + "reference": "37b0976c78b94856543260ce09b460a7bc852747", "shasum": "" }, "require": { @@ -2522,7 +2522,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.13-dev" + "dev-master": "1.15-dev" } }, "autoload": { @@ -2555,7 +2555,7 @@ "portable", "shim" ], - "time": "2019-11-27T13:56:44+00:00" + "time": "2020-02-27T09:26:54+00:00" }, { "name": "symfony/polyfill-php73", diff --git a/database/migrations/2020_04_27_050116_create_fk_event_on_speakers.php b/database/migrations/2020_04_27_050116_create_fk_event_on_speakers.php new file mode 100644 index 0000000..9c78588 --- /dev/null +++ b/database/migrations/2020_04_27_050116_create_fk_event_on_speakers.php @@ -0,0 +1,31 @@ +bigInteger('event_id')->unsigned(); + $table->foreign('event_id')->references('id')->on('events'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropForeign('event_id'); + } +} diff --git a/database/migrations/2020_04_28_051430_create_fk_event_on_schedule.php b/database/migrations/2020_04_28_051430_create_fk_event_on_schedule.php new file mode 100644 index 0000000..de7e712 --- /dev/null +++ b/database/migrations/2020_04_28_051430_create_fk_event_on_schedule.php @@ -0,0 +1,31 @@ +bigInteger('event_id')->unsigned(); + $table->foreign('event_id')->references('id')->on('events'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropForeign('event_id'); + } +} \ No newline at end of file diff --git a/resources/js/app.js b/resources/js/app.js index 5210034..e8c46c4 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -28,6 +28,8 @@ Vue.component('event-form', require('./components/EventForm.vue').default); Vue.component('speaker-form', require('./components/SpeakerForm.vue').default); Vue.component('alert-toast', require('./components/ToastAlert.vue').default); + +Vue.component('event-dashboard', require('./components/EventDashboard.vue').default); /** * Next, we will create a fresh Vue application instance and attach it to * the page. Then, you may begin adding components to this application diff --git a/resources/js/components/EventDashboard.vue b/resources/js/components/EventDashboard.vue new file mode 100644 index 0000000..3f58d14 --- /dev/null +++ b/resources/js/components/EventDashboard.vue @@ -0,0 +1,157 @@ + + + + + \ No newline at end of file diff --git a/resources/views/cms/event/show.blade.php b/resources/views/cms/event/show.blade.php index d090449..485fa2b 100644 --- a/resources/views/cms/event/show.blade.php +++ b/resources/views/cms/event/show.blade.php @@ -5,7 +5,7 @@ ]) @section('content') -
+
@@ -18,13 +18,11 @@
@@ -42,50 +40,19 @@
@endif - -
- - - - - - - - - - - - - - - - - - - - - - - - -
Local do Evento{{ $event -> place }}
Curso Relacionado{{ $event -> course }}
Data de Início{{ date('d/m/Y', strtotime($event -> startDate)) }}
Duração - {{ $event -> duration }} - @if ($event -> duration > 1) - dias - @else - dia - @endif -
Descrição{{ $event -> description }}
-
+ +
- - @if ($event -> enrollable) - - @endif -
diff --git a/resources/views/cms/schedule/create.blade.php b/resources/views/cms/schedule/create.blade.php index 85d9c7f..0af6e44 100644 --- a/resources/views/cms/schedule/create.blade.php +++ b/resources/views/cms/schedule/create.blade.php @@ -13,6 +13,9 @@

Adicionar Programação + + +

@@ -98,6 +101,7 @@ class="form-control" > + diff --git a/resources/views/cms/schedule/edit.blade.php b/resources/views/cms/schedule/edit.blade.php index 49817c2..a53c521 100644 --- a/resources/views/cms/schedule/edit.blade.php +++ b/resources/views/cms/schedule/edit.blade.php @@ -13,7 +13,10 @@ @method('PUT')

- Adicionar Programação + Editar Programação + + +

diff --git a/resources/views/cms/schedule/index.blade.php b/resources/views/cms/schedule/index.blade.php index d1df735..8dba7a3 100644 --- a/resources/views/cms/schedule/index.blade.php +++ b/resources/views/cms/schedule/index.blade.php @@ -10,7 +10,9 @@

- nome-do-evento/Programação + + {{ $event->name }} + / Programação

diff --git a/resources/views/cms/schedule/show.blade.php b/resources/views/cms/schedule/show.blade.php index b21cdeb..f8232a5 100644 --- a/resources/views/cms/schedule/show.blade.php +++ b/resources/views/cms/schedule/show.blade.php @@ -10,13 +10,13 @@

- nome-do-evento/{{ $schedule->title }} + {{ $event->name }} / {{ $schedule->title }}

- + Voltar diff --git a/resources/views/cms/speaker/create.blade.php b/resources/views/cms/speaker/create.blade.php index f284a10..2b16f66 100644 --- a/resources/views/cms/speaker/create.blade.php +++ b/resources/views/cms/speaker/create.blade.php @@ -9,15 +9,19 @@
+