Include a link to the genre's content in the genre editor.

This commit is contained in:
Peter Deltchev 2015-11-24 03:37:33 -08:00
parent 2bd6a0b258
commit be23475ae5
3 changed files with 11 additions and 3 deletions

View file

@ -24,13 +24,14 @@ use DB;
use Illuminate\Database\Eloquent\Relations\Relation;
use Poniverse\Ponyfm\Traits\SlugTrait;
use Illuminate\Database\Eloquent\Model;
use URL;
use Venturecraft\Revisionable\RevisionableTrait;
class Genre extends Model
{
protected $table = 'genres';
protected $fillable = ['name', 'slug'];
protected $appends = ['track_count'];
protected $appends = ['track_count', 'url'];
protected $hidden = ['trackCountRelation'];
public $timestamps = false;
@ -63,4 +64,11 @@ class Genre extends Model
public function getTrackCountAttribute() {
return $this->trackCountRelation()->count();
}
/**
* @return string relative, Angular-friendly URL to this genre
*/
public function getUrlAttribute() {
return URL::route('tracks.discover', ['filter' => "genres-{$this->id}"], false);
}
}

View file

@ -34,7 +34,7 @@ if (Config::get('app.debug')) {
}
Route::get('/dashboard', 'TracksController@getIndex');
Route::get('/tracks', 'TracksController@getIndex');
Route::get('/tracks', ['as' => 'tracks.discover', 'uses' => 'TracksController@getIndex']);
Route::get('/tracks/popular', 'TracksController@getIndex');
Route::get('/tracks/random', 'TracksController@getIndex');

View file

@ -22,7 +22,7 @@
</div>
</td>
<td><i ng-show="genre.isSaving" class="icon-cog icon-spin icon-large"></i></td>
<td>{{ genre.track_count }}</td>
<td><a ng-href="{{ genre.url }}">{{ genre.track_count }}</a></td>
<td>
<button class="btn btn-warning" disabled>Merge&hellip;</button>
</td>