A free open source IT asset/license management system
Add labels route for testing layouts
Cram4248fb4f2439ea
diff --git a/app/Http/Controllers/LabelsController.php b/app/Http/Controllers/LabelsController.phpnew file mode 100755index 0000000000..99214a5c1a--- /dev/null+++ b/app/Http/Controllers/LabelsController.php@@ -0,0 +1,73 @@+<?php++namespace App\Http\Controllers;++use App\Models\Asset;+use App\Models\AssetModel;+use App\Models\Category;+use App\Models\Company;+use App\Models\Labels\Label;+use App\Models\Manufacturer;+use App\Models\Setting;+use App\Models\User;+use App\View\Label as LabelView;+use Illuminate\Support\Facades\Storage;++class LabelsController extends Controller+{+ /**+ * Returns the Label view with test data+ *+ * @author Grant Le Roux <[email protected]>+ * @param string $labelName+ * @return \Illuminate\Contracts\View\View+ */+ public function show(string $labelName)+ {+ $this->authorize('view', Label::class);++ $labelName = str_replace('/', '\\', $labelName);+ $template = Label::find($labelName);++ $this->authorize('view', $template);++ $testAsset = new Asset();++ $testAsset->id = 999999;+ $testAsset->name = 'AST-AB-CD-1234';+ $testAsset->asset_tag = 'TCA-00001';+ $testAsset->serial = 'SN9876543210';++ $testAsset->company = new Company();+ $testAsset->company->id = 999999;+ $testAsset->company->name = 'Test Company Limited';+ $testAsset->company->image = 'company-image-test.png';++ $testAsset->assignedto = new User();+ $testAsset->assignedto->id = 999999;+ $testAsset->assignedto->first_name = 'Test';+ $testAsset->assignedto->last_name = 'Person';+ $testAsset->assignedto->username = 'Test.Person';+ $testAsset->assignedto->employee_num = '0123456789';++ $testAsset->model = new AssetModel();+ $testAsset->model->id = 999999;+ $testAsset->model->name = 'Test Model';+ $testAsset->model->model_number = 'MDL5678';+ $testAsset->model->manufacturer = new Manufacturer();+ $testAsset->model->manufacturer->id = 999999;+ $testAsset->model->manufacturer->name = 'Test Manufacturing Inc.';+ $testAsset->model->category = new Category();+ $testAsset->model->category->id = 999999;+ $testAsset->model->category->name = 'Test Category';++ return (new LabelView())+ ->with('assets', collect([$testAsset]))+ ->with('settings', Setting::getSettings())+ ->with('template', $template)+ ->with('bulkedit', false)+ ->with('count', 0);++ return redirect()->route('home')->with('error', trans('admin/labels/message.does_not_exist'));+ }+}diff --git a/public/uploads/companies/.gitignore b/public/uploads/companies/.gitignoreindex f935021a8f..a24807084c 100755--- a/public/uploads/companies/.gitignore+++ b/public/uploads/companies/.gitignore@@ -1 +1,2 @@!.gitignore+!company-image-test.png\ No newline at end of filediff --git a/public/uploads/companies/company-image-test.png b/public/uploads/companies/company-image-test.pngnew file mode 100644index 0000000000..681ec5401eBinary files /dev/null and b/public/uploads/companies/company-image-test.png differdiff --git a/routes/web.php b/routes/web.phpindex 4c52918f8e..ca7a5beac2 100644--- a/routes/web.php+++ b/routes/web.php@@ -10,6 +10,7 @@ use App\Http\Controllers\DepreciationsController;use App\Http\Controllers\GroupsController;use App\Http\Controllers\HealthController;use App\Http\Controllers\ImportsController;+use App\Http\Controllers\LabelsController;use App\Http\Controllers\LocationsController;use App\Http\Controllers\ManufacturersController;use App\Http\Controllers\ModalController;@@ -40,6 +41,14 @@ Route::group(['middleware' => 'auth'], function () {'parameters' => ['category' => 'category_id'],]);+ /*+ * Labels+ */+ Route::get(+ 'labels/{labelName}',+ [LabelsController::class, 'show']+ )->where('labelName', '.*')->name('labels.show');+/** Locations*/