mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-01-26 03:04:05 +00:00
148 - Viewing an Unused Invitation
This commit is contained in:
18
app/Http/Controllers/InvitationsController.php
Normal file
18
app/Http/Controllers/InvitationsController.php
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Invitation;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class InvitationsController extends Controller
|
||||||
|
{
|
||||||
|
public function show($code)
|
||||||
|
{
|
||||||
|
$invitation = Invitation::findByCode($code);
|
||||||
|
|
||||||
|
return view('invitations.show', [
|
||||||
|
'invitation' => $invitation,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
13
app/Invitation.php
Normal file
13
app/Invitation.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Invitation extends Model
|
||||||
|
{
|
||||||
|
public static function findByCode($code)
|
||||||
|
{
|
||||||
|
return self::where('code', $code)->first();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -78,3 +78,7 @@ $factory->define(App\Order::class, function (Faker\Generator $faker) {
|
|||||||
'card_last_four' => '1234',
|
'card_last_four' => '1234',
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$factory->define(App\Invitation::class, function (Faker\Generator $faker) {
|
||||||
|
return [];
|
||||||
|
});
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class CreateInvitationsTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('invitations', function (Blueprint $table) {
|
||||||
|
$table->increments('id');
|
||||||
|
$table->string('code');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('invitations');
|
||||||
|
}
|
||||||
|
}
|
||||||
0
resources/views/invitations/show.blade.php
Normal file
0
resources/views/invitations/show.blade.php
Normal file
@@ -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('/login', 'Auth\LoginController@login')->name('auth.login');
|
||||||
Route::post('/logout', 'Auth\LoginController@logout')->name('auth.logout');
|
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::group(['middleware' => 'auth', 'prefix' => 'backstage', 'namespace' => 'Backstage'], function () {
|
||||||
Route::get('/concerts', 'ConcertsController@index')->name('backstage.concerts.index');
|
Route::get('/concerts', 'ConcertsController@index')->name('backstage.concerts.index');
|
||||||
Route::get('/concerts/new', 'ConcertsController@create')->name('backstage.concerts.new');
|
Route::get('/concerts/new', 'ConcertsController@create')->name('backstage.concerts.new');
|
||||||
|
|||||||
29
tests/Feature/AcceptInvitationTest.php
Normal file
29
tests/Feature/AcceptInvitationTest.php
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use Tests\TestCase;
|
||||||
|
use App\Invitation;
|
||||||
|
use Illuminate\Foundation\Testing\WithFaker;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
|
||||||
|
class AcceptInvitationTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
/** @test */
|
||||||
|
function viewing_an_unused_invitation()
|
||||||
|
{
|
||||||
|
$this->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));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user