blue-twilight/app/Label.php

28 lines
519 B
PHP

<?php
namespace App;
use App\Helpers\MiscHelper;
use Illuminate\Database\Eloquent\Model;
class Label extends Model
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'url_alias'
];
public function generateAlias()
{
$this->url_alias = preg_replace('/[^a-z0-9\-]/', '-', strtolower($this->name));
}
public function photos()
{
return $this->belongsToMany(Photo::class, 'photo_labels');
}
}