October export file url to database

99 views Asked by At

Is there a way to export the url of a file in October to a database table? I currently have a model called "Image" that stores the url by doing the following:

public $attachOne = [
  'image' => ['System\Models\File']
];

I'm storing other attributes in the model list (called columns.yaml) and in the database, I'd like to add the url here if possible?

columns:
  id:
    label: ID
    type: number
  name:
    label: Name
    type: text
    searchable: true
    sortable: true
1

There are 1 answers

0
Hardik Satasiya On BEST ANSWER

Its relatively easy, you just need to add Accessor

In your modal add this Accessor

public function getImagePathAttribute() {
    return $this->image->path;
}

And in your modal's columns

columns:
  id:
    label: ID
    type: number
  name:
    label: Name
    type: text
    searchable: true
    sortable: true
  image_path:
    label: Image Path
    type: text

Now it will show the image's path as a column and you can export its value.

enter image description here

if any doubt please comment.