# -*- encoding : utf-8 -*-

class Admin::LabelCategoriesController < ApplicationController
  layout "admin"
  before_filter :auth_admin

  def index
    @label_categories = LabelCategory.all

   
  end

  def show
    @label_category = LabelCategory.find(params[:id])

  end

  def new
    
    
		@label_category = LabelCategory.new(:label_famille_id => params[:label_famille_id])
    

  end

 

  def edit
  
    
    @label_category = LabelCategory.find(params[:id])
  end

  def create
    @label_category = LabelCategory.new(params.require(:label_category).permit!)


    if @label_category.save
     redirect_to admin_label_famille_path(@label_category.label_famille), notice: 'La marque a été crée.' 
      
    else
      render action: "new"
 
    end

  end


  def update
    @label_category = LabelCategory.find(params[:id])


    if @label_category.update_attributes(params.require(:label_category).permit!)
      redirect_to admin_label_famille_path(@label_category.label_famille), notice: 'Les infos sur la marque ont été mise à jour.' 
     
    else
     render action: "edit" 
      
    end
      
  end


  def destroy
    @label_category = LabelCategory.find(params[:id])
    @label_category.destroy
    
  
    redirect_to admin_label_famille_path(@label_category.label_famille), notice: 'La catégorie a été supprimée.' 
     

  end
end
