mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-01-26 11:14:06 +00:00
113 - Viewing the Update Form
Just the view, saving changes not yet implemented.
This commit is contained in:
@@ -55,4 +55,15 @@ class ConcertsController extends Controller
|
||||
|
||||
return redirect()->route('concerts.show', $concert);
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$concert = Auth::user()->concerts()->findOrFail($id);
|
||||
|
||||
abort_if($concert->isPublished(), 403);
|
||||
|
||||
return view('backstage.concerts.edit', [
|
||||
'concert' => $concert,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
204
resources/views/backstage/concerts/edit.blade.php
Normal file
204
resources/views/backstage/concerts/edit.blade.php
Normal file
@@ -0,0 +1,204 @@
|
||||
@extends('layouts.master')
|
||||
|
||||
@section('body')
|
||||
<header>
|
||||
<nav class="navbar p-xs-y-3">
|
||||
<div class="container">
|
||||
<div class="navbar-content">
|
||||
<div>
|
||||
<img src="/img/logo.svg" alt="TicketBeast" style="height: 2.5rem;">
|
||||
</div>
|
||||
<div>
|
||||
<form class="inline-block" action="{{ route('auth.logout') }}" method="POST">
|
||||
{{ csrf_field() }}
|
||||
<button type="submit" class="link link-light">Log out</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<div class="bg-light p-xs-y-4 border-b">
|
||||
<div class="container">
|
||||
<h1 class="text-lg">Edit concert</h1>
|
||||
</div>
|
||||
</div>
|
||||
<form class="bg-soft p-xs-y-5" action="{{-- route('backstage.concerts.update', $concert) --}}" method="POST">
|
||||
{{ csrf_field() }}
|
||||
{{ method_field('PATCH') }}
|
||||
|
||||
@if ($errors->any())
|
||||
<div class="container m-xs-b-4">
|
||||
<div class="alert alert-danger">
|
||||
<h2 class="text-base text-danger wt-bold m-xs-b-2">
|
||||
There {{ $errors->count() == 1 ? 'is' : 'are' }} {{ $errors->count() }} {{ str_plural('error', $errors->count() )}} with this concert:
|
||||
</h2>
|
||||
<ul class="bullet-list text-danger">
|
||||
@foreach ($errors->all() as $error)
|
||||
<li>{{ $error }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="border-b p-xs-b-4 m-xs-b-4">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col col-lg-4">
|
||||
<div class="p-xs-y-4">
|
||||
<h2 class="text-base wt-medium m-xs-b-4">Concert Details</h2>
|
||||
<p class="text-dark-soft text-sm m-xs-b-4">Tell us who's playing! <em>(Please be Slayer!)</em></p>
|
||||
<p class="text-dark-soft text-sm">Include the headliner in the concert name, use the subtitle section to list any opening bands, and add any important information to the description.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col col-lg-8">
|
||||
<div class="card">
|
||||
<div class="card-section">
|
||||
<div class="form-group {{ $errors->first('title', 'has-error') }}">
|
||||
<label class="form-label">Title</label>
|
||||
<input name="title" class="form-control" value="{{ old('title', $concert->title) }}" placeholder="The Headliners">
|
||||
</div>
|
||||
<div class="form-group {{ $errors->first('subtitle', 'has-error') }}">
|
||||
<label class="form-label">Subtitle</label>
|
||||
<input name="subtitle" class="form-control" value="{{ old('subtitle', $concert->subtitle) }}" placeholder="with The Openers (optional)">
|
||||
</div>
|
||||
<div class="form-group {{ $errors->first('additional_information', 'has-error') }}">
|
||||
<label class="form-label">Additional Information</label>
|
||||
<textarea name="additional_information" class="form-control" rows="4" placeholder="This concert is 19+ (optional)">{{ old('additional_information', $concert->additional_information) }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="border-b p-xs-b-4 m-xs-b-4">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col col-lg-4">
|
||||
<div class="p-xs-y-4">
|
||||
<h2 class="text-base wt-medium m-xs-b-4">Date & Time</h2>
|
||||
<p class="text-dark-soft text-sm">True metalheads really only care about the obscure openers, so make sure they don't get there late!</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col col-lg-8">
|
||||
<div class="card">
|
||||
<div class="card-section">
|
||||
<div class="row">
|
||||
<div class="col col-md-6">
|
||||
<div class="form-group {{ $errors->first('date', 'has-error') }}">
|
||||
<label class="form-label">Date</label>
|
||||
<input type="date" name="date" class="form-control" placeholder="yyyy-mm-dd" value="{{ old('date', $concert->date->format('Y-m-d')) }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col col-md-6">
|
||||
|
||||
<div class="form-group {{ $errors->first('time', 'has-error') }}">
|
||||
<label class="form-label">Start Time</label>
|
||||
<input name="time" class="form-control" placeholder="7:00pm" value="{{ old('time', $concert->date->format('g:ia')) }}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="border-b p-xs-b-4 m-xs-b-4">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col col-lg-4">
|
||||
<div class="p-xs-y-4">
|
||||
<h2 class="text-base wt-medium m-xs-b-4">Venue Information</h2>
|
||||
<p class="text-dark-soft text-sm">Where's the show? Let attendees know the venue name and address so they can bring the mosh.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col col-lg-8">
|
||||
<div class="card">
|
||||
<div class="card-section">
|
||||
<div class="form-group {{ $errors->first('venue', 'has-error') }}">
|
||||
<label class="form-label">Venue Name</label>
|
||||
<input name="venue" class="form-control" value="{{ old('venue', $concert->venue) }}" placeholder="The Mosh Pit">
|
||||
</div>
|
||||
<div class="form-group {{ $errors->first('venue_address', 'has-error') }}">
|
||||
<label class="form-label">Stree Address</label>
|
||||
<input name="venue_address" class="form-control" value="{{ old('venue_address', $concert->venue_address) }}" placeholder="500 Example Ave.">
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col col-sm-4">
|
||||
<div class="form-group {{ $errors->first('city', 'has-error') }}">
|
||||
<label class="form-label">City</label>
|
||||
<input name="city" class="form-control" value="{{ old('city', $concert->city) }}" placeholder="Laraville">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col col-sm-4">
|
||||
<div class="form-group {{ $errors->first('state', 'has-error') }}">
|
||||
<label class="form-label">State/Province</label>
|
||||
<input name="state" class="form-control" value="{{ old('state', $concert->state) }}" placeholder="ON">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col col-sm-4">
|
||||
<div class="form-group {{ $errors->first('zip', 'has-error') }}">
|
||||
<label class="form-label">ZIP</label>
|
||||
<input name="zip" class="form-control" value="{{ old('zip', $concert->zip) }}" placeholder="90210">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="border-b p-xs-b-4 m-xs-b-4">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col col-lg-4">
|
||||
<div class="p-xs-y-4">
|
||||
<h2 class="text-base wt-medium m-xs-b-4">Tickets & Pricing</h2>
|
||||
<p class="text-dark-soft text-sm">Set your ticket price and availability, but don't forget, metalheads are cheap so keep it reasonable.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col col-lg-8">
|
||||
<div class="card">
|
||||
<div class="card-section">
|
||||
<div class="row">
|
||||
<div class="col col-md-6">
|
||||
<div class="form-group {{ $errors->first('ticket_price', 'has-error') }}">
|
||||
<label class="form-label">Price</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon text-dark-muted">
|
||||
$
|
||||
</span>
|
||||
<input name="ticket_price" class="form-control" placeholder="0.00" value="{{ old('ticket_price', $concert->ticket_price_in_dollars) }}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col col-md-6">
|
||||
<div class="form-group {{ $errors->first('ticket_quantity', 'has-error') }}">
|
||||
<label class="form-label">Ticket Quantity</label>
|
||||
<input name="ticket_quantity" class="form-control" placeholder="250" value="{{ old('ticket_quantity', $concert->tickets()->count()) }}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container text-right">
|
||||
<button type="submit" class="btn btn-primary">Save Changes</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
<footer class="p-xs-y-6 text-light-muted">
|
||||
<div class="container">
|
||||
<p class="text-center">© TicketBeast {{ date('Y') }}</p>
|
||||
</div>
|
||||
</footer>
|
||||
@endsection
|
||||
@@ -48,9 +48,6 @@
|
||||
{{ $concert->formatted_date }} @ {{ $concert->formatted_start_time }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="text-right">
|
||||
<a href="#" class="btn btn-secondary btn-block">Edit</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -23,5 +23,5 @@ Route::group(['middleware' => 'auth', 'prefix' => 'backstage', 'namespace' => 'B
|
||||
Route::get('/concerts', 'ConcertsController@index');
|
||||
Route::get('/concerts/new', 'ConcertsController@create')->name('backstage.concerts.new');
|
||||
Route::post('/concerts', 'ConcertsController@store');
|
||||
Route::get('/concerts/{id}/edit', 'ConcertsController@edit')->name('backstage.concerts.edit');
|
||||
});
|
||||
|
||||
|
||||
84
tests/Feature/Backstage/EditConcertTest.php
Normal file
84
tests/Feature/Backstage/EditConcertTest.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Backstage;
|
||||
|
||||
use App\User;
|
||||
use App\Concert;
|
||||
use Carbon\Carbon;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
|
||||
class EditConcertTest extends TestCase
|
||||
{
|
||||
use DatabaseMigrations;
|
||||
|
||||
/** @test */
|
||||
function promoters_can_view_the_edit_form_for_their_own_unpublished_concerts()
|
||||
{
|
||||
$this->disableExceptionHandling();
|
||||
|
||||
$user = factory(User::class)->create();
|
||||
$concert = factory(Concert::class)->create(['user_id' => $user->id]);
|
||||
$this->assertFalse($concert->isPublished());
|
||||
|
||||
$response = $this->actingAs($user)->get("/backstage/concerts/{$concert->id}/edit");
|
||||
|
||||
$response->assertStatus(200);
|
||||
$this->assertTrue($response->data('concert')->is($concert));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function promoters_cannot_view_the_edit_form_for_their_own_published_concerts()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
$concert = factory(Concert::class)->states('published')->create(['user_id' => $user->id]);
|
||||
$this->assertTrue($concert->isPublished());
|
||||
|
||||
$response = $this->actingAs($user)->get("/backstage/concerts/{$concert->id}/edit");
|
||||
|
||||
$response->assertStatus(403);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function promoters_cannot_view_the_edit_form_for_other_concerts()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
$otherUser = factory(User::class)->create();
|
||||
$concert = factory(Concert::class)->create(['user_id' => $otherUser->id]);
|
||||
|
||||
$response = $this->actingAs($user)->get("/backstage/concerts/{$concert->id}/edit");
|
||||
|
||||
$response->assertStatus(404);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function promoters_see_a_404_when_attempting_to_view_the_edit_form_for_a_concert_that_does_not_exist()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
$response = $this->actingAs($user)->get("/backstage/concerts/999/edit");
|
||||
|
||||
$response->assertStatus(404);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function guests_are_asked_to_login_when_attempting_to_view_the_edit_form_for_any_concert()
|
||||
{
|
||||
$otherUser = factory(User::class)->create();
|
||||
$concert = factory(Concert::class)->create(['user_id' => $otherUser->id]);
|
||||
|
||||
$response = $this->get("/backstage/concerts/{$concert->id}/edit");
|
||||
|
||||
$response->assertStatus(302);
|
||||
$response->assertRedirect('/login');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function guests_are_asked_to_login_when_attempting_to_view_the_edit_form_for_a_concert_that_does_not_exist()
|
||||
{
|
||||
$response = $this->get("/backstage/concerts/999/edit");
|
||||
|
||||
$response->assertStatus(302);
|
||||
$response->assertRedirect('/login');
|
||||
}
|
||||
}
|
||||
@@ -20,10 +20,6 @@ class ViewConcertListTest extends TestCase
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
TestResponse::macro('data', function ($key) {
|
||||
return $this->original->getData()[$key];
|
||||
});
|
||||
|
||||
Collection::macro('assertContains', function ($value) {
|
||||
Assert::assertTrue($this->contains($value), "Failed asserting that the collection contains the specified value.");
|
||||
});
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Tests;
|
||||
|
||||
use Exception;
|
||||
use App\Exceptions\Handler;
|
||||
use Illuminate\Foundation\Testing\TestResponse;
|
||||
use Illuminate\Contracts\Debug\ExceptionHandler;
|
||||
|
||||
abstract class TestCase extends \Illuminate\Foundation\Testing\TestCase
|
||||
@@ -20,6 +21,10 @@ abstract class TestCase extends \Illuminate\Foundation\Testing\TestCase
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
TestResponse::macro('data', function ($key) {
|
||||
return $this->original->getData()[$key];
|
||||
});
|
||||
}
|
||||
|
||||
protected function disableExceptionHandling()
|
||||
|
||||
Reference in New Issue
Block a user