Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Commit

Permalink
tipo relacion ajustes
Browse files Browse the repository at this point in the history
  • Loading branch information
rats4final committed Nov 10, 2022
1 parent 5bb6b15 commit 4c2b31d
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 0 deletions.
91 changes: 91 additions & 0 deletions app/Http/Controllers/TipoRelacionController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?php

namespace App\Http\Controllers;

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

class TipoRelacionController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$TipoRelaciones = TipoRelacion::get();
return view('admin.tipo_relacion.index', compact('TipoRelaciones'));
}

/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
return view('admin.tipo_relacion.create');
}

/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$datos = $request->all();
TipoRelacion::create($datos);
return to_route('TipoRelacion.index');
}

/**
* Display the specified resource.
*
* @param \App\Models\TipoRelacion $TipoRelacion
* @return \Illuminate\Http\Response
*/
public function show(TipoRelacion $TipoRelacion)
{
return view('admin.tipo_relacion.show', compact('TipoRelacion'));
}

/**
* Show the form for editing the specified resource.
*
* @param \App\Models\TipoRelacion $tipoRelacion
* @return \Illuminate\Http\Response
*/
public function edit(TipoRelacion $tipoRelacion)
{
return view('admin.tipo_relacion.edit', compact('tipoRelacion'));
}

/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Models\TipoRelacion $tipoRelacion
* @return \Illuminate\Http\Response
*/
public function update(Request $request, TipoRelacion $tipoRelacion)
{
$datos = $request->all();
$tipoRelacion->update($datos);
return to_route('TipoRelacion.index');
}

/**
* Remove the specified resource from storage.
*
* @param \App\Models\TipoRelacion $tipoRelacion
* @return \Illuminate\Http\Response
*/
public function destroy(TipoRelacion $tipoRelacion)
{
$tipoRelacion->delete();
return to_route('TipoRelacion.index');
}
}
25 changes: 25 additions & 0 deletions app/Models/TipoRelacion.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace App\Models;

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

class TipoRelacion extends Model
{
use HasFactory;
protected $primaryKey = 'id_tipo_relacion';
protected $table = 'tipo_relacion';
protected $fillable = [
'relacion',
'id_persona',
'id_pariente'
];

public function persona(){
return $this->hasOne(Persona::class,'id_persona','id_persona');
}
public function pariente(){
return $this->hasOne(Persona::class,'id_persona','id_pariente');
}
}

0 comments on commit 4c2b31d

Please sign in to comment.