class CarLogsController < ApplicationController
	def log #index
		@carlogs = CarLog.all
	end

	def show
		@carlog = CarLog.find(params[:id])

	end

	def destroy
		@carlog = CarLog.find(params[:id])
		@carlog.destroy()

		redirect_to carlogs_path
	end

	def new
		@carlog = CarLog.new

	end

	def create
		@carlog = CarLog.new

		@carlog.plate_number = params[:plate_number]
		@carlog.brand = params[:brand]
		@carlog.slot_number = params[:slot_number]
		@carlog.is_taken = params[:is_taken]

		if @carlog.save
			redirect_to carlogs_path, notice: "Car Record was successfully added"
		else
			render 'new'
		end

	end 

	private 
	def carlog_params
		params.require(:carlog).permit!
	end
end
