public function updateRoles(Request $request) { // dd($request->user_id); // dd($request->role); $updateRole = \CrudHelper::show(new \App\User(), 'id', $request->user_id)->first(); $updateRole->roles()->sync([$request->role]); return redirect()->route('admin')->with('success_message', 'Role for' . $updateRole['name'] . ' has been updated...'); }
public function buildOrder($products) { $orderAmount = 0; foreach ($products as $productKey => $productValue) { $getProduct[] = \CrudHelper::show(new \App\Product(), 'id', $productValue, ['images'])->first()->toArray(); unset($getProduct[$productKey]['created_at']); unset($getProduct[$productKey]['updated_at']); unset($getProduct[$productKey]['description']); $orderAmount = $orderAmount + $getProduct[$productKey]['price']; } $orderDetails = ['products' => $getProduct, 'orderAmount' => $orderAmount]; return $orderDetails; }
/** * The main call point for output of a field * * This gives the sub-classes a chance to decide if any special * process should take place before calling for final output * * @param string $field * @return string */ public function output($field, $options = []) { $outputStrategy = $this->helper->columnType($field); return $this->{$outputStrategy}($field); }
public function getLoan($id) { $loan = \CrudHelper::show(new \App\Loan(), 'id', $id); return $loan; }
/** * Unset users already able to view the contact * * @depends testGetAllUsers * @return Collection Collection of users able to view a contact */ public function testUnsetCanView($users) { $contact = CrudHelper::index(new App\CompanyContact(), ['canView'])->first(); $canViews = $contact->canView; $unsetCanViews = $this->contactsController->unsetCanView($canViews); foreach ($users as $user) { foreach ($canViews as $canView) { if ($user->id === $canView->id) { foreach ($unsetCanViews as $unsetCanView) { $this->assertTrue($unsetCanView->id !== $canView->id); } } } } }
/** * Unset categories that have been previously selected * * @depends testGetPeopleCategories * @return void */ public function testUnsetSelectedCategory($allCategories) { $people = \CrudHelper::index(new \App\PeopleContact(), ['category'])->first(); $selectedCategories = $people->category; // Provide $model, $selectedCategories $unsetSelectedCategories = $this->contactsController->unsetSelectedCategory(new \App\PeopleCategory(), $selectedCategories); foreach ($allCategories as $category) { foreach ($selectedCategories as $selectedCategory) { if ($category['id'] === $selectedCategory->id) { foreach ($unsetSelectedCategories as $unsetSelectedCategory) { $this->assertTrue($unsetSelectedCategory->id !== $selectedCategory->id); } } } } }