Programmatically fill file field fype
hugogilmar - 11 months ago
I'm working on an old news website migration to PyroCMS. I've already imported all posts data to PyroCMS Post stream.
I've a problem, I need to fill an aditional File type field (cover photo) adden on posts. I don't understand how to programmatically set a file field type stream for a model. Reading the documentation I've found that file field type can be set with a file instance (I asume is an Eloquent model instance).
This is how I'm setting post model on import process:
$post = $this->post->create( [ 'es' => [ 'title' => $article->titulo, 'summary' => $article->encabezado, ], 'slug' => $slug, 'created_at' => $article->fecha, 'updated_at' => $article->fecha, 'publish_at' => time(), 'enabled' => true, 'type' => $type, 'entry' => $content, 'category' => $category, 'author' => 1, ] );
What I'm targeting into is, that this images should be later be updated from PyroCMS admin interface, so I wan't to emulate/follow the same process with disk/folder storage used in PyroCMS. My files are stored in a temporary folder for import process.
Thanks for your help.