mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-01-26 03:04:05 +00:00
1.3 - Getting to Green
This commit is contained in:
11
app/Concert.php
Normal file
11
app/Concert.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Concert extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
protected $dates = ['date'];
|
||||
}
|
||||
15
app/Http/Controllers/ConcertsController.php
Normal file
15
app/Http/Controllers/ConcertsController.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Concert;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ConcertsController extends Controller
|
||||
{
|
||||
public function show($id)
|
||||
{
|
||||
$concert = Concert::find($id);
|
||||
return view('concerts.show', ['concert' => $concert]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateConcertsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('concerts', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('title');
|
||||
$table->string('subtitle');
|
||||
$table->datetime('date');
|
||||
$table->integer('ticket_price');
|
||||
$table->string('venue');
|
||||
$table->string('venue_address');
|
||||
$table->string('city');
|
||||
$table->string('state');
|
||||
$table->string('zip');
|
||||
$table->text('additional_information');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('concerts');
|
||||
}
|
||||
}
|
||||
@@ -23,5 +23,7 @@
|
||||
<env name="CACHE_DRIVER" value="array"/>
|
||||
<env name="SESSION_DRIVER" value="array"/>
|
||||
<env name="QUEUE_DRIVER" value="sync"/>
|
||||
<env name="DB_CONNECTION" value="sqlite"/>
|
||||
<env name="DB_DATABASE" value=":memory:"/>
|
||||
</php>
|
||||
</phpunit>
|
||||
|
||||
9
resources/views/concerts/show.blade.php
Normal file
9
resources/views/concerts/show.blade.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<h1>{{ $concert->title }}</h1>
|
||||
<h2>{{ $concert->subtitle }}</h2>
|
||||
<p>{{ $concert->date->format('F j, Y') }}</p>
|
||||
<p>Doors at {{ $concert->date->format('g:ia') }}</p>
|
||||
<p>{{ number_format($concert->ticket_price / 100, 2) }}</p>
|
||||
<p>{{ $concert->venue }}</p>
|
||||
<p>{{ $concert->venue_address }}</p>
|
||||
<p>{{ $concert->city }}, {{ $concert->state }} {{ $concert->zip }}</p>
|
||||
<p>{{ $concert->additional_information }}</p>
|
||||
@@ -11,6 +11,4 @@
|
||||
|
|
||||
*/
|
||||
|
||||
Route::get('/', function () {
|
||||
return view('welcome');
|
||||
});
|
||||
Route::get('/concerts/{id}', 'ConcertsController@show');
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
<?php
|
||||
|
||||
use App\Concert;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
||||
class ViewConcertListingTest extends TestCase
|
||||
{
|
||||
use DatabaseMigrations;
|
||||
|
||||
/** @test */
|
||||
function user_can_view_a_concert_listing()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user