I have built a plugin that should function as a file manager where you can download on the frontend, the backend is almost ready and I am busy creating the component (which has started with scaffolding) I have already built several components but now I am running into a problem where I can’t figure out what I’m doing wrong. i get the following error: The component 'Nielsvandendries\Toolkit\Components\Files' does not contain a method 'where'.
Below is the content of my component php file
<?php namespace Nielsvandendries\Toolkit\Components;
use Cms\Classes\ComponentBase;
use Nielsvandendries\Toolkit\Models\Filemanager;
/**
* Files Component
*
* @link https://docs.octobercms.com/3.x/extend/cms-components.html
*/
class Files extends ComponentBase
{
public $fileslist;
public function componentDetails()
{
return [
'name' => 'filesList',
'description' => 'always watch the simpsons'
];
}
/**
* @link https://docs.octobercms.com/3.x/element/inspector-types.html
*/
public function defineProperties()
{
return [
'file_owner' => [
'title' => 'File Owner',
'description' => 'Owner selectie',
'type' => 'dropdown',
]
];
}
public function getOwnerOptions()
{
return Files::get()->lists('file_owner', 'file_owner');
}
public function onRun()
{
$this->fileslist = Files::where('file_owner', $this->property('file_owner'))->get()->toArray();
}
}
The problem is that when this component runs, it executes the static method where, this does not exist. I think you’re trying to use the Files model, so you are missing a use statement. I would suggest renaming your Files component to something else, like FileBrowser, if you are using a Files model.