public function store_user(Request $req)
{
mod_user::create($req->all());
Session::flash('flash_message', 'User Data Saved');
return redirect('adduser');
}
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class mod_user extends Model
{
protected $table = 'tbl_user';
protected $fillable = [
'nama_user',
'level_akses',
'contact',
'eMail',
'password'
];
protected $guarded = ['status'];
}
how to do that? @Asser90
You can use mutators.
Accessors and mutators allow you to format Eloquent attributes when retrieving them from a model or setting their value. from laravel documentation.
If you want for some reason manipulate model attribute before saving to DB
you can define a mutator method:
public function setEMailAttribute($value){
$this->attributes['eMail'] = $value.'@id.mail.com';
}
Name of mutator method must be studly cased, and has word set before and word Attribute after it.
bikasoon said:
You can use mutators.
Accessors and mutators allow you to format Eloquent attributes when retrieving them from a model or setting their value. from laravel documentation.
If you want for some reason manipulate model attribute before saving to
DB
you can define a mutator method:public function setEMailAttribute($value){ $this->attributes['eMail'] = $value.'@id.mail.com'; }
Name of mutator method must be studly cased, and has word set before and word Attribute after it.
Thank you :D
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community