First stab at handling the n+1 issue on licenses

This commit is contained in:
snipe
2017-11-02 18:20:42 -07:00
parent f47075c180
commit 368ac5b85d
2 changed files with 3 additions and 5 deletions
@@ -21,7 +21,7 @@ class LicensesController extends Controller
public function index(Request $request)
{
$this->authorize('view', License::class);
$licenses = Company::scopeCompanyables(License::with('company', 'licenseSeatsRelation', 'manufacturer', 'supplier'));
$licenses = Company::scopeCompanyables(License::with('company', 'licenseseats', 'manufacturer', 'supplier')->withCount('licenseseats'));
if ($request->has('search')) {
$licenses = $licenses->TextSearch($request->input('search'));