From ac4d9685976ee38d38ee313584ba3297d6500e26 Mon Sep 17 00:00:00 2001 From: Adam Wathan Date: Fri, 8 Dec 2017 12:44:32 -0500 Subject: [PATCH] 148 - Viewing an Unused Invitation --- .../Controllers/InvitationsController.php | 18 +++++++++++ app/Invitation.php | 13 ++++++++ database/factories/ModelFactory.php | 4 +++ ..._12_08_173739_create_invitations_table.php | 32 +++++++++++++++++++ resources/views/invitations/show.blade.php | 0 routes/web.php | 2 ++ tests/Feature/AcceptInvitationTest.php | 29 +++++++++++++++++ 7 files changed, 98 insertions(+) create mode 100644 app/Http/Controllers/InvitationsController.php create mode 100644 app/Invitation.php create mode 100644 database/migrations/2017_12_08_173739_create_invitations_table.php create mode 100644 resources/views/invitations/show.blade.php create mode 100644 tests/Feature/AcceptInvitationTest.php diff --git a/app/Http/Controllers/InvitationsController.php b/app/Http/Controllers/InvitationsController.php new file mode 100644 index 0000000..78c5b87 --- /dev/null +++ b/app/Http/Controllers/InvitationsController.php @@ -0,0 +1,18 @@ + $invitation, + ]); + } +} diff --git a/app/Invitation.php b/app/Invitation.php new file mode 100644 index 0000000..16e6f34 --- /dev/null +++ b/app/Invitation.php @@ -0,0 +1,13 @@ +first(); + } +} diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index 0eb450b..1d92179 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -78,3 +78,7 @@ $factory->define(App\Order::class, function (Faker\Generator $faker) { 'card_last_four' => '1234', ]; }); + +$factory->define(App\Invitation::class, function (Faker\Generator $faker) { + return []; +}); diff --git a/database/migrations/2017_12_08_173739_create_invitations_table.php b/database/migrations/2017_12_08_173739_create_invitations_table.php new file mode 100644 index 0000000..2391bda --- /dev/null +++ b/database/migrations/2017_12_08_173739_create_invitations_table.php @@ -0,0 +1,32 @@ +increments('id'); + $table->string('code'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('invitations'); + } +} diff --git a/resources/views/invitations/show.blade.php b/resources/views/invitations/show.blade.php new file mode 100644 index 0000000..e69de29 diff --git a/routes/web.php b/routes/web.php index ee7cb01..adbff40 100644 --- a/routes/web.php +++ b/routes/web.php @@ -19,6 +19,8 @@ Route::get('/login', 'Auth\LoginController@showLoginForm')->name('auth.show-logi Route::post('/login', 'Auth\LoginController@login')->name('auth.login'); Route::post('/logout', 'Auth\LoginController@logout')->name('auth.logout'); +Route::get('/invitations/{code}', 'InvitationsController@show')->name('invitations.show'); + Route::group(['middleware' => 'auth', 'prefix' => 'backstage', 'namespace' => 'Backstage'], function () { Route::get('/concerts', 'ConcertsController@index')->name('backstage.concerts.index'); Route::get('/concerts/new', 'ConcertsController@create')->name('backstage.concerts.new'); diff --git a/tests/Feature/AcceptInvitationTest.php b/tests/Feature/AcceptInvitationTest.php new file mode 100644 index 0000000..943a6b3 --- /dev/null +++ b/tests/Feature/AcceptInvitationTest.php @@ -0,0 +1,29 @@ +withoutExceptionHandling(); + + $invitation = factory(Invitation::class)->create([ + 'code' => 'TESTCODE1234', + ]); + + $response = $this->get('/invitations/TESTCODE1234'); + + $response->assertStatus(200); + $response->assertViewIs('invitations.show'); + $this->assertTrue($response->data('invitation')->is($invitation)); + } +}