<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Http\Requests\SpatialisationRequest;
use App\Models\Spatialisation;

class SpatialisationsController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \App\Http\Requests\SpatialisationRequest  $request
     * @return \Illuminate\Http\Response
     */
    public function store(SpatialisationRequest $request)
    {
        Spatialisation::create($request->getSpatialisationPayload());

        return back();
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \App\Http\Requests\SpatialisationRequest  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(SpatialisationRequest $request, Spatialisation $spatialisation)
    {dd($request->getSpatialisationPayload());
        $spatialisation->update($request->getSpatialisationPayload());

        return back();
    }

    public function confirmed(Spatialisation $spatialisation)
    {//dd($spatialisation->id);
        $spatialisation->update(['confirmed' => !$spatialisation->confirmed]);

        return back();
    }


    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }
}
