app/User.php
<?php
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Support\Facades\Hash;
use Prettus\Repository\Contracts\Transformable;
use Prettus\Repository\Traits\TransformableTrait;
class User extends Authenticatable implements Transformable
{
use TransformableTrait;
/**
* 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'];
public function setPasswordAttribute($pass)
{
$this->attributes['password'] = Hash::make($pass);
}
/**
* Get all the posts for a given User.
*/
public function posts()
{
return $this->hasMany(Post::class);
}
}