. */ namespace Database\Factories; use App\Account; use App\Password; use Illuminate\Database\Eloquent\Factories\Factory; class PasswordFactory extends Factory { protected $model = Password::class; public function definition() { $account = Account::factory()->create(); $realm = space()?->account_realm ?? $account->domain; return [ 'account_id' => $account->id, 'password' => hash('md5', $account->username.':'.$realm.':testtest'), 'algorithm' => 'MD5', ]; } public function admin() { return $this->state(function (array $attributes) { $account = Account::find($attributes['account_id']); $account->admin = true; $account->save(); return $attributes; }); } public function sha256() { return $this->state(function (array $attributes) { $account = Account::find($attributes['account_id']); $realm = space()?->account_realm ?? $account->domain; return [ 'password' => hash('sha256', $account->username.':'.$realm.':testtest'), 'account_id' => $account->id, 'algorithm' => 'SHA-256', ]; }); } public function clrtxt() { return $this->state(fn (array $attributes) => [ 'password' => 'testtest', 'algorithm' => 'CLRTXT', ]); } }