Skip to content

Folder Model ​

DB Table Name{wp_db_prefix}fbs_boards (rows with type = 'folder')
SchemaCheck Schema
Source Filefluent-boards/app/Models/Folder.php
Name SpaceFluentBoards\App\Models
ClassFluentBoards\App\Models\Folder

Folders group boards. They are stored in fbs_boards with type = 'folder'; the model adds that as a global scope and sets it on create, along with created_by (current user). Boards are placed in a folder through fbs_relations rows with object_type = 'FluentBoardsPro\App\Models\Folder' (Constant::OBJECT_TYPE_FOLDER_BOARD), where object_id is the folder ID and foreign_id is the board ID.

Attributes ​

AttributeData TypeComment
idINT UNSIGNEDPrimary key
parent_idINT UNSIGNED NULLParent folder (for sub-folders)
titleTEXT NULLFolder name
descriptionLONGTEXT NULLDescription
typeVARCHAR(50)Always folder
backgroundTEXT NULLSerialized; returned as an array
settingsTEXT NULLSerialized; returned as an array
created_byINT UNSIGNEDCreator user ID
archived_atTIMESTAMP NULLArchive time
created_atTIMESTAMP NULLHidden
updated_atTIMESTAMP NULLHidden

Appended attribute meta: folder meta from fbs_metas (object_type = 'board') as a key => value array.

toArray()

toArray() is overridden and returns only id, title, created_by and boards_ids (the IDs of the boards in the folder). It loads the boards relation to do so.

Usage ​

Please check Model Basic for common methods.

php
use FluentBoards\App\Models\Folder;

$folder = Folder::create(['title' => 'Client Projects']);

// Put board 12 in the folder
$folder->boards()->attach(12, [
    'object_type' => \FluentBoards\App\Services\Constant::OBJECT_TYPE_FOLDER_BOARD,
]);

$folders = Folder::whereNull('archived_at')->get();

Relations ​

boards ​

Boards in the folder. Pivot: settings. The Board global scope applies, so only to-do and roadmap boards are returned.

  • Returns a collection of FluentBoards\App\Models\Board
php
$boardTitles = $folder->boards->pluck('title');

parentFolder ​

  • Returns FluentBoards\App\Models\Folder or null

subFolders ​

Non-archived child folders.

  • Returns a collection of FluentBoards\App\Models\Folder

See also Board::removeBoardFromFolder() on the Board page.