正在进行一个涉及将视频文件从MPEG转换为WEBM的新项目。我的问题是,在转换过程中,我试图更新我的Video
模型属性,但由于某种原因,我不能修改一些属性。
例如,我可以修改Video模型的name
,但是我不能修改streampath
或converted
字段
class Video extends Model
{
//
public $streampath;
public $converted;
protected $fillable = ['streampath', 'converted'];
/**
* Video constructor.
* @param array $path
*/
public function __construct($path=null)
{
parent::__construct();
if($path) {
$this->path = $path;
}
}
....
下面是转换方法:
public function convert() {
$uniqueId = $this->id;
$tempPath = $this->path;
$outputFileName = Carbon::now()->format('Ymdhis') . '.webm';
$outputPath = 'videos/' . $outputFileName;
$this->setConverted(ConvertStatusEnum::CONVERTING);
// Run the converter
$this->name = 'MY NEW TEST';
$this->setStreampath($outputFileName);
$this->setConverted(ConvertStatusEnum::CONVERTED);
Log::debug($this);
return $this;
}
这是这两个属性的setter
public function setStreampath($streampath)
{
$this->streampath = $streampath;
}
public function setConverted($converted)
{
$this->converted = $converted;
}
如有任何帮助,不胜感激
试试这个。改变$this->property
到$this->attributes['property']