/** * @param Request $request * @param Team $team * @param AccountManager $manager * @return Team */ public function store(Request $request, Team $team, AccountManager $manager) { $team->account()->associate($manager->account()); $team->fill($request->get('translations')); $team->save(); return $team; }
/** * @param AccountManager $manager * @param Store $session * @return \Illuminate\Contracts\View\View * @throws \Exception */ public function index(AccountManager $manager, Store $session) { $account = $manager->account(); $contact = $account->contactInformation->first(); $success = $session->get('success'); return $this->theme->render('contact.' . $this->theme->setting('contactLayout'), ['contact' => $contact, 'success' => $success]); }
/** * @param Store $session * @param Request $request * @param AccountManager $accounts * @return \Illuminate\Http\RedirectResponse */ public function locale(Store $session, Request $request, AccountManager $accounts) { $account = $accounts->account(); if ($request->has('locale') && $this->is_account_locale($account, $request->get('locale'))) { $session->set('locale', $request->get('locale')); return redirect()->to('/' . $request->get('locale')); } return redirect()->to(store_route('store.home')); }
/** * @param Project $portfolio * @param AccountManager $manager * @return mixed */ public function index(Project $portfolio, AccountManager $manager) { $account = $manager->account(); $members = $account->members; foreach ($members as $member) { $member->selected = $portfolio->collaborators->contains($member->id); } $members->load(['images']); return $members; }
/** * This route is only valid for multi locale applications. * * @param Request $request * @param AccountManager $manager * @return \Illuminate\Contracts\View\View|\Illuminate\Http\RedirectResponse */ public function landing(Request $request, AccountManager $manager) { if ($manager->account()->locales->count() == 1) { return redirect()->to(store_route('store.home')); } if ($request->hasCookie('locale')) { return redirect()->to(store_route('store.home', [], [], $request->cookie('locale'))); } return $this->theme->render('home.landing'); }
/** * @param Request $request * @param Post $post * @param Guard $guard * @param AccountManager $accounts * @return Post|string|static */ public function store(Request $request, Post $post, Guard $guard, AccountManager $accounts) { $input = translation_input($request); $post = $post->newInstance($input); $post->account_id = $accounts->account()->id; $post->user()->associate($guard->user()); if ($post->save()) { return $post; } return json_encode(['status' => 'noke']); }
/** * @param $invitation * @param Request $request * @param AccountManager $manager * @return mixed */ public function destroy($invitation, Request $request, AccountManager $manager) { $account = $manager->account(); if ($account->membershipInvitations->contains($invitation)) { $invitation = $account->membershipInvitations->find($invitation); if ($invitation->delete()) { $invitation->id = false; } } return $invitation; }
/** * @param AccountManager $accountManager * @param Team $team * @return \Illuminate\Contracts\View\View */ public function index(AccountManager $accountManager, Team $team) { $account = $accountManager->account(); $memberships = $account->memberships; //make sure to test all templates when changing these relations. //some templates show data by running through teams and others by running through memberships $memberships->load(['member', 'member.images', 'member.socialLinks', 'member.skills', 'member.skills.translations']); $teams = $team->with(['memberships', 'translations'])->whereHas('memberships', function ($query) { $query->whereNotNull('id'); }, '>=')->get(); return $this->theme->render('team.index', ['memberships' => $memberships, 'teams' => $teams]); }
/** * @param Filesystem $files * @param AccountManager $manager * @return mixed */ public function handle(Filesystem $files, AccountManager $manager) { $temp_dir = storage_path('media') . '/' . $this->owner->getMediaFolder('images'); $name = $this->uniqueName(); $this->image->move($temp_dir, $name); $temp_file = $temp_dir . $name; $name_with_extension = $name . $this->extension($temp_file); $final_path = $temp_file . $name_with_extension; $files->move($temp_file, $final_path); $image = $this->dispatch(new StoreNewImage($manager->account(), $this->owner, $final_path)); $files->delete($final_path); return $image; }
/** * @param AccountManager $accounts * @param MediaRepositoryInterface $media * @param Locale $locale * @return bool */ public function handle(AccountManager $accounts, MediaRepositoryInterface $media, Locale $locale) { if ($this->input['mode'] == 'youtube') { $info = $this->handleYoutube(); } elseif ($this->input['mode'] == 'vimeo') { $info = $this->handleVimeo(); } if (!$info) { return false; } $locale = $locale->whereSlug($this->input['locale'])->firstOrFail(); $input = array_merge(array_except($this->input, ['url', 'mode']), ['provider' => $this->input['mode'], 'provider_id' => $info['provider_id'], 'provider_thumbnail' => $info['provider_thumbnail'], 'title' => $info['title'], 'description' => $info['description'], 'width' => $info['width'], 'height' => $info['height'], 'account_id' => $accounts->account()->id, 'locale_id' => $locale->id]); return $media->createVideo($this->owner, $input); }
/** * @param Request $request * @param Product $product * @param Guard $guard * @param AccountManager $accounts * @return Product|string|static */ public function store(Request $request, Product $product, Guard $guard, AccountManager $accounts) { $this->validate($request, ['brand_id' => 'required|exists:product_brands,id', 'name' => 'required|string', 'ean' => 'string|size:13']); $input = translation_input($request); $name = $request->get('name'); foreach (Locale::all() as $locale) { $input[$locale->slug] = ['name' => $name]; } $product = $product->newInstance($input); $product->account_id = $accounts->account()->id; if ($product->save()) { return $product; } return json_encode(['status' => 'noke']); }
/** * @param Request $request * @param Module $module * @param AccountManager $manager * @param Pusher $pusher */ public function toggle(Request $request, Module $module, AccountManager $manager, Pusher $pusher) { $module = $module->findOrFail($request->get('id')); $account = $manager->account(); if ($request->get('activated')) { //attach module $account->modules()->attach($module->id); //broadcast event $pusher->trigger(pusher_account_channel(), 'system.hard-reload', []); } else { //detach module $account->modules()->detach($module->id); //broadcast event $pusher->trigger(pusher_account_channel(), 'system.hard-reload', []); } }
/** * @param Gravatar $gravatar * @param Filesystem $files * @param AccountManager $manager * @throws \Exception */ public function handle(Gravatar $gravatar, Filesystem $files, AccountManager $manager) { if ($gravatar->exists($this->user->email)) { $gravatar->setAvatarSize(512); $url = $gravatar->get($this->user->email); $content = file_get_contents($url); $tmpDir = storage_path('media' . '/' . $this->user->getMediaFolder()); if (!$files->isDirectory($tmpDir)) { $files->makeDirectory($tmpDir, 0755, true); } $path = $tmpDir . sha1(time() . 'user-profile-pic' . $this->user->id); $files->put($path, $content); $finalPath = $this->pathWithExtension($path); $files->move($path, $finalPath); $this->dispatch(new StoreNewImage($manager->account(), $this->user, $finalPath)); $files->delete($finalPath); } }
/** * @param AccountManager $manager * @return */ public function index(AccountManager $manager) { $account = $manager->account(); $account->load(['memberships', 'memberships.member', 'memberships.member.images', 'memberships.teams', 'teams', 'teams.translations']); $teams = $account->teams; foreach ($teams as $team) { $team->selected = false; } $teams = $teams->keyBy('id'); foreach ($account->memberships as $membership) { $membershipTeams = clone $teams; foreach ($membership->teams as $team) { $team->selected = true; $membershipTeams->put($team->id, $team); } $membership->setRelation('teams', $membershipTeams); } return $account->memberships; }
/** * @param PageRepository $pages * @param ModuleRoute $route * @param AccountManager $manager * @return mixed */ public function index(PageRepository $pages, ModuleRoute $route, AccountManager $manager) { $menus = $this->menu->getMenus(); $validRoutes = $manager->account()->modules->routes(); $validRoutes = $validRoutes->lists('id')->toArray(); foreach ($menus as $menu) { $usedPages = new Collection(); $usedRoutes = new Collection(); foreach ($menu->items as $item) { if ($item->page) { $usedPages->push($item->page); } if ($item->route) { $usedRoutes->push($item->route); } } $menu->availablePages = $pages->with('translations')->mainPages()->but($usedPages)->get(); $menu->availableRoutes = $route->with('translations')->whereIn('id', $validRoutes)->but($usedRoutes)->get(); } return $menus; }
/** * @param AccountContactInformation $accountContactInformation * @param UpdateInformationRequest $request * @param AccountManager $manager */ public function update(AccountContactInformation $accountContactInformation, UpdateInformationRequest $request, AccountManager $manager) { $response = $this->dispatch(new UpdateInformation($accountContactInformation, translation_input($request))); $manager->updated(); }
/** * @param AccountManager $manager */ public function __construct(AccountManager $manager) { $this->account = $manager->account(); }
/** * @param AccountManager $manager * @param Request $request * @return mixed * @throws Exception */ public function index(AccountManager $manager, Request $request) { $owner = $this->owner($request); return $owner->socialLinks()->firstOrCreate(['account_id' => $manager->account()->id]); }
/** * @param MenuRepository $menu * @param Repository $cache * @param AccountManager $manager */ public function __construct(MenuRepository $menu, Repository $cache, AccountManager $manager) { $this->menu = $menu; $this->cache = $cache; $this->account = $manager->account(); }
/** * @param array $payload * @return bool */ public function createMenu(array $payload) { $menu = $this->menu->newInstance($payload); $menu->account_id = $this->account->account()->id; return $menu->save(); }
/** * @param AccountManager $account * @return array */ protected function pusherInfo(AccountManager $account) { return ['channel' => $account->account()->alias, 'apikey' => env('PUSHER_API_KEY')]; }
/** * @param Project $project * @param AccountManager $accounts * @return Project|string */ public function store(Project $project, AccountManager $accounts) { $project->newInstance(); $project->account_id = $accounts->account()->id; return $project->save() ? $project : json_encode(['status' => 'noke']); }
/** * @param Client $client * @param Request $request * @param AccountManager $manager * @return static */ public function store(Client $client, Request $request, AccountManager $manager) { $input = array_merge(['account_id' => $manager->account()->id], translation_input($request, ['description'])); return $client->create($input); }
/** * @param AccountManager $manager * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function settings(AccountManager $manager) { $themes = $this->theme->supported(); return view('theme::admin.settings', ['themes' => $themes, 'account' => $manager->account(), 'current' => $this->theme->current()]); }
/** * @param Request $request * @param AccountManager $manager * @param $locale * @return array */ protected function postsQuery(Request $request, AccountManager $manager, $locale) { return ['index' => 'framework', 'type' => 'posts', 'body' => ['query' => ['filtered' => ['query' => ['nested' => ['path' => "translations.{$locale}", 'query' => ['multi_match' => ['query' => $request->get('query'), 'fields' => ["translations.{$locale}.title", "translations.{$locale}.content", "translations.{$locale}.extract"]]]]], 'filter' => ['bool' => ['must' => [['term' => ['account_id' => $manager->account()->id]], ['nested' => ['path' => "translations.{$locale}", 'query' => ['range' => ["translations.{$locale}.publish_at" => ['lte' => 'now']]]]]]]]]]]]; }
/** * @param $template * @param Guard $guard * @param AccountManager $manager * @param Store $session * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function template($template, Guard $guard, AccountManager $manager, Store $session) { $user = $guard->user(); return view('layout::admin.' . $template, ['user' => $user, 'account' => $manager->account(), 'theme' => $this->theme->current()]); }
/** * @param Theme $theme * @param AccountManager $manager * @param ThemeSelection $selection */ public function __construct(Theme $theme, AccountManager $manager, ThemeSelection $selection) { $this->theme = $theme; $this->account = $manager->account(); $this->selector = $selection; }
/** * @param AccountManager $accountManager * @param MenuRepositoryInterface $menu */ public function __construct(AccountManager $accountManager, MenuRepositoryInterface $menu) { $this->account = $accountManager->account(); $this->menu = $menu; }
/** * @param Request $request * @param Category $category * @param Brand $brand * @param AccountManager $manager */ public function detail(Request $request, Category $category, Brand $brand, AccountManager $manager) { $status = $request->get('status'); $brand = $brand->find($request->get('brand')); $category = $category->find($request->get('category')); if ($status) { $this->dispatch(new NotifyDetailActivation($brand, $category, $manager->account())); } else { $this->dispatch(new NotifyDetailDeactivation($brand, $category, $manager->account())); } }