I have a relation as follows: A Class
has many ClassContents
.
The code at Class model as follows
public function classContents(): HasMany
{
return $this->hasMany(ClassContent::class);
}
The code at ClassCrudController's setupCreateOperation
as follows
$this->crud->addField([
'name' => 'classContents',
'type' => "relationship",
'subfields' => [
[
'name' => 'attachment',
'label' => 'Attachment',
'type' => 'upload',
'upload' => true
],
... ... ...
The code at ClassContent
model as follows
public function setAttachmentAttribute($value)
{
$attribute_name = "classContents['attachment']";
$disk = "public";
$destination_path = "class_contents";
$this->uploadFileToDisk($value, $attribute_name, $disk, $destination_path, $fileName = null);
}
File upload does not work with the above arrangement. Please suggest.