Skip to main content

Overview

The Cliente model represents clients in the VIP2CARS system. It handles client information including personal details, contact information, and manages the relationship with their vehicles.

Database Configuration

table
string
default:"clientes"
Database table name
primaryKey
string
default:"id_cliente"
Primary key column name

Fillable Attributes

The following attributes can be mass-assigned:
nombres
string
required
Client’s first name(s)
apellidos
string
required
Client’s last name(s)
nro_documento
string
required
Client’s document number (ID card, passport, etc.)
correo
string
required
Client’s email address
telefono
string
required
Client’s phone number

Relationships

vehiculos()

Defines a one-to-many relationship with the Vehiculo model. A client can have multiple vehicles. Relationship Type: hasMany Related Model: App\Models\Vehiculo Foreign Key: id_cliente Local Key: id_cliente
public function vehiculos()
{
    return $this->hasMany(Vehiculo::class, 'id_cliente', 'id_cliente');
}

Usage Examples

use App\Models\Cliente;

$cliente = Cliente::create([
    'nombres' => 'Juan Carlos',
    'apellidos' => 'Pérez García',
    'nro_documento' => '12345678',
    'correo' => '[email protected]',
    'telefono' => '+51987654321',
]);

Model Source

Location: app/Models/Cliente.php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Cliente extends Model
{
    protected $table = 'clientes';
    protected $primaryKey = 'id_cliente';
    
    protected $fillable = [
        'nombres',
        'apellidos',
        'nro_documento',
        'correo',
        'telefono',
    ];

    public function vehiculos()
    {
        return $this->hasMany(Vehiculo::class, 'id_cliente', 'id_cliente');
    }
}

Build docs developers (and LLMs) love