class CollectSalariesController < ApplicationController
  def index
    @collect_salaries = CollectSalary.page(params[:page]).per(20)
  end

  def new
    @collect_salary = CollectSalary.new
  end

  def create
    @collect_salary = CollectSalary.new(collect_salary_params)
    if @collect_salary.save
      redirect_to @collect_salary
    else
      render 'edit'
    end
  end

  def show
    @collect_salary = CollectSalary.find(params[:id])
  end

  def edit
    @collect_salary = CollectSalary.find(params[:id])
  end

  def update
    @collect_salary = CollectSalary.find(params[:id])
    if @collect_salary.update(collect_salary_params)
      redirect_to @collect_salary
    else
      render 'edit'
    end
  end

  def destroy
    @collect_salary = CollectSalary.find(params[:id])
    @collect_salary.destroy
    redirect_to collect_salaries_path
  end

  private
  def collect_salary_params
    params.require(:collect_salary).permit(:user_id, :money, :collect_date,:notes)
  end
end
