2016-12-19 11:04:28 -08:00
|
|
|
<?php
|
|
|
|
|
2021-06-10 13:17:44 -07:00
|
|
|
namespace Database\Factories;
|
|
|
|
|
2023-03-15 14:12:34 -07:00
|
|
|
use App\Models\Company;
|
2023-03-16 12:46:47 -07:00
|
|
|
use App\Models\User;
|
2021-06-10 13:19:27 -07:00
|
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
2021-12-01 23:33:20 -08:00
|
|
|
use \Auth;
|
2021-06-10 13:17:44 -07:00
|
|
|
|
|
|
|
class UserFactory extends Factory
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Define the model's default state.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function definition()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'activated' => 1,
|
2021-12-02 16:43:03 -08:00
|
|
|
'address' => $this->faker->address(),
|
|
|
|
'city' => $this->faker->city(),
|
2023-03-15 14:12:34 -07:00
|
|
|
'company_id' => Company::factory(),
|
2021-12-02 16:43:03 -08:00
|
|
|
'country' => $this->faker->country(),
|
2023-03-16 16:38:21 -07:00
|
|
|
'email' => $this->faker->safeEmail(),
|
2021-06-10 13:17:44 -07:00
|
|
|
'employee_num' => $this->faker->numberBetween(3500, 35050),
|
2021-12-02 16:43:03 -08:00
|
|
|
'first_name' => $this->faker->firstName(),
|
|
|
|
'jobtitle' => $this->faker->jobTitle(),
|
|
|
|
'last_name' => $this->faker->lastName(),
|
2022-01-12 13:10:29 -08:00
|
|
|
'locale' => 'en',
|
2021-06-10 13:17:44 -07:00
|
|
|
'notes' => 'Created by DB seeder',
|
2021-12-01 23:33:20 -08:00
|
|
|
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
|
2021-06-10 13:17:44 -07:00
|
|
|
'permissions' => '{"user":"0"}',
|
2023-03-16 16:38:21 -07:00
|
|
|
'phone' => $this->faker->phoneNumber(),
|
|
|
|
'state' => $this->faker->stateAbbr(),
|
|
|
|
'username' => $this->faker->username(),
|
|
|
|
'zip' => $this->faker->postcode(),
|
2021-06-10 13:17:44 -07:00
|
|
|
];
|
|
|
|
}
|
2021-12-01 23:33:20 -08:00
|
|
|
|
2021-06-10 13:17:44 -07:00
|
|
|
public function firstAdmin()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'first_name' => 'Admin',
|
|
|
|
'last_name' => 'User',
|
|
|
|
'username' => 'admin',
|
2021-09-23 22:16:19 -07:00
|
|
|
'avatar' => '1.jpg',
|
2021-06-10 13:17:44 -07:00
|
|
|
'permissions' => '{"superuser":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function snipeAdmin()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'first_name' => 'Snipe E.',
|
|
|
|
'last_name' => 'Head',
|
|
|
|
'username' => 'snipe',
|
2021-09-23 22:16:19 -07:00
|
|
|
'avatar' => '2.jpg',
|
2021-06-10 13:17:44 -07:00
|
|
|
'email' => 'snipe@snipe.net',
|
|
|
|
'permissions' => '{"superuser":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function superuser()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"superuser":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function admin()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"admin":"1"}',
|
2023-03-16 12:46:47 -07:00
|
|
|
'manager_id' => function () {
|
|
|
|
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
|
|
|
|
},
|
2021-06-10 13:17:44 -07:00
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function viewAssets()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"assets.view":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function createAssets()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"assets.create":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function editAssets()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"assets.edit":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function deleteAssets()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"assets.delete":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function checkinAssets()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"assets.checkin":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function checkoutAssets()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"assets.checkout":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function viewRequestableAssets()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"assets.view.requestable":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function viewAccessories()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"accessories.view":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function createAccessories()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"accessories.create":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function editAccessories()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"accessories.edit":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function deleteAccessories()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"accessories.delete":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function checkinAccessories()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"accessories.checkin":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function checkoutAccessories()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"accessories.checkout":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function viewConsumables()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"consumables.view":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function createConsumables()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"consumables.create":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function editConsumables()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"consumables.edit":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function deleteConsumables()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"consumables.delete":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function checkinConsumables()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"consumables.checkin":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function checkoutConsumables()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"consumables.checkout":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function viewLicenses()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"licenses.view":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function createLicenses()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"licenses.create":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function editLicenses()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"licenses.edit":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function deleteLicenses()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"licenses.delete":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function checkoutLicenses()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"licenses.checkout":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function viewKeysLicenses()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"licenses.keys":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function viewComponents()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"components.view":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function createComponents()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"components.create":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function editComponents()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"components.edit":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function deleteComponents()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"components.delete":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function checkinComponents()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"components.checkin":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function checkoutComponents()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"components.checkout":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function viewUsers()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"users.view":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function createUsers()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"users.create":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function editUsers()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"users.edit":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function deleteUsers()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'permissions' => '{"users.delete":"1"}',
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
2021-12-01 23:33:20 -08:00
|
|
|
|
2021-06-10 13:17:44 -07:00
|
|
|
}
|