-
Hello all, I installed "orchid/platform": "^12.4" within "laravel/framework": "^9.0" existing project
NB : Updating a user seems to be successfull. This is the query exception :
This is the post request :
And this the actual User model definition : <?php
namespace App\Models;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
// use Illuminate\Foundation\Auth\User as Authenticatable;
use Orchid\Platform\Models\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
use HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name',
'email',
'password',
'permissions',
];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = [
'password',
'remember_token',
'permissions',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'permissions' => 'array',
'email_verified_at' => 'datetime',
];
/**
* The attributes for which you can use filters in url.
*
* @var array
*/
protected $allowedFilters = [
'id',
'name',
'email',
'permissions',
];
/**
* The attributes for which can use sort in url.
*
* @var array
*/
protected $allowedSorts = [
'id',
'name',
'email',
'updated_at',
'created_at',
];
} Does someone have any idea of what's going on in my code ? Thanks 🙏 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
At this point, I tested deeper. With setting the columns nullable in the database, bypassed the error message, creating a user without password even if the field was filled. So I went to // app\Orchid\Screens\User\UserEditScreen.php:183
$user->when($user->exists && ! empty($userData['password']), function (Builder $builder) use ($userData) {
$builder->getModel()->password = Hash::make($userData['password']);
}); I added : // app\Orchid\Screens\User\UserEditScreen.php:188
// User doesn't exists ==> create dans handle password
$user->when(!$user->exists, function (Builder $builder) use ($userData) {
$builder->getModel()->password = Hash::make($userData['password']);
}); And it works ! I'm able to create a user with a password, ans still able to update an existing user's password. |
Beta Was this translation helpful? Give feedback.
At this point, I tested deeper.
With setting the columns nullable in the database, bypassed the error message, creating a user without password even if the field was filled.
So I went to
app\Orchid\Screens\User\UserEditScreen.php
and looked how the save action was handled by the screen. At about line 183, I added the handling method for creating a user.So after :
I added :