Problemas con la conculta a la BD
Publicado por solimar (1 intervención) el 04/10/2017 15:21:26
Buneos dias, en estos momentos me encuentro practicando laravel de un tutorial de youtube que da "mascodigonet" y la verdad que todo me ha dado pero cuando se va a realizar una consulta a la BD para solo traerse un objeto o dato me da error y he hecho tal y como lo explica pero no me da y a el si por supuesto, aqui les dejo el codigo y error que me arroja, Agradezco su ayuda gracias!!!:
/********************CONTROLADOR*********************
/*****************************VISTA*********************
/************************ERROR QUE MA ARROJA********************
(2/2) ErrorException
Trying to get property of non-object (View: C:\Users\solimar.carrascal\Desktop\SOLIMAR\proyectolaravel5.4\resources\views\app\student\edit.blade.php)
in 97ffd1526e3d08115d186aec48157aa72527e1af.php (line 7)
at CompilerEngine->handleViewException(object(ErrorException), 1)
in PhpEngine.php (line 44)
at PhpEngine->evaluatePath('C:\\Users\\solimar.carrascal\\Desktop\\SOLIMAR\\proyectolaravel5.4\\storage\\framework\\views/97ffd1526e3d08115d186aec48157aa72527e1af.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'editStudent' => null))
in CompilerEngine.php (line 59)
at CompilerEngine->get('C:\\Users\\solimar.carrascal\\Desktop\\SOLIMAR\\proyectolaravel5.4\\resources\\views/app/student/edit.blade.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'editStudent' => null))
in View.php (line 137)
......
/********************CONTROLADOR*********************
1
2
3
4
5
6
7
8
9
10
11
12
public function edit($id)
{
$estudiante = DB::table('students')
->join('peoples', 'students.people_id', '=', 'peoples.id')
->where('students.id', $id)
->first(); //recupera un objeto
return view('app.student.edit',[
'editStudent'=>$estudiante
]);/**/
}
/*****************************VISTA*********************
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
@extends('app.layouts.app')
@section('title', 'Editar Estudiante')
@section('content')
<div class="col-lg-10 col-lg-offset-1">
<h2>FORMULARIO DE EDICIÓN DE ESTUDIANTE</h2>
{{ Form::open(['route'=>['estudiante.update', $editStudent->id],'method' => 'patch', 'role' => 'form']) }}
<!-- Y AQUI PROCEDEMOS A CREAR LOS ELEMENTOS DE NUESTRO FORMULARIO-->
<div class="col-lg-6">
<div>
{{ Form::label('rude', 'RUDE') }}
{{ Form::text('rude', $editStudent->rude, ['class' => 'form-control','required'=>'true','minlength'=>'3'])}}
</div>
<div>
{{ Form::label('name', 'NOMBRE') }}
{{ Form::text('name',$editStudent->name, ['class' => 'form-control','required'=>'true','minlength'=>'3']) }}
</div>
</div>
<div class="col-lg-6">
<div>
{{ Form::label('firstname', 'APELLIDO PATERNO') }}
{{ Form::text('firstname',$editStudent->firstname, ['class' => 'form-control','required'=>'true','minlength'=>'3']) }}
</div>
<div>
{{ Form::label('lastname', 'APELLIDO MATERNO') }}
{{ Form::text('lastname',$editStudent->lastname, ['class' => 'form-control','required'=>'true','minlength'=>'3']) }}
</div>
</div>
<br>
<div class="col-lg-12">
<div class="form-group">
<a href="{{ route('estudiante.index')}}" class="btn btn-danger"> CANCELAR </a>
<button type="submit" class="btn btn-success"> GUARDAR</button>
</div>
</div>
{{ Form::close() }}
</div>
@endsection
/************************ERROR QUE MA ARROJA********************
(2/2) ErrorException
Trying to get property of non-object (View: C:\Users\solimar.carrascal\Desktop\SOLIMAR\proyectolaravel5.4\resources\views\app\student\edit.blade.php)
in 97ffd1526e3d08115d186aec48157aa72527e1af.php (line 7)
at CompilerEngine->handleViewException(object(ErrorException), 1)
in PhpEngine.php (line 44)
at PhpEngine->evaluatePath('C:\\Users\\solimar.carrascal\\Desktop\\SOLIMAR\\proyectolaravel5.4\\storage\\framework\\views/97ffd1526e3d08115d186aec48157aa72527e1af.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'editStudent' => null))
in CompilerEngine.php (line 59)
at CompilerEngine->get('C:\\Users\\solimar.carrascal\\Desktop\\SOLIMAR\\proyectolaravel5.4\\resources\\views/app/student/edit.blade.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'editStudent' => null))
in View.php (line 137)
......
Valora esta pregunta
0