bcrypt password

Laraship QuestionsCategory: Technicalbcrypt password
nao asked 6 years ago
I have a question. At UsersController class, store() and update() functions don't code to bcrypt password. Instead, in User class of Model, setPasswordAttribute() function executes bcrypt. I code bcypt password in store() function of class extends BaseController. The code is like below: public function store(OriginalRequest $request) { try { $data = $request->except($this->excludedRequestParams); $class = OriginalClass::create($data); $class->password = bcrypt($request->password); flash(trans('Corals::messages.success.created', ['item' => $this->title_singular]))->success(); } catch (Exception $exception) { log_exception($exception, Instructor::class, 'store'); }
return redirectTo($this->resource_url);
} But password is stored as raw string into database. Even if I code bcyrpt password at store() function, is password stored as raw string in Laraship? Or simply is my above code or my way wrong?
nao replied 6 years ago

I fixed this problem.
This is why OriginalClass::create($data) is executed, data is stored into table.

But as a tip, please let me ask.
In User class of Model, how and when is setPasswordAttribute() called?

1 Answers
laraship Staff answered 6 years ago

Hello,

This is Laravel standard way to define object attribute like $user->example then you create a function called getExampleAttribue() and setExampleAttribute

the user thumbnail attribute is an example in Laraship