PHP Laravel - How to use xSQL FUNC in model?

Tom

I want to use MySQL FUNC UUID() in the SQL is similar to this :

INSERT INTO users SET user_guid=UUID();

I know laravel has model when I create an user and add it to DB, I can do this :

$user = new User;
$user->user_guid = uniqid();
$user->username = Input::get('username');
$user->email = Input::get('email');
$user->password = Hash::make(Input::get('password'));
$user->save();

If I want to use MySQL FUNC UUID replace uniqid(), what can I do for that? Thanks.

Joseph Silber

Use DB::raw():

$user->user_guid = DB::raw('UUID()');

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related