Oscar
Oscar

Reputation: 139

How to write two tables in the same model using Laravel?

I would like to create another table with another columns in the same model.. is it posible?

This is my model

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
class Tbl_Perimetro extends Model
{
protected $table = "tbl_perimetros";
protected $fillable = [
'id', 'rif', 'act', 'razon_social', 'holdings_id', 'tipo', 'facturando', 'pines_id', 'regionduenas_id', 'sectoreconomicos_id', 'segmentos_id', 'segmentacionatcs_id', 'segmentacionings_id', 'estatus', 'equipos_id', 'ing', 'cobranzas_id', 'comerciales_id', 'ingpreventa_id', 'ingproyectos_id', 'postventaatc_id', 'postventaing_id'
];
protected $guarded = ['id'];
}

Upvotes: 0

Views: 121

Answers (1)

Waleed Muaz
Waleed Muaz

Reputation: 802

Firstly I should say each model is written for a specific table, you can't squeeze two tables into one model unless they are related. See Here

Upvotes: 2

Related Questions