• File: Product.php
  • Full Path: /var/www/paytekchalenge/app/Models/Product.php
  • Date Modified: 07/19/2022 7:23 PM
  • File size: 1.32 KB
  • MIME-type: text/x-php
  • Charset: utf-8
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Product extends Model
{
    //Dados do Modelo antido...*
//    protected $fillable = ['title', 'description', 'quantMin', 'quantity', 'price',
//        'product_code', 'statuses_id', 'clubs_id', 'colors_id', 'tamanhos_id', 'subcategorias_id'];

    //dados actualizados
    protected $fillable = ['title', 'product_code', 'statuses_id', 'clubs_id', 'visible', 'image',
        'product_category_id', 'subcategorias_id', 'description'];


    public $table = "products";


    public function imagens(){
        return $this->hasMany('App\Models\Image', 'products_id');
    }

    public function proditem(){
        return $this->hasOne('App\ProductItem', 'product_id');
    }

    public function cor(){
        return $this->belongsTo('App\Models\Color','colors_id');
    }

    public function size(){
        return $this->belongsTo('App\Models\Tamanho', 'tamanhos_id');
    }

    public function club(){
        return $this->belongsTo('App\Models\Club','clubs_id');
    }

    public function status(){
        return $this->belongsTo('App\Models\Status','statuses_id');
    }


    public function subcategorias(){
        return  $this->belongsTo('App\Models\ProductoSubcategoria','subcategorias_id');
    }

}