Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

370
Views
Laravel 5.8: error extraño al intentar obtener la propiedad 'created_at' de un no objeto

Estoy usando Laravel 5.8 para desarrollar mi proyecto y en este proyecto, tengo una relación OneToMany entre el modelo de Member y el modelo de Student como esta:

Student.php :

 public function member() { return $this->belongsTo(Student::class, 'std_mbr_id'); }

Member.php :

 public function student() { return $this->hasOne(Student::class,'std_mbr_id'); }

Luego, en el controlador, agregué esto:

 public function index() { $student = new Student(); $students = $student->searchStudents()->paginate(20); $custom = new Student(); $customs = $custom->all(); return view('admin.students.custom', compact('students','customs')); }

Ahora, en la vista, quiero obtener created_at timestamp de esta manera:

$customs->find($student->mbr_id)->created_at

Pero esto devolverá este error:

Intentando obtener la propiedad 'created_at' de un no objeto

Sin embargo, cuando hago dd($customs->find($student->mbr_id)) , puedo obtener correctamente las marcas de tiempo:

ingrese la descripción de la imagen aquí

Entonces, ¿cómo acceder a la marca de tiempo created_at en esta situación?


ACTUALIZACIÓN #1:

Resultado de {{ dd($customs->find($student->mbr_id)->created_at ) }} :

ingrese la descripción de la imagen aquí

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Primero verifique si $customs->find($student->mbr_id) devuelve algo:

 $customs->find($student->mbr_id) ? $customs->find($student->mbr_id)->created_at : 'not found';
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!