This repository has been archived by the owner on Apr 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5bb6b15
commit 4c2b31d
Showing
2 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
} |