Ejemplo de Codigo
Versión 1 (Guillermo Zdanowicz, 18/04/2017 09:18) → Versión 2/3 (Guillermo Zdanowicz, 18/04/2017 09:23)
h1. Ejemplo de Codigo
*VISTA: resources/views/vercuentas.blade.php* VISTA
<pre>
@extends('master')
@section('titulo','Listado de Cuentas')
@section('contenido')
<h1> CUENTAS </h1>
<? //{{ $resultado }} ?>
<ul>
@foreach($resultado as $item)
<li> {{ $item->id }} - {{ $item->descripcion }} </li>
@endforeach
</ul>
@endsection
</pre>
MODELO: /app/T_cuentas_persona.php CONTROLADOR
MODELO
<pre>
namespace App;
use App\T_cuentas_persona;
use Illuminate\Database\Eloquent\Model;
class T_cuentas_persona extends Model
{
public static function buscarcuentapersona($id)
{
return t_cuentas_persona::where('idpersona', $id)->join('t_cuentas as tc','idcuenta','=','tc.id')->get();
}
}
</pre>
*LAYOUT LAYOUT PERSONALIZADO : /resources/views/master.blade.php*
<pre>
<!DOCTIPE html>
<html>
<head>
<title>App - @yield('titulo')</title>
</head>
<body>
<h1>Logo</h1>
@yield('contenido')
</body>
</html>
</pre>
*ROUTING: routes/web.php* ROUTING
<pre>
/**
* Cuentas Personas
*/
Route::resource('t_cuentas_personas', 'T_cuentas_personasController');
Route::get('t_cuentas_personas/vercuentas/{id}','T_cuentas_personasController@obtenercuentas');
Route::get('vercuentas/{id}','cuentaspersonasController@vercuentas');
</pre>
*VISTA: resources/views/vercuentas.blade.php* VISTA
<pre>
@extends('master')
@section('titulo','Listado de Cuentas')
@section('contenido')
<h1> CUENTAS </h1>
<? //{{ $resultado }} ?>
<ul>
@foreach($resultado as $item)
<li> {{ $item->id }} - {{ $item->descripcion }} </li>
@endforeach
</ul>
@endsection
</pre>
MODELO: /app/T_cuentas_persona.php CONTROLADOR
MODELO
<pre>
namespace App;
use App\T_cuentas_persona;
use Illuminate\Database\Eloquent\Model;
class T_cuentas_persona extends Model
{
public static function buscarcuentapersona($id)
{
return t_cuentas_persona::where('idpersona', $id)->join('t_cuentas as tc','idcuenta','=','tc.id')->get();
}
}
</pre>
*LAYOUT LAYOUT PERSONALIZADO : /resources/views/master.blade.php*
<pre>
<!DOCTIPE html>
<html>
<head>
<title>App - @yield('titulo')</title>
</head>
<body>
<h1>Logo</h1>
@yield('contenido')
</body>
</html>
</pre>
*ROUTING: routes/web.php* ROUTING
<pre>
/**
* Cuentas Personas
*/
Route::resource('t_cuentas_personas', 'T_cuentas_personasController');
Route::get('t_cuentas_personas/vercuentas/{id}','T_cuentas_personasController@obtenercuentas');
Route::get('vercuentas/{id}','cuentaspersonasController@vercuentas');
</pre>