Created
May 12, 2015 15:10
-
-
Save herusdianto/71f85d05e51f483c5761 to your computer and use it in GitHub Desktop.
Laravel Eloquent lists multiple column.
This file contains hidden or 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
<?php namespace App; | |
use DB; | |
use Illuminate\Auth\Authenticatable; | |
use Illuminate\Database\Eloquent\Model; | |
use Illuminate\Auth\Passwords\CanResetPassword; | |
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; | |
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract; | |
class User extends Model implements AuthenticatableContract, CanResetPasswordContract { | |
use Authenticatable, CanResetPassword; | |
/** | |
* The database table used by the model. | |
* | |
* @var string | |
*/ | |
protected $table = 'users'; | |
/** | |
* The attributes that are mass assignable. | |
* | |
* @var array | |
*/ | |
protected $fillable = ['name', 'email', 'password']; | |
/** | |
* The attributes excluded from the model's JSON form. | |
* | |
* @var array | |
*/ | |
protected $hidden = ['password', 'remember_token']; | |
/** | |
* get first name and last name | |
*/ | |
public static function getFullName() | |
{ | |
return self::select(DB::raw("CONCAT(first_name, ' ', last_name) AS full_name, id"))->lists('full_name', 'id'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment