/** * Get the 'return to index' URL. * * @return string */ protected function getReturnUrl() { if ($this->resource->category and $this->resource->category->getKey()) { return route('category.show', [$this->resource->category->getKey()]); } return parent::getReturnUrl(); }
/** * Class constructor. * * @param App\Model $resource Instance of the resource this controller is in charge of. * * @return void */ public function __construct(User $resource) { $user = auth()->user() ?: new User(); // Fallback for `php artisan route:list` to work $permissions = ['view' => $user->hasPermission(60), 'add' => $user->hasPermission(61), 'edit' => $user->hasPermission(62), 'delete' => $user->hasPermission(63), 'viewAccount' => $user->hasPermission(100), 'viewCountry' => $user->hasPermission(10) and $this->with[] = 'country', 'viewLanguage' => $user->hasPermission(20), 'viewProfile' => $user->hasPermission(40) and $this->with[] = 'profile']; parent::__construct($resource, $permissions); }
/** * Class constructor. * * @param App\Model $resource Instance of the resource this controller is in charge of. * * @return void */ public function __construct(Currency $resource) { $user = auth()->user() ?: new User(); // Fallback for `php artisan route:list` to work $permissions = ['view' => $user->hasPermission(120), 'add' => $user->hasPermission(121), 'edit' => $user->hasPermission(122), 'delete' => $user->hasPermission(123), 'viewCountry' => $user->hasPermission(10)]; parent::__construct($resource, $permissions); }
/** * Class constructor. * * @param App\Model $resource Instance of the resource this controller is in charge of. * * @return void */ public function __construct(AuthProvider $resource) { $user = auth()->user() ?: new User(); // Fallback for `php artisan route:list` to work $permissions = ['view' => $user->hasPermission(80), 'add' => $user->hasPermission(81), 'edit' => $user->hasPermission(82), 'delete' => $user->hasPermission(83), 'viewAccount' => $user->hasPermission(100) and $this->with[] = 'accounts']; parent::__construct($resource, $permissions); }
/** * Class constructor. * * @param App\Model $resource Instance of the resource this controller is in charge of. * * @return void */ public function __construct(Language $resource) { $user = auth()->user() ?: new User(); // Fallback for `php artisan route:list` to work $permissions = ['view' => $user->hasPermission(20), 'add' => $user->hasPermission(21), 'edit' => $user->hasPermission(22), 'delete' => $user->hasPermission(23), 'viewUser' => $user->hasPermission(10) and $this->with[] = 'users']; parent::__construct($resource, $permissions); }
/** * Class constructor. * * @param App\Model $resource Instance of the resource this controller is in charge of. * * @return void */ public function __construct(Document $resource) { $user = auth()->user() ?: new User(); // Fallback for `php artisan route:list` to work $permissions = ['view' => $user->hasPermission(140), 'add' => $user->hasPermission(141), 'edit' => $user->hasPermission(142), 'delete' => $user->hasPermission(143), 'viewProfile' => $user->hasPermission(40) and $this->with[] = 'profiles']; parent::__construct($resource, $permissions); // Relationships to validate when saving resource $this->relationships = ['profiles' => [_('Profiles'), 'required|array|min:1']]; }
/** * @param $x * @param $y * @return \Illuminate\View\View */ public function getMap() { TaskController::checkTasks(); $cities = Auth::user()->cities; foreach ($cities as $city) { ResourceController::processProduction($city); } return view('map', ['help' => '/help/map']); }
public function getWall($id) { TaskController::checkTasks(); $city = City::where('id', $id)->first(); if (!$this->validateOwner($city)) { return redirect('/home')->withErrors('Nem a te városod'); } $wall = $city->building_slot->wall; $wall = Building::find($wall); $production = ResourceController::processProduction($city); return view('wall', ['city' => $city, 'wall' => $wall, 'production' => $production]); }
/** * shows the selected building * * @param $city_id * @param $slot_num * @param $building_id * @return $this|\Illuminate\View\View */ public function getBuilding($city_id, $slot_num, $building_id) { TaskController::checkTasks(); $city = City::find($city_id); if (!$this->validateOwner($city)) { return redirect('/home')->withErrors('Nem a te városod'); } $production = ResourceController::processProduction($city); if ($building = $this->buildingCompleted($building_id)) { return view('building', ['city' => $city, 'building' => $building, 'production' => $production]); } return redirect("/city/{$city->id}")->withErrors(['no_building' => "Ezen az építési területen nem található épület"]); }
/** * */ public function getHome() { $user = Auth::user(); $username = $user->name; $cities = Auth::user()->cities; TaskController::checkTasks(); $productions = []; if (!count($cities)) { // TODO if the user has not got any city. } foreach ($cities as $city) { $productions[$city->id] = ResourceController::processProduction($city); } $armies = $user->armies; $coords = []; foreach ($armies as $army) { $coords[$army->id] = ['x' => $army->currentHex->x, 'y' => $army->currentHex->y]; } return view('home', ['username' => $username, 'cities' => $cities, 'help' => '/help/home', 'productions' => $productions, 'armies' => $armies, 'coords' => $coords]); }
/** * Remove the specified resource. * * @param int $id * @return Response */ public function destroy($id) { // Make sure resource exists $resource = $this->resource->findOrFail($id); // Move pages to the parent if (with($pages = $resource->pages)->count()) { // Check if there is actually a parent category to be used as destination if ($resource->isRoot()) { Session::flash('error', _('The category cannot be deleted because it has directly assigned pages') . '. ' . _('Please move those pages to another category first')); return redirect()->back()->withInput(); } Page::where('category_id', $resource->id)->update(['category_id' => $resource->parent->id]); } // Move subcategories to the parent foreach ($resource->children as $children) { $resource->isRoot() ? $children->makeRoot() : $children->makeChildOf($resource->parent); } return parent::destroy($id); }
/** * Show the form for editing the specified resource. * * @param int $id * * @return Response */ public function edit($id) { // Purge permission cache Cache::forget('profile' . intval($id) . 'permissions'); return parent::edit($id); }
/** * Display a form for saving a resource. * * @param string $subtitle Page subtitle. * @param string $action Form route sufix. * @param string $method Form method. * @return Response */ protected function showForm($subtitle, $action, $method = 'POST') { view()->share(['languages' => \App\Language::orderBy('name')->withTrashed()->lists('name', 'id'), 'providers' => \App\Provider::orderBy('name')->withTrashed()->lists('name', 'id'), 'role' => \App\Role::orderBy('name')->lists('name', 'id')]); return parent::showForm($subtitle, $action, $method); }
public function __construct(Project $project) { parent::__construct(); $this->model = $project; $this->setBreadCrumbs(['List' => 'project.index', 'Create' => 'project.create']); }
/** * Update an exsiting resource. * * @param UpdateRequest * @param int $id * @return Response */ public function update(UpdateRequest $request, $id) { return parent::_update($request, $id); }
public function getBuildingsForCity($id) { $city = City::find($id); $buildings = \App\Building::all(); $modifiedPrices = ResourceController::getPricesForBuildings($buildings, $city); return $modifiedPrices; for ($i = 0; $i < count($buildings); $i++) { $buildings[$i]->resource = $modifiedPrices[$i]; } return $buildings; }
public function create() { parent::create(); $projects = Project::all()->lists('name', 'id'); $this->setViewData(compact('projects')); }
public function payForUnits($unitsToBuy, $army, $city) { $prices = ResourceController::getPricesForUnits($army->units, $city); $unitsToBuy = $this->getBuyCount($army->units, $unitsToBuy); foreach ($prices as $price) { foreach ($unitsToBuy as $unit) { if ($price['id'] == $unit['resource_id']) { $price->multiplyResource($unit['countToBuy']); } } } $resource = Resource::find($city->resource->id); $resource->substractResourceArray($prices); $resource->save(); }