<?php

namespace App\Http\Controllers;

use App\Models\{
    AgricoleViticole,
    Bien
};
use Illuminate\Http\Request;

class AgricoleViticoleController extends Controller
{
    public function __construct()
    {
        $this->middleware('auth');
    }
    
    /**
     * 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  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request, $bienId)
    {
        $terrain = AgricoleViticole::create($request->all());
        Bien::where('id',$bienId)->update(['agricole_viticole_id' => $terrain->id]);
        $bienId = Bien::find($bienId);

        return redirect()->route('flux.create',['bienId' => $bienId]);
    }

    /**
     * Display the specified resource.
     *
     * @param  \App\Models\AgricoleViticole  $agricoleViticole
     * @return \Illuminate\Http\Response
     */
    public function show(AgricoleViticole $agricoleViticole)
    {
        //
    }

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

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\AgricoleViticole  $agricoleViticole
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, AgricoleViticole $agricoleViticole)
    {
        //
    }

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