mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Merge pull request #16226 from snipe/add_notes_to_locations_companies_etc
Fixed #16184 - added notes to locations, companies, categories, manufacturers and groups
This commit is contained in:
commit
c08cfb9b73
|
@ -39,6 +39,7 @@ class CategoriesController extends Controller
|
|||
'components_count',
|
||||
'licenses_count',
|
||||
'image',
|
||||
'notes',
|
||||
];
|
||||
|
||||
$categories = Category::select([
|
||||
|
@ -52,6 +53,7 @@ class CategoriesController extends Controller
|
|||
'require_acceptance',
|
||||
'checkin_email',
|
||||
'image',
|
||||
'notes',
|
||||
])
|
||||
->with('adminuser')
|
||||
->withCount('accessories as accessories_count', 'consumables as consumables_count', 'components as components_count', 'licenses as licenses_count');
|
||||
|
|
|
@ -38,6 +38,7 @@ class CompaniesController extends Controller
|
|||
'accessories_count',
|
||||
'consumables_count',
|
||||
'components_count',
|
||||
'notes',
|
||||
];
|
||||
|
||||
$companies = Company::withCount(['assets as assets_count' => function ($query) {
|
||||
|
|
|
@ -23,7 +23,7 @@ class DepartmentsController extends Controller
|
|||
public function index(Request $request) : JsonResponse | array
|
||||
{
|
||||
$this->authorize('view', Department::class);
|
||||
$allowed_columns = ['id', 'name', 'image', 'users_count'];
|
||||
$allowed_columns = ['id', 'name', 'image', 'users_count', 'notes'];
|
||||
|
||||
$departments = Department::select(
|
||||
'departments.id',
|
||||
|
@ -35,7 +35,8 @@ class DepartmentsController extends Controller
|
|||
'departments.manager_id',
|
||||
'departments.created_at',
|
||||
'departments.updated_at',
|
||||
'departments.image'
|
||||
'departments.image',
|
||||
'departments.notes',
|
||||
)->with('users')->with('location')->with('manager')->with('company')->withCount('users as users_count');
|
||||
|
||||
if ($request->filled('search')) {
|
||||
|
|
|
@ -24,7 +24,7 @@ class GroupsController extends Controller
|
|||
|
||||
$this->authorize('view', Group::class);
|
||||
|
||||
$groups = Group::select('id', 'name', 'permissions', 'created_at', 'updated_at', 'created_by')->with('adminuser')->withCount('users as users_count');
|
||||
$groups = Group::select('id', 'name', 'permissions', 'notes', 'created_at', 'updated_at', 'created_by')->with('adminuser')->withCount('users as users_count');
|
||||
|
||||
if ($request->filled('search')) {
|
||||
$groups = $groups->TextSearch($request->input('search'));
|
||||
|
@ -81,6 +81,7 @@ class GroupsController extends Controller
|
|||
|
||||
$group->name = $request->input('name');
|
||||
$group->created_by = auth()->id();
|
||||
$group->notes = $request->input('notes');
|
||||
$group->permissions = json_encode($request->input('permissions', $groupPermissions));
|
||||
|
||||
if ($group->save()) {
|
||||
|
@ -118,6 +119,7 @@ class GroupsController extends Controller
|
|||
$group = Group::findOrFail($id);
|
||||
|
||||
$group->name = $request->input('name');
|
||||
$group->notes = $request->input('notes');
|
||||
$group->permissions = $request->input('permissions'); // Todo - some JSON validation stuff here
|
||||
|
||||
if ($group->save()) {
|
||||
|
|
|
@ -53,6 +53,7 @@ class LocationsController extends Controller
|
|||
'updated_at',
|
||||
'users_count',
|
||||
'zip',
|
||||
'notes',
|
||||
];
|
||||
|
||||
$locations = Location::with('parent', 'manager', 'children')->select([
|
||||
|
@ -73,6 +74,7 @@ class LocationsController extends Controller
|
|||
'locations.image',
|
||||
'locations.ldap_ou',
|
||||
'locations.currency',
|
||||
'locations.notes',
|
||||
])
|
||||
->withCount('assignedAssets as assigned_assets_count')
|
||||
->withCount('assets as assets_count')
|
||||
|
@ -190,6 +192,7 @@ class LocationsController extends Controller
|
|||
'locations.updated_at',
|
||||
'locations.image',
|
||||
'locations.currency',
|
||||
'locations.notes',
|
||||
])
|
||||
->withCount('assignedAssets as assigned_assets_count')
|
||||
->withCount('assets as assets_count')
|
||||
|
|
|
@ -39,7 +39,8 @@ class ManufacturersController extends Controller
|
|||
'assets_count',
|
||||
'consumables_count',
|
||||
'components_count',
|
||||
'licenses_count'
|
||||
'licenses_count',
|
||||
'notes',
|
||||
];
|
||||
|
||||
$manufacturers = Manufacturer::select([
|
||||
|
@ -55,6 +56,7 @@ class ManufacturersController extends Controller
|
|||
'updated_at',
|
||||
'image',
|
||||
'deleted_at',
|
||||
'notes',
|
||||
])
|
||||
->with('adminuser')
|
||||
->withCount('assets as assets_count')
|
||||
|
|
|
@ -69,6 +69,7 @@ class CategoriesController extends Controller
|
|||
$category->use_default_eula = $request->input('use_default_eula', '0');
|
||||
$category->require_acceptance = $request->input('require_acceptance', '0');
|
||||
$category->checkin_email = $request->input('checkin_email', '0');
|
||||
$category->notes = $request->input('notes');
|
||||
$category->created_by = auth()->id();
|
||||
|
||||
$category = $request->handleImages($category);
|
||||
|
@ -134,6 +135,7 @@ class CategoriesController extends Controller
|
|||
$category->use_default_eula = $request->input('use_default_eula', '0');
|
||||
$category->require_acceptance = $request->input('require_acceptance', '0');
|
||||
$category->checkin_email = $request->input('checkin_email', '0');
|
||||
$category->notes = $request->input('notes');
|
||||
|
||||
$category = $request->handleImages($category);
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ final class CompaniesController extends Controller
|
|||
$company->phone = $request->input('phone');
|
||||
$company->fax = $request->input('fax');
|
||||
$company->email = $request->input('email');
|
||||
$company->notes = $request->input('notes');
|
||||
$company->created_by = auth()->id();
|
||||
|
||||
$company = $request->handleImages($company);
|
||||
|
@ -111,6 +112,7 @@ final class CompaniesController extends Controller
|
|||
$company->phone = $request->input('phone');
|
||||
$company->fax = $request->input('fax');
|
||||
$company->email = $request->input('email');
|
||||
$company->notes = $request->input('notes');
|
||||
|
||||
$company = $request->handleImages($company);
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ class DepartmentsController extends Controller
|
|||
$department->manager_id = ($request->filled('manager_id') ? $request->input('manager_id') : null);
|
||||
$department->location_id = ($request->filled('location_id') ? $request->input('location_id') : null);
|
||||
$department->company_id = ($request->filled('company_id') ? $request->input('company_id') : null);
|
||||
$department->notes = $request->input('notes');
|
||||
$department = $request->handleImages($department);
|
||||
|
||||
if ($department->save()) {
|
||||
|
@ -171,7 +172,7 @@ class DepartmentsController extends Controller
|
|||
$department->company_id = ($request->filled('company_id') ? $request->input('company_id') : null);
|
||||
$department->phone = $request->input('phone');
|
||||
$department->fax = $request->input('fax');
|
||||
|
||||
$department->notes = $request->input('notes');
|
||||
$department = $request->handleImages($department);
|
||||
|
||||
if ($department->save()) {
|
||||
|
|
|
@ -62,6 +62,7 @@ class GroupsController extends Controller
|
|||
$group->name = $request->input('name');
|
||||
$group->permissions = json_encode($request->input('permission'));
|
||||
$group->created_by = auth()->id();
|
||||
$group->notes = $request->input('notes');
|
||||
|
||||
if ($group->save()) {
|
||||
return redirect()->route('groups.index')->with('success', trans('admin/groups/message.success.create'));
|
||||
|
@ -108,6 +109,7 @@ class GroupsController extends Controller
|
|||
}
|
||||
$group->name = $request->input('name');
|
||||
$group->permissions = json_encode($request->input('permission'));
|
||||
$group->notes = $request->input('notes');
|
||||
|
||||
if (! config('app.lock_passwords')) {
|
||||
if ($group->save()) {
|
||||
|
|
|
@ -78,6 +78,7 @@ class LocationsController extends Controller
|
|||
$location->created_by = auth()->id();
|
||||
$location->phone = request('phone');
|
||||
$location->fax = request('fax');
|
||||
$location->notes = $request->input('notes');
|
||||
|
||||
$location = $request->handleImages($location);
|
||||
|
||||
|
@ -138,6 +139,7 @@ class LocationsController extends Controller
|
|||
$location->fax = request('fax');
|
||||
$location->ldap_ou = $request->input('ldap_ou');
|
||||
$location->manager_id = $request->input('manager_id');
|
||||
$location->notes = $request->input('notes');
|
||||
|
||||
$location = $request->handleImages($location);
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@ class ManufacturersController extends Controller
|
|||
$manufacturer->warranty_lookup_url = $request->input('warranty_lookup_url');
|
||||
$manufacturer->support_phone = $request->input('support_phone');
|
||||
$manufacturer->support_email = $request->input('support_email');
|
||||
$manufacturer->notes = $request->input('notes');
|
||||
$manufacturer = $request->handleImages($manufacturer);
|
||||
|
||||
if ($manufacturer->save()) {
|
||||
|
@ -123,6 +124,7 @@ class ManufacturersController extends Controller
|
|||
$manufacturer->warranty_lookup_url = $request->input('warranty_lookup_url');
|
||||
$manufacturer->support_phone = $request->input('support_phone');
|
||||
$manufacturer->support_email = $request->input('support_email');
|
||||
$manufacturer->notes = $request->input('notes');
|
||||
|
||||
// Set the model's image property to null if the image is being deleted
|
||||
if ($request->input('image_delete') == 1) {
|
||||
|
|
|
@ -66,6 +66,7 @@ class CategoriesTransformer
|
|||
'id' => (int) $category->adminuser->id,
|
||||
'name'=> e($category->adminuser->present()->fullName()),
|
||||
] : null,
|
||||
'notes' => Helper::parseEscapedMarkedownInline($category->notes),
|
||||
'created_at' => Helper::getFormattedDateObject($category->created_at, 'datetime'),
|
||||
'updated_at' => Helper::getFormattedDateObject($category->updated_at, 'datetime'),
|
||||
];
|
||||
|
|
|
@ -40,6 +40,7 @@ class CompaniesTransformer
|
|||
'id' => (int) $company->adminuser->id,
|
||||
'name'=> e($company->adminuser->present()->fullName()),
|
||||
] : null,
|
||||
'notes' => Helper::parseEscapedMarkedownInline($company->notes),
|
||||
'created_at' => Helper::getFormattedDateObject($company->created_at, 'datetime'),
|
||||
'updated_at' => Helper::getFormattedDateObject($company->updated_at, 'datetime'),
|
||||
];
|
||||
|
|
|
@ -44,6 +44,7 @@ class DepartmentsTransformer
|
|||
'name' => e($department->location->name),
|
||||
] : null,
|
||||
'users_count' => e($department->users_count),
|
||||
'notes' => Helper::parseEscapedMarkedownInline($department->notes),
|
||||
'created_at' => Helper::getFormattedDateObject($department->created_at, 'datetime'),
|
||||
'updated_at' => Helper::getFormattedDateObject($department->updated_at, 'datetime'),
|
||||
];
|
||||
|
|
|
@ -26,6 +26,7 @@ class GroupsTransformer
|
|||
'name' => e($group->name),
|
||||
'permissions' => json_decode($group->permissions),
|
||||
'users_count' => (int) $group->users_count,
|
||||
'notes' => Helper::parseEscapedMarkedownInline($group->notes),
|
||||
'created_by' => ($group->adminuser) ? [
|
||||
'id' => (int) $group->adminuser->id,
|
||||
'name'=> e($group->adminuser->present()->fullName()),
|
||||
|
|
|
@ -55,6 +55,7 @@ class LocationsTransformer
|
|||
'users_count' => (int) $location->users_count,
|
||||
'currency' => ($location->currency) ? e($location->currency) : null,
|
||||
'ldap_ou' => ($location->ldap_ou) ? e($location->ldap_ou) : null,
|
||||
'notes' => Helper::parseEscapedMarkedownInline($location->notes),
|
||||
'created_at' => Helper::getFormattedDateObject($location->created_at, 'datetime'),
|
||||
'updated_at' => Helper::getFormattedDateObject($location->updated_at, 'datetime'),
|
||||
'parent' => ($location->parent) ? [
|
||||
|
|
|
@ -37,6 +37,7 @@ class ManufacturersTransformer
|
|||
'consumables_count' => (int) $manufacturer->consumables_count,
|
||||
'accessories_count' => (int) $manufacturer->accessories_count,
|
||||
'components_count' => (int) $manufacturer->components_count,
|
||||
'notes' => Helper::parseEscapedMarkedownInline($manufacturer->notes),
|
||||
'created_by' => ($manufacturer->adminuser) ? [
|
||||
'id' => (int) $manufacturer->adminuser->id,
|
||||
'name'=> e($manufacturer->adminuser->present()->fullName()),
|
||||
|
|
|
@ -74,6 +74,8 @@ class LocationImporter extends ItemImporter
|
|||
$this->item['ldap_ou'] = trim($this->findCsvMatch($row, 'ldap_ou'));
|
||||
$this->item['manager'] = trim($this->findCsvMatch($row, 'manager'));
|
||||
$this->item['manager_username'] = trim($this->findCsvMatch($row, 'manager_username'));
|
||||
$this->item['notes'] = trim($this->findCsvMatch($row, 'notes'));
|
||||
|
||||
|
||||
if ($this->findCsvMatch($row, 'parent_location')) {
|
||||
$this->item['parent_id'] = $this->createOrFetchLocation(trim($this->findCsvMatch($row, 'parent_location')));
|
||||
|
|
|
@ -342,6 +342,7 @@ class Importer extends Component
|
|||
'manager_username' => trans('general.importer.manager_username'),
|
||||
'manager' => trans('general.importer.manager_full_name'),
|
||||
'parent_location' => trans('admin/locations/table.parent'),
|
||||
'notes' => trans('general.notes'),
|
||||
];
|
||||
|
||||
$this->assetmodels_fields = [
|
||||
|
|
|
@ -71,6 +71,7 @@ class Category extends SnipeModel
|
|||
'require_acceptance',
|
||||
'use_default_eula',
|
||||
'created_by',
|
||||
'notes',
|
||||
];
|
||||
|
||||
use Searchable;
|
||||
|
@ -80,7 +81,7 @@ class Category extends SnipeModel
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $searchableAttributes = ['name', 'category_type'];
|
||||
protected $searchableAttributes = ['name', 'category_type', 'notes'];
|
||||
|
||||
/**
|
||||
* The relations and their attributes that should be included when searching the model.
|
||||
|
|
|
@ -18,7 +18,8 @@ class Group extends SnipeModel
|
|||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'permissions'
|
||||
'permissions',
|
||||
'notes',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -37,7 +38,7 @@ class Group extends SnipeModel
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $searchableAttributes = ['name', 'created_at'];
|
||||
protected $searchableAttributes = ['name', 'created_at', 'notes'];
|
||||
|
||||
/**
|
||||
* The relations and their attributes that should be included when searching the model.
|
||||
|
|
|
@ -72,6 +72,7 @@ class Location extends SnipeModel
|
|||
'currency',
|
||||
'manager_id',
|
||||
'image',
|
||||
'notes',
|
||||
];
|
||||
protected $hidden = ['user_id'];
|
||||
|
||||
|
@ -82,7 +83,7 @@ class Location extends SnipeModel
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $searchableAttributes = ['name', 'address', 'city', 'state', 'zip', 'created_at', 'ldap_ou', 'phone', 'fax'];
|
||||
protected $searchableAttributes = ['name', 'address', 'city', 'state', 'zip', 'created_at', 'ldap_ou', 'phone', 'fax', 'notes'];
|
||||
|
||||
/**
|
||||
* The relations and their attributes that should be included when searching the model.
|
||||
|
|
|
@ -53,6 +53,7 @@ class Manufacturer extends SnipeModel
|
|||
'support_url',
|
||||
'url',
|
||||
'warranty_lookup_url',
|
||||
'notes',
|
||||
];
|
||||
|
||||
use Searchable;
|
||||
|
@ -62,7 +63,7 @@ class Manufacturer extends SnipeModel
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $searchableAttributes = ['name', 'created_at'];
|
||||
protected $searchableAttributes = ['name', 'created_at', 'notes'];
|
||||
|
||||
/**
|
||||
* The relations and their attributes that should be included when searching the model.
|
||||
|
|
|
@ -77,7 +77,13 @@ class CategoryPresenter extends Presenter
|
|||
"title" => trans('admin/categories/general.use_default_eula_column'),
|
||||
'visible' => true,
|
||||
"formatter" => 'trueFalseFormatter',
|
||||
],[
|
||||
], [
|
||||
'field' => 'notes',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'visible' => false,
|
||||
'title' => trans('general.notes'),
|
||||
], [
|
||||
'field' => 'created_by',
|
||||
'searchable' => false,
|
||||
'sortable' => true,
|
||||
|
|
|
@ -105,7 +105,13 @@ class CompanyPresenter extends Presenter
|
|||
'title' => trans('general.components'),
|
||||
'visible' => true,
|
||||
'class' => 'css-component',
|
||||
],[
|
||||
], [
|
||||
'field' => 'notes',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'visible' => false,
|
||||
'title' => trans('general.notes'),
|
||||
], [
|
||||
'field' => 'created_by',
|
||||
'searchable' => false,
|
||||
'sortable' => true,
|
||||
|
|
|
@ -184,6 +184,12 @@ class LocationPresenter extends Presenter
|
|||
'title' => trans('admin/users/table.manager'),
|
||||
'visible' => false,
|
||||
'formatter' => 'usersLinkObjFormatter',
|
||||
], [
|
||||
'field' => 'notes',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'visible' => false,
|
||||
'title' => trans('general.notes'),
|
||||
], [
|
||||
'field' => 'created_at',
|
||||
'searchable' => true,
|
||||
|
|
|
@ -6,5 +6,5 @@ return array (
|
|||
'prerelease_version' => '',
|
||||
'hash_version' => 'gfb857ccf5',
|
||||
'full_hash' => 'v7.1.16-510-gfb857ccf5',
|
||||
'branch' => 'master',
|
||||
'branch' => 'develop',
|
||||
);
|
|
@ -30,6 +30,7 @@ class CategoryFactory extends Factory
|
|||
'require_acceptance' => false,
|
||||
'use_default_eula' => $this->faker->boolean(),
|
||||
'created_by' => User::factory()->superuser(),
|
||||
'notes' => 'Created by DB seeder',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ class CompanyFactory extends Factory
|
|||
return [
|
||||
'name' => $this->faker->unique()->company(),
|
||||
'created_by' => 1,
|
||||
'notes' => 'Created by DB seeder',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ class DepartmentFactory extends Factory
|
|||
'name' => $this->faker->unique()->word() . ' Department',
|
||||
'created_by' => User::factory()->superuser(),
|
||||
'location_id' => Location::factory(),
|
||||
'notes' => 'Created by DB seeder',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ class GroupFactory extends Factory
|
|||
return [
|
||||
'name' => $this->faker->name(),
|
||||
'permissions' => json_encode([]),
|
||||
'notes' => 'Created by DB seeder',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ class LocationFactory extends Factory
|
|||
'currency' => $this->faker->currencyCode(),
|
||||
'zip' => $this->faker->postcode(),
|
||||
'image' => rand(1, 9).'.jpg',
|
||||
'notes' => 'Created by DB seeder',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ class ManufacturerFactory extends Factory
|
|||
'support_phone' => $this->faker->phoneNumber(),
|
||||
'url' => $this->faker->url(),
|
||||
'support_email' => $this->faker->safeEmail(),
|
||||
'notes' => 'Created by DB seeder',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('locations', function (Blueprint $table) {
|
||||
$table->text('notes')->nullable()->default(null);
|
||||
});
|
||||
|
||||
Schema::table('companies', function (Blueprint $table) {
|
||||
$table->text('notes')->nullable()->default(null);
|
||||
});
|
||||
|
||||
Schema::table('categories', function (Blueprint $table) {
|
||||
$table->text('notes')->nullable()->default(null);
|
||||
});
|
||||
|
||||
Schema::table('manufacturers', function (Blueprint $table) {
|
||||
$table->text('notes')->nullable()->default(null);
|
||||
});
|
||||
|
||||
Schema::table('permission_groups', function (Blueprint $table) {
|
||||
$table->text('notes')->nullable()->default(null);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('locations', function (Blueprint $table) {
|
||||
$table->dropColumn('notes');
|
||||
});
|
||||
|
||||
Schema::table('companies', function (Blueprint $table) {
|
||||
$table->dropColumn('notes');
|
||||
});
|
||||
|
||||
Schema::table('categories', function (Blueprint $table) {
|
||||
$table->dropColumn('notes');
|
||||
});
|
||||
|
||||
Schema::table('manufacturers', function (Blueprint $table) {
|
||||
$table->dropColumn('notes');
|
||||
});
|
||||
|
||||
Schema::table('permission_groups', function (Blueprint $table) {
|
||||
$table->dropColumn('notes');
|
||||
});
|
||||
}
|
||||
};
|
|
@ -561,6 +561,7 @@ return [
|
|||
'consumables' => ':count Consumable|:count Consumables',
|
||||
'components' => ':count Component|:count Components',
|
||||
],
|
||||
|
||||
'more_info' => 'More Info',
|
||||
'quickscan_bulk_help' => 'Checking this box will edit the asset record to reflect this new location. Leaving it unchecked will simply note the location in the audit log. Note that if this asset is checked out, it will not change the location of the person, asset or location it is checked out to.',
|
||||
'whoops' => 'Whoops!',
|
||||
|
@ -577,4 +578,9 @@ return [
|
|||
'user_managed_passwords_disallow' => 'Disallow users from managing their own passwords',
|
||||
'user_managed_passwords_allow' => 'Allow users to manage their own passwords',
|
||||
|
||||
// Add form placeholders here
|
||||
'placeholders' => [
|
||||
'notes' => 'Add a note',
|
||||
],
|
||||
|
||||
];
|
||||
|
|
|
@ -33,6 +33,21 @@
|
|||
|
||||
@include ('partials.forms.edit.image-upload', ['image_path' => app('categories_upload_path')])
|
||||
|
||||
<div class="form-group{!! $errors->has('notes') ? ' has-error' : '' !!}">
|
||||
<label for="notes" class="col-md-3 control-label">{{ trans('general.notes') }}</label>
|
||||
<div class="col-md-8">
|
||||
<x-input.textarea
|
||||
name="notes"
|
||||
id="notes"
|
||||
:value="old('notes', $item->notes)"
|
||||
placeholder="{{ trans('general.placeholders.notes') }}"
|
||||
aria-label="notes"
|
||||
rows="5"
|
||||
/>
|
||||
{!! $errors->first('notes', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@stop
|
||||
|
||||
|
|
|
@ -14,4 +14,20 @@
|
|||
@include ('partials.forms.edit.email')
|
||||
@include ('partials.forms.edit.image-upload', ['image_path' => app('companies_upload_path')])
|
||||
|
||||
<div class="form-group{!! $errors->has('notes') ? ' has-error' : '' !!}">
|
||||
<label for="notes" class="col-md-3 control-label">{{ trans('general.notes') }}</label>
|
||||
<div class="col-md-8">
|
||||
|
||||
<x-input.textarea
|
||||
name="notes"
|
||||
id="notes"
|
||||
:value="old('notes', $item->notes)"
|
||||
placeholder="{{ trans('general.placeholders.notes') }}"
|
||||
aria-label="notes"
|
||||
rows="5"
|
||||
/>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@stop
|
||||
|
|
|
@ -26,6 +26,20 @@
|
|||
@include ('partials.forms.edit.location-select', ['translated_name' => trans('general.location'), 'fieldname' => 'location_id'])
|
||||
@include ('partials.forms.edit.image-upload', ['image_path' => app('departments_upload_path')])
|
||||
|
||||
<div class="form-group{!! $errors->has('notes') ? ' has-error' : '' !!}">
|
||||
<label for="notes" class="col-md-3 control-label">{{ trans('general.notes') }}</label>
|
||||
<div class="col-md-8">
|
||||
<x-input.textarea
|
||||
name="notes"
|
||||
id="notes"
|
||||
:value="old('notes', $item->notes)"
|
||||
placeholder="{{ trans('general.placeholders.notes') }}"
|
||||
aria-label="notes"
|
||||
rows="5"
|
||||
/>
|
||||
{!! $errors->first('notes', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@stop
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
<th data-sortable="true" data-formatter="usersLinkObjFormatter" data-field="manager" data-searchable="false">{{ trans('admin/departments/table.manager') }}</th>
|
||||
<th data-sortable="true" data-field="users_count" data-searchable="false">{{ trans('general.users') }}</th>
|
||||
<th data-sortable="true" data-formatter="locationsLinkObjFormatter" data-field="location" data-searchable="false">{{ trans('admin/departments/table.location') }}</th>
|
||||
<th data-sortable="true" data-field="notes" data-searchable="true">{{ trans('general.notes') }}</th>
|
||||
<th data-sortable="false" data-formatter="departmentsActionsFormatter" data-field="actions" data-searchable="false">{{ trans('table.actions') }}</th>
|
||||
|
||||
</tr>
|
||||
|
|
|
@ -54,12 +54,29 @@
|
|||
@section('inputFields')
|
||||
<!-- Name -->
|
||||
<div class="form-group {{ $errors->has('name') ? ' has-error' : '' }}">
|
||||
<label for="name" class="col-md-3 control-label">{{ trans('admin/groups/titles.group_name') }}</label>
|
||||
<div class="col-md-6 required">
|
||||
<label for="name" class="col-md-2 control-label">{{ trans('admin/groups/titles.group_name') }}</label>
|
||||
<div class="col-md-9 required">
|
||||
<input class="form-control" type="text" name="name" id="name" value="{{ old('name', $group->name) }}" required />
|
||||
{!! $errors->first('name', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group{!! $errors->has('notes') ? ' has-error' : '' !!}">
|
||||
<label for="notes" class="col-md-2 control-label">{{ trans('general.notes') }}</label>
|
||||
<div class="col-md-9">
|
||||
<x-input.textarea
|
||||
name="notes"
|
||||
id="notes"
|
||||
:value="old('notes', $group->notes)"
|
||||
placeholder="{{ trans('general.placeholders.notes') }}"
|
||||
aria-label="notes"
|
||||
rows="2"
|
||||
/>
|
||||
|
||||
{!! $errors->first('notes', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12">
|
||||
|
||||
<table class="table table-striped permissions">
|
||||
|
|
|
@ -57,6 +57,23 @@
|
|||
</div>
|
||||
@endif
|
||||
|
||||
|
||||
@include ('partials.forms.edit.image-upload', ['image_path' => app('locations_upload_path')])
|
||||
|
||||
<div class="form-group{!! $errors->has('notes') ? ' has-error' : '' !!}">
|
||||
<label for="notes" class="col-md-3 control-label">{{ trans('general.notes') }}</label>
|
||||
<div class="col-md-8">
|
||||
<x-input.textarea
|
||||
name="notes"
|
||||
id="notes"
|
||||
:value="old('notes', $item->notes)"
|
||||
placeholder="{{ trans('general.placeholders.notes') }}"
|
||||
aria-label="notes"
|
||||
rows="5"
|
||||
/>
|
||||
{!! $errors->first('notes', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@stop
|
||||
|
||||
|
|
|
@ -63,6 +63,21 @@
|
|||
|
||||
@include ('partials.forms.edit.image-upload', ['image_path' => app('manufacturers_upload_path')])
|
||||
|
||||
<div class="form-group{!! $errors->has('notes') ? ' has-error' : '' !!}">
|
||||
<label for="notes" class="col-md-3 control-label">{{ trans('general.notes') }}</label>
|
||||
<div class="col-md-8">
|
||||
<x-input.textarea
|
||||
name="notes"
|
||||
id="notes"
|
||||
:value="old('notes', $item->notes)"
|
||||
placeholder="{{ trans('general.placeholders.notes') }}"
|
||||
aria-label="notes"
|
||||
rows="5"
|
||||
/>
|
||||
{!! $errors->first('notes', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@stop
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<!-- Notes -->
|
||||
<div class="form-group{{ $errors->has('notes') ? ' has-error' : '' }}">
|
||||
<label for="notes" class="col-md-3 control-label">{{ trans('admin/hardware/form.notes') }}</label>
|
||||
<label for="notes" class="col-md-3 control-label">{{ trans('general.notes') }}</label>
|
||||
<div class="col-md-7 col-sm-12">
|
||||
<textarea class="col-md-6 form-control" id="notes" aria-label="notes" name="notes" style="min-width:100%;">{{ old('notes', $item->notes) }}</textarea>
|
||||
{!! $errors->first('notes', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||
|
|
|
@ -27,6 +27,7 @@ class CreateCategoriesTest extends TestCase
|
|||
'name' => 'Test Category',
|
||||
'eula_text' => 'Test EULA',
|
||||
'category_type' => 'accessory',
|
||||
'notes' => 'Test Note',
|
||||
])
|
||||
->assertOk()
|
||||
->assertStatusMessageIs('success')
|
||||
|
@ -38,6 +39,7 @@ class CreateCategoriesTest extends TestCase
|
|||
$category = Category::find($response['payload']['id']);
|
||||
$this->assertEquals('Test Category', $category->name);
|
||||
$this->assertEquals('Test EULA', $category->eula_text);
|
||||
$this->assertEquals('Test Note', $category->notes);
|
||||
$this->assertEquals('accessory', $category->category_type);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ class UpdateCategoriesTest extends TestCase
|
|||
->patchJson(route('api.categories.update', $category), [
|
||||
'name' => 'Test Category',
|
||||
'eula_text' => 'Test EULA',
|
||||
'notes' => 'Test Note',
|
||||
])
|
||||
->assertOk()
|
||||
->assertStatusMessageIs('success')
|
||||
|
@ -27,6 +28,7 @@ class UpdateCategoriesTest extends TestCase
|
|||
$category->refresh();
|
||||
$this->assertEquals('Test Category', $category->name, 'Name was not updated');
|
||||
$this->assertEquals('Test EULA', $category->eula_text, 'EULA was not updated');
|
||||
$this->assertEquals('Test Note', $category->notes, 'Note was not updated');
|
||||
|
||||
}
|
||||
|
||||
|
@ -39,6 +41,7 @@ class UpdateCategoriesTest extends TestCase
|
|||
'name' => 'Test Category',
|
||||
'eula_text' => 'Test EULA',
|
||||
'category_type' => 'accessory',
|
||||
'note' => 'Test Note',
|
||||
])
|
||||
->assertOk()
|
||||
->assertStatusMessageIs('error')
|
||||
|
@ -48,6 +51,7 @@ class UpdateCategoriesTest extends TestCase
|
|||
$category->refresh();
|
||||
$this->assertNotEquals('Test Category', $category->name, 'Name was not updated');
|
||||
$this->assertNotEquals('Test EULA', $category->eula_text, 'EULA was not updated');
|
||||
$this->assertNotEquals('Test Note', $category->notes, 'Note was not updated');
|
||||
$this->assertNotEquals('accessory', $category->category_type, 'EULA was not updated');
|
||||
|
||||
}
|
||||
|
|
|
@ -33,11 +33,12 @@ class CreateCategoriesTest extends TestCase
|
|||
$this->actingAs(User::factory()->superuser()->create())
|
||||
->post(route('categories.store'), [
|
||||
'name' => 'Test Category',
|
||||
'category_type' => 'asset'
|
||||
'category_type' => 'asset',
|
||||
'notes' => 'Test Note',
|
||||
])
|
||||
->assertRedirect(route('categories.index'));
|
||||
|
||||
$this->assertTrue(Category::where('name', 'Test Category')->exists());
|
||||
$this->assertTrue(Category::where('name', 'Test Category')->where('notes', 'Test Note')->exists());
|
||||
}
|
||||
|
||||
public function testUserCannotCreateCategoriesWithInvalidType()
|
||||
|
@ -48,7 +49,7 @@ class CreateCategoriesTest extends TestCase
|
|||
->from(route('categories.create'))
|
||||
->post(route('categories.store'), [
|
||||
'name' => 'Test Category',
|
||||
'category_type' => 'invalid'
|
||||
'category_type' => 'invalid',
|
||||
])
|
||||
->assertRedirect(route('categories.create'));
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class UpdateCategoriesTest extends TestCase
|
|||
$this->actingAs(User::factory()->superuser()->create())
|
||||
->post(route('categories.store'), [
|
||||
'name' => 'Test Category',
|
||||
'category_type' => 'asset'
|
||||
'category_type' => 'asset',
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertSessionHasNoErrors()
|
||||
|
@ -49,13 +49,14 @@ class UpdateCategoriesTest extends TestCase
|
|||
$response = $this->actingAs(User::factory()->superuser()->create())
|
||||
->put(route('categories.update', ['category' => $category]), [
|
||||
'name' => 'Test Category Edited',
|
||||
'notes' => 'Test Note Edited',
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertSessionHasNoErrors()
|
||||
->assertRedirect(route('categories.index'));
|
||||
|
||||
$this->followRedirects($response)->assertSee('Success');
|
||||
$this->assertTrue(Category::where('name', 'Test Category Edited')->exists());
|
||||
$this->assertTrue(Category::where('name', 'Test Category Edited')->where('notes', 'Test Note Edited')->exists());
|
||||
|
||||
}
|
||||
|
||||
|
@ -69,13 +70,14 @@ class UpdateCategoriesTest extends TestCase
|
|||
->put(route('categories.update', ['category' => $category]), [
|
||||
'name' => 'Test Category Edited',
|
||||
'category_type' => 'accessory',
|
||||
'notes' => 'Test Note Edited',
|
||||
])
|
||||
->assertSessionHasNoErrors()
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('categories.index'));
|
||||
|
||||
$this->followRedirects($response)->assertSee('Success');
|
||||
$this->assertTrue(Category::where('name', 'Test Category Edited')->exists());
|
||||
$this->assertTrue(Category::where('name', 'Test Category Edited')->where('notes', 'Test Note Edited')->exists());
|
||||
|
||||
}
|
||||
|
||||
|
@ -89,6 +91,7 @@ class UpdateCategoriesTest extends TestCase
|
|||
->put(route('categories.update', ['category' => $category]), [
|
||||
'name' => 'Test Category Edited',
|
||||
'category_type' => 'accessory',
|
||||
'notes' => 'Test Note Edited',
|
||||
])
|
||||
->assertSessionHasErrors(['category_type'])
|
||||
->assertInvalid(['category_type'])
|
||||
|
@ -96,7 +99,7 @@ class UpdateCategoriesTest extends TestCase
|
|||
->assertRedirect(route('categories.edit', ['category' => $category->id]));
|
||||
|
||||
$this->followRedirects($response)->assertSee(trans('general.error'));
|
||||
$this->assertFalse(Category::where('name', 'Test Category Edited')->exists());
|
||||
$this->assertFalse(Category::where('name', 'Test Category Edited')->where('notes', 'Test Note Edited')->exists());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -20,4 +20,23 @@ class CreateDepartmentsTest extends TestCase
|
|||
->assertForbidden();
|
||||
}
|
||||
|
||||
public function testCanCreateDepartment()
|
||||
{
|
||||
$response = $this->actingAsForApi(User::factory()->superuser()->create())
|
||||
->postJson(route('api.departments.store'), [
|
||||
'name' => 'Test Department',
|
||||
'notes' => 'Test Note',
|
||||
])
|
||||
->assertOk()
|
||||
->assertStatusMessageIs('success')
|
||||
->assertStatus(200)
|
||||
->json();
|
||||
|
||||
$this->assertTrue(Department::where('name', 'Test Department')->exists());
|
||||
|
||||
$department = Department::find($response['payload']['id']);
|
||||
$this->assertEquals('Test Department', $department->name);
|
||||
$this->assertEquals('Test Note', $department->notes);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ class UpdateDepartmentsTest extends TestCase
|
|||
$this->actingAsForApi(User::factory()->superuser()->create())
|
||||
->patchJson(route('api.departments.update', $department), [
|
||||
'name' => 'Test Department',
|
||||
'notes' => 'Test Note',
|
||||
])
|
||||
->assertOk()
|
||||
->assertStatusMessageIs('success')
|
||||
|
@ -33,6 +34,7 @@ class UpdateDepartmentsTest extends TestCase
|
|||
|
||||
$department->refresh();
|
||||
$this->assertEquals('Test Department', $department->name, 'Name was not updated');
|
||||
$this->assertEquals('Test Note', $department->notes, 'Note was not updated');
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -34,11 +34,12 @@ class CreateDepartmentsTest extends TestCase
|
|||
$this->actingAs(User::factory()->superuser()->create())
|
||||
->post(route('departments.store'), [
|
||||
'name' => 'Test Department',
|
||||
'company_id' => Company::factory()->create()->id
|
||||
'company_id' => Company::factory()->create()->id,
|
||||
'notes' => 'Test Note',
|
||||
])
|
||||
->assertRedirect(route('departments.index'));
|
||||
|
||||
$this->assertTrue(Department::where('name', 'Test Department')->exists());
|
||||
$this->assertTrue(Department::where('name', 'Test Department')->where('notes', 'Test Note')->exists());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -34,13 +34,14 @@ class UpdateDepartmentsTest extends TestCase
|
|||
$response = $this->actingAs(User::factory()->superuser()->create())
|
||||
->put(route('departments.update', ['department' => $department]), [
|
||||
'name' => 'Test Department Edited',
|
||||
'notes' => 'Test Note Edited',
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertSessionHasNoErrors()
|
||||
->assertRedirect(route('departments.index'));
|
||||
|
||||
$this->followRedirects($response)->assertSee('Success');
|
||||
$this->assertTrue(Department::where('name', 'Test Department Edited')->exists());
|
||||
$this->assertTrue(Department::where('name', 'Test Department Edited')->where('notes', 'Test Note Edited')->exists());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ class StoreGroupTest extends TestCase
|
|||
$this->actingAsForApi(User::factory()->superuser()->create())
|
||||
->postJson(route('api.groups.store'), [
|
||||
'name' => 'My Awesome Group',
|
||||
'notes' => 'My Awesome Note',
|
||||
'permissions' => [
|
||||
'admin' => '1',
|
||||
'import' => '1',
|
||||
|
@ -29,7 +30,7 @@ class StoreGroupTest extends TestCase
|
|||
])
|
||||
->assertOk();
|
||||
|
||||
$group = Group::where('name', 'My Awesome Group')->first();
|
||||
$group = Group::where('name', 'My Awesome Group')->where('notes', 'My Awesome Note')->first();
|
||||
|
||||
$this->assertNotNull($group);
|
||||
$this->assertEquals('1', $group->decodePermissions()['admin']);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Tests\Feature\Groups\Ui;
|
||||
|
||||
use App\Models\Group;
|
||||
use App\Models\User;
|
||||
use Tests\TestCase;
|
||||
|
||||
|
@ -13,4 +14,18 @@ class CreateGroupTest extends TestCase
|
|||
->get(route('groups.create'))
|
||||
->assertOk();
|
||||
}
|
||||
|
||||
public function testUserCanCreateGroup()
|
||||
{
|
||||
$this->assertFalse(Group::where('name', 'Test Group')->exists());
|
||||
|
||||
$this->actingAs(User::factory()->superuser()->create())
|
||||
->post(route('groups.store'), [
|
||||
'name' => 'Test Group',
|
||||
'notes' => 'Test Note',
|
||||
])
|
||||
->assertRedirect(route('groups.index'));
|
||||
|
||||
$this->assertTrue(Group::where('name', 'Test Group')->where('notes', 'Test Note')->exists());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,4 +14,22 @@ class UpdateGroupTest extends TestCase
|
|||
->get(route('groups.edit', Group::factory()->create()->id))
|
||||
->assertOk();
|
||||
}
|
||||
|
||||
public function testUserCanEditGroups()
|
||||
{
|
||||
$group = Group::factory()->create(['name' => 'Test Group']);
|
||||
$this->assertTrue(Group::where('name', 'Test Group')->exists());
|
||||
|
||||
$response = $this->actingAs(User::factory()->superuser()->create())
|
||||
->put(route('groups.update', ['group' => $group]), [
|
||||
'name' => 'Test Group Edited',
|
||||
'notes' => 'Test Note Edited',
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertSessionHasNoErrors()
|
||||
->assertRedirect(route('groups.index'));
|
||||
|
||||
$this->followRedirects($response)->assertSee('Success');
|
||||
$this->assertTrue(Group::where('name', 'Test Group Edited')->where('notes', 'Test Note Edited')->exists());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,26 @@ class CreateLocationsTest extends TestCase
|
|||
->assertForbidden();
|
||||
}
|
||||
|
||||
|
||||
public function testCanCreateLocation()
|
||||
{
|
||||
$response = $this->actingAsForApi(User::factory()->superuser()->create())
|
||||
->postJson(route('api.locations.store'), [
|
||||
'name' => 'Test Location',
|
||||
'notes' => 'Test Note',
|
||||
])
|
||||
->assertOk()
|
||||
->assertStatusMessageIs('success')
|
||||
->assertStatus(200)
|
||||
->json();
|
||||
|
||||
$this->assertTrue(Location::where('name', 'Test Location')->exists());
|
||||
|
||||
$department = Location::find($response['payload']['id']);
|
||||
$this->assertEquals('Test Location', $department->name);
|
||||
$this->assertEquals('Test Note', $department->notes);
|
||||
}
|
||||
|
||||
public function testCannotCreateNewLocationsWithTheSameName()
|
||||
{
|
||||
$location = Location::factory()->create();
|
||||
|
|
|
@ -22,7 +22,8 @@ class UpdateLocationsTest extends TestCase
|
|||
|
||||
$this->actingAsForApi(User::factory()->superuser()->create())
|
||||
->patchJson(route('api.locations.update', $location), [
|
||||
'name' => 'Test Location',
|
||||
'name' => 'Test Updated Location',
|
||||
'notes' => 'Test Updated Note',
|
||||
])
|
||||
->assertOk()
|
||||
->assertStatusMessageIs('success')
|
||||
|
@ -30,7 +31,8 @@ class UpdateLocationsTest extends TestCase
|
|||
->json();
|
||||
|
||||
$location->refresh();
|
||||
$this->assertEquals('Test Location', $location->name, 'Name was not updated');
|
||||
$this->assertEquals('Test Updated Location', $location->name, 'Name was not updated');
|
||||
$this->assertEquals('Test Updated Note', $location->notes, 'Note was not updated');
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -33,11 +33,11 @@ class CreateLocationsTest extends TestCase
|
|||
$this->actingAs(User::factory()->superuser()->create())
|
||||
->post(route('locations.store'), [
|
||||
'name' => 'Test Location',
|
||||
'company_id' => Company::factory()->create()->id
|
||||
'notes' => 'Test Note',
|
||||
])
|
||||
->assertRedirect(route('locations.index'));
|
||||
|
||||
$this->assertTrue(Location::where('name', 'Test Location')->exists());
|
||||
$this->assertTrue(Location::where('name', 'Test Location')->where('notes', 'Test Note')->exists());
|
||||
}
|
||||
|
||||
public function testUserCannotCreateLocationsWithInvalidParent()
|
||||
|
|
|
@ -33,13 +33,14 @@ class UpdateLocationsTest extends TestCase
|
|||
$response = $this->actingAs(User::factory()->superuser()->create())
|
||||
->put(route('locations.update', ['location' => $location]), [
|
||||
'name' => 'Test Location Edited',
|
||||
'notes' => 'Test Note Edited',
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertSessionHasNoErrors()
|
||||
->assertRedirect(route('locations.index'));
|
||||
|
||||
$this->followRedirects($response)->assertSee('Success');
|
||||
$this->assertTrue(Location::where('name', 'Test Location Edited')->exists());
|
||||
$this->assertTrue(Location::where('name', 'Test Location Edited')->where('notes', 'Test Note Edited')->exists());
|
||||
}
|
||||
|
||||
public function testUserCannotEditLocationsToMakeThemTheirOwnParent()
|
||||
|
|
39
tests/Feature/Manufacturers/Api/CreateManufacturersTest.php
Normal file
39
tests/Feature/Manufacturers/Api/CreateManufacturersTest.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\Manufacturers\Api;
|
||||
|
||||
use App\Models\Manufacturer;
|
||||
use App\Models\User;
|
||||
use Tests\TestCase;
|
||||
|
||||
class CreateManufacturersTest extends TestCase
|
||||
{
|
||||
|
||||
|
||||
public function testRequiresPermissionToCreateDepartment()
|
||||
{
|
||||
$this->actingAsForApi(User::factory()->create())
|
||||
->postJson(route('api.departments.store'))
|
||||
->assertForbidden();
|
||||
}
|
||||
|
||||
public function testCanCreateManufacturer()
|
||||
{
|
||||
$response = $this->actingAsForApi(User::factory()->superuser()->create())
|
||||
->postJson(route('api.manufacturers.store'), [
|
||||
'name' => 'Test Manufacturer',
|
||||
'notes' => 'Test Note',
|
||||
])
|
||||
->assertOk()
|
||||
->assertStatusMessageIs('success')
|
||||
->assertStatus(200)
|
||||
->json();
|
||||
|
||||
$this->assertTrue(Manufacturer::where('name', 'Test Manufacturer')->where('notes', 'Test Note')->exists());
|
||||
|
||||
$manufacturer = Manufacturer::find($response['payload']['id']);
|
||||
$this->assertEquals('Test Manufacturer', $manufacturer->name);
|
||||
$this->assertEquals('Test Note', $manufacturer->notes);
|
||||
}
|
||||
|
||||
}
|
50
tests/Feature/Manufacturers/Api/UpdateManufacturersTest.php
Normal file
50
tests/Feature/Manufacturers/Api/UpdateManufacturersTest.php
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\Manufacturers\Ui;
|
||||
|
||||
use App\Models\Manufacturer;
|
||||
use App\Models\Category;
|
||||
use App\Models\User;
|
||||
use Tests\TestCase;
|
||||
|
||||
class UpdateManufacturersTest extends TestCase
|
||||
{
|
||||
public function testPermissionRequiredToStoreManufacturer()
|
||||
{
|
||||
$this->actingAs(User::factory()->create())
|
||||
->post(route('manufacturers.store'), [
|
||||
'name' => 'Test Manufacturer',
|
||||
])
|
||||
->assertStatus(403)
|
||||
->assertForbidden();
|
||||
}
|
||||
|
||||
public function testPageRenders()
|
||||
{
|
||||
$this->actingAs(User::factory()->superuser()->create())
|
||||
->get(route('manufacturers.edit', Manufacturer::factory()->create()->id))
|
||||
->assertOk();
|
||||
}
|
||||
|
||||
public function testUserCanEditManufacturers()
|
||||
{
|
||||
$department = Manufacturer::factory()->create(['name' => 'Test Manufacturer']);
|
||||
$this->assertTrue(Manufacturer::where('name', 'Test Manufacturer')->exists());
|
||||
|
||||
$response = $this->actingAs(User::factory()->superuser()->create())
|
||||
->put(route('manufacturers.update', ['manufacturer' => $department]), [
|
||||
'name' => 'Test Manufacturer Edited',
|
||||
'notes' => 'Test Note Edited',
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertSessionHasNoErrors()
|
||||
->assertRedirect(route('manufacturers.index'));
|
||||
|
||||
$this->followRedirects($response)->assertSee('Success');
|
||||
$this->assertTrue(Manufacturer::where('name', 'Test Manufacturer Edited')->where('notes', 'Test Note Edited')->exists());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -3,6 +3,7 @@
|
|||
namespace Tests\Feature\Manufacturers\Ui;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Manufacturer;
|
||||
use Tests\TestCase;
|
||||
|
||||
class CreateManufacturerTest extends TestCase
|
||||
|
@ -13,4 +14,19 @@ class CreateManufacturerTest extends TestCase
|
|||
->get(route('manufacturers.create'))
|
||||
->assertOk();
|
||||
}
|
||||
|
||||
public function testUserCanCreateManufacturer()
|
||||
{
|
||||
$this->assertFalse(Manufacturer::where('name', 'Test Manufacturer')->exists());
|
||||
|
||||
$this->actingAs(User::factory()->superuser()->create())
|
||||
->post(route('manufacturers.store'), [
|
||||
'name' => 'Test Manufacturer',
|
||||
'notes' => 'Test Note',
|
||||
])
|
||||
->assertRedirect(route('manufacturers.index'));
|
||||
|
||||
$this->assertTrue(Manufacturer::where('name', 'Test Manufacturer')->where('notes', 'Test Note')->exists());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,4 +14,23 @@ class UpdateManufacturerTest extends TestCase
|
|||
->get(route('manufacturers.edit', Manufacturer::factory()->create()->id))
|
||||
->assertOk();
|
||||
}
|
||||
|
||||
public function testUserCanEditManufacturers()
|
||||
{
|
||||
$manufacturer = Manufacturer::factory()->create(['name' => 'Test Manufacturer']);
|
||||
$this->assertTrue(Manufacturer::where('name', 'Test Manufacturer')->exists());
|
||||
|
||||
$response = $this->actingAs(User::factory()->superuser()->create())
|
||||
->put(route('manufacturers.update', ['manufacturer' => $manufacturer]), [
|
||||
'name' => 'Test Manufacturer Edited',
|
||||
'notes' => 'Test Note Edited',
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertSessionHasNoErrors()
|
||||
->assertRedirect(route('manufacturers.index'));
|
||||
|
||||
$this->followRedirects($response)->assertSee('Success');
|
||||
$this->assertTrue(Manufacturer::where('name', 'Test Manufacturer Edited')->where('notes', 'Test Note Edited')->exists());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue