. */ 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 = config('app.realm') ?? $account->domain; return [ 'account_id' => $account->id, 'password' => hash('md5', $account->username.':'.$realm.':testtest'), 'algorithm' => 'MD5', ]; } public function sha256() { return $this->state(function (array $attributes) { $account = Account::find($attributes['account_id']); $realm = config('app.realm') ?? $account->domain; return [ 'password' => hash('sha256', $account->username.':'.$realm.':testtest'), 'account_id' => $account->id, 'algorithm' => 'SHA-256', ]; }); } public function clrtxt() { return $this->state(function (array $attributes) { return [ 'password' => 'testtest', 'algorithm' => 'CLRTXT', ]; }); } }