<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Project extends Model
{
protected $fillable = ['title', 'description', 'owner_id', 'picture', 'themes_id'];
protected $guarded = [];
protected $attributes = [];
public function tasks(){
return $this->hasMany(Task::class);
}
public function addTask($attributes){
return Task::create([
'project_id' => $this->id,
'filename' => $attributes['filename'],
'filecode' => $attributes['filecode'],
'filetext' => $attributes['filetext']
]);
}
public function updateTask($attributes){
return Task::update([
'project_id' => $this->id,
'filename' => $attributes['filename'],
'filecode' => $attributes['filecode']
]);
}
public function getImageAttribute(){
return $this->image;
}
}