<?php

namespace App\Http\Controllers;

use App\Http\Resources\GlobalContentElementView;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Mtc\ContentManager\Models\ContentElement;
use Mtc\MercuryDataModels\GlobalContent;

class GlobalContentController extends Controller
{
    use DispatchesJobs;

    public function forElement(ContentElement $element)
    {
        $element->load('fields.childElement.fields.childElement.fields.childElement.fields');
        $content = new GlobalContent();
        $content->element_id = $element->id;
        $content->contentElement = $element;
        return new GlobalContentElementView($content);
    }
}
