mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-02-05 17:49:19 +00:00
1.7 - Testing Query Scopes
This commit is contained in:
@@ -9,6 +9,11 @@ class Concert extends Model
|
||||
protected $guarded = [];
|
||||
protected $dates = ['date'];
|
||||
|
||||
public function scopePublished($query)
|
||||
{
|
||||
return $query->whereNotNull('published_at');
|
||||
}
|
||||
|
||||
public function getFormattedDateAttribute()
|
||||
{
|
||||
return $this->date->format('F j, Y');
|
||||
|
||||
@@ -9,7 +9,7 @@ class ConcertsController extends Controller
|
||||
{
|
||||
public function show($id)
|
||||
{
|
||||
$concert = Concert::whereNotNull('published_at')->findOrFail($id);
|
||||
$concert = Concert::published()->findOrFail($id);
|
||||
return view('concerts.show', ['concert' => $concert]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user