<?php

namespace App\Http\Controllers;

use App\Models\Proprietaire;
use Illuminate\Http\Request;
use DB;
use App\Models\Bien;

class QuestionController extends Controller
{
    public function __construct()
    {
        $this->middleware('auth');
    }
    
    public function entreprise(){
        return view('questions.entreprise');
    }

    public function conjoint(){
        $proprietaire = DB::table('proprietaires')->latest()->first();
        return view('questions.conjoint', [
            'proprietaire' =>  $proprietaire,
        ]);
    }

    public function coproprietaire(){
        $proprietaire = DB::table('proprietaires')->latest()->first();
        return view('questions.coproprietaire', [
            'proprietaire' =>  $proprietaire,
        ]);
    }

    public function vente_location($bienId){
        $bienId = Bien::find($bienId);
        return view('questions.vente_location', [
            'bienId' =>  $bienId,
        ]);
    }

    public function enregistre(){
        return redirect()->route('home')->with('message','Un propriétaire a été créé.');
    }
}
