<?php

namespace App\Http\Controllers;

use App\Models\Room;
use Illuminate\Http\Request;

class RoomController extends Controller
{
    //


    protected function admin_all_rooms()
    {
        $rooms = Room::all();

//        dd($rooms);

        return view('admin.rooms.index', compact('rooms'));


    }



    protected function member_all_rooms()
    {
        $rooms = Room::all();

//        dd($rooms);

        return view('rooms.index', compact('rooms'));
    }


    protected function admin_new_room()
    {

        return view('rooms.create');

    }


    protected function admin_save_room(Request $request)
    {
        $request->validate([
            'room_name' => 'required|string|max:255',
            'room_number' => 'required|integer',
            'floor' => 'required|integer',
            'line' => 'required|integer',
            'room_description' => 'required|string',
            'room_type' => 'required|string',
            'room_price' => 'required',
            'room_condition' => 'required',
        ]);

        $room = new Room([
            'room_name' => $request->room_name,
            'room_description' => $request->room_description,
            'room_number' => $request->room_number,
            'room_price' => $request->room_price,
            'room_floor' => $request->floor,
            'line' => $request->line,
            'room_type' => $request->room_type,
            'room_condition' => $request->room_condition,
        ]);

        $room->save();


        return redirect()->back()->with('success', 'Room Created Successfully');

    }
}
