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