public function home() { $this->view->title = $this->view->site_name; $this->view->asset_count = Asset::count(); $this->view->user_count = User::count(); $this->view->crew_count = Crew::count(); $this->view->job_list_count = JobList::count(); $this->view->job_count = Job::count(); $this->view->tag_count = Tag::count(); return $this->view; }
/** * @testdox Assets have a unique alphanumeric identifier of up to 150 characters. * @test */ public function asset() { $asset = new Asset(); $asset->identifier = 'TEST123'; $asset->save(); $this->assertEquals(1, Asset::count()); $this->assertEquals('TEST123', $asset->identifier); $asset2 = new Asset(); $asset2->identifier = str_repeat('A', 180); $asset2->save(); $this->assertEquals(str_repeat('A', 150), $asset2->identifier); }
public function index(Request $request) { // Get search terms. $assetIdentifiers = preg_split('/(\\n|\\r)/', $request->input('identifiers', ''), null, PREG_SPLIT_NO_EMPTY); $this->view->identifiers = array_map('trim', $assetIdentifiers); $this->view->identifier = trim($request->input('identifier')); $this->view->tagged = $request->input('tagged'); $this->view->not_tagged = $request->input('not_tagged'); // No assets at all? if (Asset::count() === 0) { $this->alert('info', trans('app.no-assets-yet'), false); } // Build and execute query. if ($this->view->identifiers || $this->view->identifier || $this->view->tagged) { $assets = Asset::query(); if (!empty($this->view->identifiers)) { $assets->whereIn('identifier', $this->view->identifiers); } if (!empty($this->view->identifier)) { $assets->where('identifier', 'LIKE', '%' . $this->view->identifier . '%'); $this->view->quick_s = $this->view->identifier; } if ($this->view->tagged) { $assets->tagged($this->view->tagged); } $this->view->assets = $assets->paginate(50); if ($this->view->assets->total() === 0) { $this->alert('success', 'No assets found with the given criteria.', false); } } // Add extra view data, and return. $this->view->title = 'Assets'; $this->view->breadcrumbs = ['assets' => 'Assets']; $this->view->quick_t = 'a'; return $this->view; }