Commit a18c0542 authored by Alfonso Rafael Solis Rangel's avatar Alfonso Rafael Solis Rangel
Browse files

Creacion del modelo, migracion y controlador de los contactos

parent af61fe26
Loading
Loading
Loading
Loading
+65 −0
Original line number Diff line number Diff line
<?php

namespace App\Http\Controllers;

use App\Models\Contacto;
use Illuminate\Http\Request;

class ContactoController extends Controller
{
    /**
     * Display a listing of the resource.
     */
    public function index()
    {
        //
    }

    /**
     * Show the form for creating a new resource.
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     */
    public function show(Contacto $contacto)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     */
    public function edit(Contacto $contacto)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     */
    public function update(Request $request, Contacto $contacto)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     */
    public function destroy(Contacto $contacto)
    {
        //
    }
}
+42 −0
Original line number Diff line number Diff line
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Contacto extends Model
{
    use HasFactory;

    //TODO Agregar la relacion hacia la tabla instituciones cuando Alejandro la tenga terminada.

    protected $fillable = [
        'nombre',
        'ap_paterno',
        'ap_materno',
        'cargo_desc',
        'mes_cump',
        'dia_cump',
        'domicilio_oficial',
        'codigo_postal',
        'localidad_oficial',
        'municipio_oficial',
        'estado',
        'pais',
        'domicilio_par',
        'cp_par',
        'localidad_par',
        'municipio_par',
        'estado_par',
        'pais_par',
        'finado',
        'foto_perfil',
        'conyuge_id',
        'profesion_id',
        'cargo_id',
        'caracteristica_id',
        //'institucion_id',
        'subgrupo_id',
    ];
}
+61 −0
Original line number Diff line number Diff line
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     * TODO Agregar la relacion hacia la tabla instituciones cuando Alejandro la tenga terminada.
     */
    public function up(): void
    {
        Schema::create('contactos', function (Blueprint $table) {
            $table->id();
            $table->string('nombre');
            $table->string('ap_paterno');
            $table->string('ap_materno');
            $table->string('cargo_desc');
            $table->integer('mes_cump');
            $table->integer('dia_cump');
            $table->string('domicilio_oficial');
            $table->integer('codigo_postal');
            $table->string('localidad_oficial');
            $table->string('municipio_oficial');
            $table->string('estado');
            $table->string('pais');
            $table->string('domicilio_par');
            $table->integer('cp_par');
            $table->string('localidad_par');
            $table->string('municipio_par');
            $table->string('estado_par');
            $table->string('pais_par');
            $table->boolean('finado');
            $table->string('foto_perfil');
            $table->unsignedBigInteger('conyuge_id')->nullable();
            $table->unsignedBigInteger('profesion_id')->nullable();
            $table->unsignedBigInteger('cargo_id')->nullable();
            $table->unsignedBigInteger('caracteristica_id')->nullable();
            //$table->unsignedBigInteger('institucion_id')->nullable();
            $table->unsignedBigInteger('subgrupo_id')->nullable();
            
            $table->foreign('conyuge_id')->references('id')->on('contactos')->nullable();
            $table->foreign('profesion_id')->references('id')->on('profesions')->nullable();
            //$table->foreign('institucion_id')->references('id')->on('')->nullable();
            $table->foreign('cargo_id')->references('id')->on('cargos')->nullable();
            $table->foreign('caracteristica_id')->references('id')->on('caracteristicas')->nullable();
            $table->foreign('subgrupo_id')->references('id')->on('subgrupos')->nullable();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('contactos');
    }
};