<?php

namespace App\Models;



use Illuminate\Database\Eloquent\Model;

class SiteAlbum extends Model
{

    protected $table = 'site_album';

    public static function getAllPoster($title)
    {
        //查找
        $foldersIds  = SiteAlbumFolder::getfolderTreeIds($title);
        //查找
        $result =  SiteAlbum::where('poster','<>', '[]')->whereIn('folder_id', $foldersIds)->get();
        $data = [];
        foreach ($result as $item) {
            $poster = json_decode($item->poster, true);
            foreach ($poster as $p) {
                $data[] = $p;
            }
        }

        return json_encode($data);
    }

}
