/** * @param Block $block * @param CmgFile $banner * @param CmgFile $texture * @param CmgFile $video * @return Block */ public static function create($block, $banner = null, $texture = null, $video = null) { if (isset($block->templateId) && $block->templateId <= 0) { unset($block->templateId); } if (isset($banner)) { FileService::saveImage($banner, ['model' => $block, 'attribute' => 'bannerId']); } if (isset($texture)) { FileService::saveImage($texture, ['model' => $block, 'attribute' => 'textureId']); } if (isset($video)) { FileService::saveImage($video, ['model' => $block, 'attribute' => 'videoId']); } // Create Block $block->save(); return $block; }