Closed jfpwork closed 6 years ago
What version of Laravel are you using? I think you may forget the Workflow alias configuration in your Laravel project. https://github.com/brexis/laravel-workflow#installation
First thanks.
Version 5.4
got exception when $post->save(); ( Array to string conversion (SQL: update blog_posts
set currentPlace
= 1, updated_at
= 2017-12-11 15:28:53 where id
= 1) )
@jfpwork My problem is the same as yours.
You can fix this by using mutators: https://laravel.com/docs/5.5/eloquent-mutators So my model would look like this:
class BlogPost extends Model
{
use WorkflowTrait;
public function setCurrentPlaceAttribute($value)
{
$this->attributes['currentPlace'] = json_encode($value);
}
public function getCurrentPlaceAttribute()
{
return json_decode($this->attributes['currentPlace'], true);
}
}
I'm closing this issue as it's not related to laravel-workflow but to laravel.
You can fix this by using mutators: https://laravel.com/docs/5.5/eloquent-mutators So my model would look like this:
class BlogPost extends Model { use WorkflowTrait; public function setCurrentPlaceAttribute($value) { $this->attributes['currentPlace'] = json_encode($value); } public function getCurrentPlaceAttribute() { return json_decode($this->attributes['currentPlace'], true); } }
Or you could simply write it as:
class BlogPost extends Model
{
use WorkflowTrait;
protected $casts = [
'currentPlace' => 'json'
];
}
Hi @jfpwork, did you try this https://github.com/brexis/laravel-workflow#usage ?