Eloquent where-()-firstOrFail() doesn't return attributes

I'm using Laravel 4.1. I have a table profiles and an class Profiles that extends Eloquent with protected $table = 'profiles'. There's a row in the table with id = 1 and first_name = 'Admin'. I have the following code:


I'm not getting any failure but nor am I getting any of the table attributes. $profile->first_name is null. What am I doing wrong?


when you use where() method use it with model like this

$profile = Profile::where('id','=',1)->firstOrFail(); 


$profile = Profile::where('id',1)->firstOrFail(); 


use findOrFail() method if you need to search with id

$profile = Profile::findOrFail(1);

You can use find or findOrFail method, which searches by id columns on it's own.


// or using Facade


Stupid newbie! I wasn't using the static methods, but rather trying to use the methods on an instantiated object.




Need Your Help

How to use html type="date" for count in sql for number of student enrolled in a year?

mysql sql codeigniter

I have a problem on how to count number of students in a year enroll?

To implement Encryption using 3DES in java

java security

I have to implement 3DES encryption using 3DES in java.