49 lines
982 B
PHP
49 lines
982 B
PHP
<?php
|
|
|
|
namespace App;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Notifications\Notifiable;
|
|
|
|
class Album extends Model
|
|
{
|
|
use Notifiable;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $fillable = [
|
|
'name', 'description', 'url_alias'
|
|
];
|
|
|
|
/**
|
|
* The attributes that should be hidden for arrays.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $hidden = [
|
|
];
|
|
|
|
public function fromRequest(Request $request)
|
|
{
|
|
$this->name = $request->get('name');
|
|
$this->description = $request->get('description');
|
|
$this->generateAlias();
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function generateAlias()
|
|
{
|
|
$this->url_alias = ucfirst(preg_replace('/[^a-z0-9\-]/', '-', strtolower($this->name)));
|
|
}
|
|
|
|
public function getUploadDisk()
|
|
{
|
|
// TODO allow albums to specify a storage location
|
|
return 'local';
|
|
}
|
|
} |