<?php

namespace App\Http\Controllers;

use Fivable\Buildable\Controllers\BuildablePageController as BaseBuildablePageController;

class BuildablePageController extends BaseBuildablePageController
{

//    /**
//     * Return all Buildable Pages
//     * @return JsonResponse
//     */
//    public function index() : JsonResponse
//    {
//        $this->authorizeForUser($this->user(), 'viewIndex', BuildablePage::class);
//
//        $pages = BuildablePage::all();
//
//        return response()->json([
//            'pages' => $pages,
//        ]);
//    }

//    /**
//     * Return a specific Buildable Page
//     * @param  BuildablePage   $buildablePage
//     * @return JsonResponse
//     */
//    public function show(BuildablePage $buildablePage) : JsonResponse
//    {
//        $this->authorizeForUser($this->user(), 'view', $buildablePage);
//
//        return response()->json([
//            'page' => $buildablePage,
//        ]);
//    }

//    /**
//     * Create a new Buildable Page
//     * @param  Request $request
//     * @return JsonResponse
//     */
//    public function store(Request $request) : JsonResponse
//    {
//        // TODO: Consider how storing components works (ajax to componentcontroller per component, or handled here???)
//        $this->authorizeForUser($this->user(), 'create', BuildablePage::class);
//
//        $newPage = BuildablePage::create($request->all());
//
//        return response()->json([
//            'new_page' => $newPage,
//        ]);
//    }

//    /**
//     * Update a specific Buildable Page
//     * @param  Request $request
//     * @param  BuildablePage   $buildablePage
//     * @return JsonResponse
//     */
//    public function update(BuildablePage $buildablePage, Request $request) : JsonResponse
//    {
//        // TODO: Consider how updating components works (ajax to componentcontroller per component, or handled here???)
//        $this->authorizeForUser($this->user(), 'update', $buildablePage);
//
//        $buildablePage->update($request->all());
//
//        return response()->json([
//            'updated_page' => $buildablePage->fresh(),
//        ]);
//    }

//    /**
//     * Delete a specific BuildablePage
//     * @param  BuildablePage  $buildablePage
//     * @return JsonResponse
//     * @throws \Exception
//     */
//    public function destroy(BuildablePage $buildablePage) : JsonResponse
//    {
//        // TODO: Consider how deleting components works (ajax to componentcontroller per component, or handled here???)
//        // TODO: I mean, are we even going to delete components linked to a deleted page?
//        $this->authorizeForUser($this->user(), 'delete', $buildablePage);
//
//        $buildablePage->delete();
//
//        return response()->json([
//            'deleted_page' => $buildablePage
//        ]);
//    }

//    /**
//     * Return the buildable-page view with
//     * @param Request $request
//     * @param BuildablePage $buildablePage
//     * @return View
//     */
//    public function showPublic(Request $request, BuildablePage $buildablePage) : View
//    {
//        $pageRenderer = new PageRenderer($buildablePage->content);
//
//        return view('buildable-page', compact('buildablePage', 'pageRenderer'));
//    }
}
