laravel - 如何使用 Laravel 在同一个模型中编写两个表?
问题描述
我想在同一模型中创建另一个包含其他列的表。这可能吗?
这是我的模型
<?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'];
}
解决方案
首先我应该说每个模型都是为一个特定的表编写的,除非它们是相关的,否则你不能将两个表压缩到一个模型中。看这里
推荐阅读
- python - 使用另一个数组创建一个由 1 和 0 组成的数组
- mongodb - MongoDB聚合查询可行性
- javascript - 无法使两个功能一起工作
- c# - 统一为我的游戏制作重置菜单,但不知道如何将碰撞设置为不同的场景
- c++ - 问题动态分配类
- spring-boot - Spring boot @Scheduler 在 Google Kubernetes Engine 中不起作用
- reactjs - 警告:在 React 中使用 forwardRef 无法给函数组件提供 refs 警告
- python - Hive/Bigsql pandas 浮点转换为整数,使用 pyarrow 将空值转换为镶木地板文件
- android - FFmpeg 从 stremed 文件或缓冲区或麦克风将 wav 编码为手机上的 mp3
- python - 尝试将 django 应用程序部署到 heroku 并遇到收集静态 storage.py 路径的问题