<?php

namespace App\Http\Controllers;

use App\Models\{Proprietaire, Conjoint};
use Illuminate\Http\Request;
use DB;

class ConjointController extends Controller
{
    public function __construct()
    {
        $this->middleware('auth');
    }
    
    public function create(){
        $proprietaire = DB::table('proprietaires')->latest()->first();
        return view('conjoints.create',['proprietaire' => $proprietaire]);
    }

    public function store(Request $request){

        Conjoint::create($request->all());

        $proprietaire = DB::table('proprietaires')->latest()->first();

        return redirect()->route('coproprietaire.create',$proprietaire->id);
    }
}
