Example #1
0
 /**
  * Bind data to the view.
  *
  * @param  View $view
  *
  * @return void
  */
 public function compose(View $view)
 {
     if ($view->group_form_errors and $view->errors->any()) {
         $view->nest('form_error_content', $view->bsb_pkg_ref . '::form.control.errors', ['errors' => $view->errors->all()]);
     }
     foreach ($view->groups as $name => &$input) {
         if (is_array($input)) {
             if (count(array_filter(array_keys($input), 'is_string'))) {
                 //The array contains named keys, generate inputs from these options
                 $view_name = $view->bsb_pkg_ref . '::input.' . (empty($input['type']) ? 'text' : $input['type']);
                 if (!view()->exists($view_name)) {
                     $view_name = $view->bsb_pkg_ref . '::input.' . 'text';
                 }
                 $input = view($view_name, array_merge(compact('name'), $input), $view->getData());
             } else {
                 //The array contains html strings, display them together within a form-group
                 $input = view($view->bsb_pkg_ref . '::input.group', ['content' => implode("\n", $input)], $view->getData());
             }
         } elseif (!str_contains($input, '.form-group')) {
             //The input is just a string of html, but it doesn't contain any .form-group element, so we'll wrap it in one
             $input = view($view->bsb_pkg_ref . '::input.group', ['content' => $input], $view->getData());
         }
     }
     //TODO: add form-horizontal and form-inline options
 }
 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     $sidebar_tags = [];
     if (isset($view->getData()['tree']) && !isset($view->getData()['trees'])) {
         $sidebar_tags = $view->getData()['tree']->getAllTags();
     }
     $view->with('sidebar_tags', $sidebar_tags);
 }
Example #3
0
 /**
  * Composer for showing a user
  *
  * @param View $view
  */
 public function compose(View $view)
 {
     $user = $view->getData()['user'];
     $view->with('user_courses', \User::userCoursesPaginate($user));
     $view->with('user_courses_count', \User::countUserCourses($user));
     $view->with('count_followers', \User::countFollowers($user));
 }
Example #4
0
 /**
  * Bind data to the view.
  *
  * @param View $view
  *
  * @return void
  */
 public function compose(View $view)
 {
     $data = $view->getData();
     if (Auth::check()) {
         $notifications = Auth::user()->notifications()->with('user')->orderBy('created_at', 'desc')->take(15)->get();
         $view->with('notifications', $notifications);
         $unreadCount = Auth::user()->notifications()->wherePivot('read', false)->count();
         $view->with('newNotificationsCount', $unreadCount);
     }
     // Get object from which we can extract name to use as page title
     $currentGroup = head(array_only($data, ['group', 'folder', 'fakeGroup']));
     $view->with('currentGroup', $currentGroup);
     if (isset($currentGroup) && isset($currentGroup->name)) {
         $pageTitle = $currentGroup->name;
         // Homepage title shall always be Strimoid.pl
         if ($currentGroup->urlname == 'all' && !Setting::get('homepage_subscribed', false)) {
             $pageTitle = 'Strimoid';
         }
         if ($currentGroup->urlname == 'subscribed' && Setting::get('homepage_subscribed', false)) {
             $pageTitle = 'Strimoid';
         }
     } else {
         $pageTitle = 'Strimoid';
     }
     $view->with('pageTitle', $pageTitle);
     // Needed by top bar with groups
     $popularGroups = Cache::remember('popularGroups', 60, function () {
         return Group::orderBy('subscribers_count', 'desc', true)->take(30)->get(['id', 'name', 'urlname']);
     });
     $view->with('popularGroups', $popularGroups);
 }
 public function compose(View $view)
 {
     $viewData = $view->getData();
     if (!array_keys_exist(['module', 'model', 'errors'], $viewData)) {
         return;
     }
     app(BlenderFormBuilder::class)->init($viewData['module'], $viewData['model'], $viewData['errors']);
 }
Example #6
0
 /**
  * @param View $view
  * @throws InstanceMissmatchException
  */
 public function compose(View $view)
 {
     $data = array_get($view->getData(), 'metaData', $this->wrapper->getMetaData());
     if (!$data instanceof MetaData) {
         throw new InstanceMissmatchException(sprintf('Data [%s] is not an instance of [%s]', gettype($data), MetaData::class));
     }
     $view->with('metaData', $data);
 }
Example #7
0
 public function compose(View $view)
 {
     //Get the data from the view
     $viewParameters = $view->getData();
     //Get the data
     $list = $this->list_repository->getByModule($viewParameters['module_id']);
     // Agregate and Send the data to the view
     $data = array('list' => $list);
     $view->with($data);
 }
Example #8
0
 public function compose(View $view)
 {
     //Get the data from the view
     $viewParameters = $view->getData();
     //Get the data
     $slideshow = $this->slideshow_repository->getByModule($viewParameters['module_id']);
     // Agregate and Send the data to the view
     $data = array_merge(array('slideshow' => $slideshow), $viewParameters);
     $view->with($data);
 }
Example #9
0
 public function compose(View $view)
 {
     //Get the data from the view
     $viewParameters = $view->getData();
     //Get the data
     $group_module = $this->repository->getByModule($viewParameters['module_id']);
     $modules = $this->module_repository->all();
     // Agregate and Send the data to the view
     $data = array_merge(array('group_module' => $group_module, 'modules' => $modules));
     $view->with($data);
 }
Example #10
0
 /**
  * Bind data to the view.
  *
  * @param \Illuminate\Contracts\View\View $view
  */
 public function compose(View $view)
 {
     $view->withThemeBackgroundColor(Setting::get('style_background_color'));
     $view->withThemeTextColor(Setting::get('style_text_color'));
     $viewData = $view->getData();
     $themeView = array_only($viewData, preg_grep('/^theme/', array_keys($viewData)));
     $hasThemeSettings = array_filter($themeView, function ($data) {
         return $data != null;
     });
     $view->withThemeSetup(!empty($hasThemeSettings));
 }
Example #11
0
 public function compose(View $view)
 {
     //Get the data from the view
     $viewParameters = $view->getData();
     //Set languages to the $data
     $parameters = $viewParameters['parameters'];
     $data = array('langs' => $this->lang_repository->all());
     // Agregate and Send the data to the view
     $data = array_merge($data, $viewParameters);
     $view->with($data);
 }
Example #12
0
 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     $employee = $view->getData()['employee'];
     $credit = $employee->leave_credit;
     $accumulated = $employee->accumulated_leave;
     $credits = collect();
     $credits->push(['title' => 'Force leave', 'icon' => 'envelope', 'color' => 'warning', 'count' => $credit->force_leave]);
     $credits->push(['title' => 'Special leave', 'icon' => 'star', 'color' => 'primary', 'count' => $credit->special_leave]);
     $credits->push(['title' => 'Vacation leave', 'icon' => 'plane', 'color' => 'primary', 'count' => $accumulated->vacation_leave]);
     $credits->push(['title' => 'Sick leave', 'icon' => 'hospital-o', 'color' => 'danger', 'count' => $accumulated->sick_leave]);
     $view->with(compact('credits'));
 }
Example #13
0
 public function compose(View $view)
 {
     $voteValue = 0;
     $comment = $view->getData()['comment'];
     if (Auth::check()) {
         $votes = $comment->votes()->where('user_id', Auth::id());
         if ($votes->count() > 0) {
             $voteValue = $votes->first()->value;
         }
     }
     $view->with('voteValue', $voteValue);
     $view->with('score', $comment->votes()->sum('value'));
 }
Example #14
0
 public function compose(View $view)
 {
     //Get the data from the view
     $viewParameters = $view->getData();
     //Get the data
     $folders = $this->folder_repository->getFullFolders();
     $foldersroot = array();
     foreach ($folders as $folder) {
         if ($folder->folder_parent_id == null) {
             $foldersroot[] = $folder;
         }
     }
     $images = $this->image_repository->getListByFolder();
     $data = array_merge($images, array('foldersroot' => $foldersroot, 'folders' => $folders));
     // Agregate and Send the data to the view
     $data = array_merge($data, $viewParameters);
     $view->with($data);
 }
Example #15
0
 public function compose(View $view)
 {
     //Get the data from the view
     $viewParameters = $view->getData();
     $parameters = $viewParameters['parameters'];
     $data = array();
     if (count($parameters) >= 2 && isset($parameters['profile']) && is_numeric($parameters['profile'])) {
         $user_id = intval($parameters['profile']);
         $user = $this->user_repository->show($user_id);
         if ($user != null) {
             $data = array_merge(array('mode' => 'show'), $user);
         }
     } else {
         $data = array('mode' => 'list', 'users' => $this->user_repository->index(10));
     }
     // Agregate and Send the data to the view
     $data = array_merge($data, $viewParameters);
     $view->with($data);
 }
Example #16
0
 public function compose(View $view)
 {
     //Get the data from the view
     $viewParameters = $view->getData();
     $parameters = $viewParameters['parameters'];
     $data = array();
     if (count($parameters) >= 2 && isset($parameters['post'])) {
         if (is_numeric($parameters['post'])) {
             $post_id = intval($parameters['post']);
             $data = $this->getPostById($post_id, $viewParameters);
         } else {
             $post_slug = $parameters['post'];
             $data = $this->getPostBySlug($post_slug, $viewParameters);
         }
     } elseif (count($parameters) >= 2 && isset($parameters['tag'])) {
         $data = $this->getListTag($parameters['tag'], $viewParameters);
     } else {
         $data = $this->getList($viewParameters);
     }
     // Agregate and Send the data to the view
     $data = array_merge($data, $viewParameters);
     $view->with($data);
 }
Example #17
0
 /**
  * compose
  *
  * @param \Illuminate\Contracts\View\View|\Illuminate\View\View $view
  */
 public function compose(View $view)
 {
     $data = $view->getData();
     $view->with(['projectRefList' => $this->getRefList($data['project']), 'projectsList' => $this->getProjectList(), 'projectName' => $data['project']->getName(), 'projectRef' => $data['project']->getRef()]);
 }
Example #18
0
 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     $society = $view->getData()['soc'];
     $data['services'] = Society::with('service')->where('society', '=', $society)->first();
     foreach ($data['services']->service as $service) {
         if ($service['language'] == "English" and $service['description'] == "") {
             $service->description = "Our " . $service->servicetime . " service is led in English by a minister or local preacher and a team of musicians. Everyone is welcome!";
         } elseif ($service['language'] == "isiZulu" and $service['description'] == "") {
             $service->description = "Our " . $service->servicetime . " service is led in isiZulu by a minister or local preacher and uses the liturgy and music of the Methodist Hymn Book. Everyone is welcome!";
         }
         $data['allservices'][] = $service;
     }
     if (!count($data['services'])) {
         return View::make('errors.404');
     }
     if (isset($view->getData()['pagetitle'])) {
         $data['pagetitle'] = $view->getData()['pagetitle'];
     } else {
         $data['pagetitle'] = $society;
     }
     $socid = Society::where('society', '=', $society)->select('id')->first()->id;
     if (Helpers::is_online() and $data['services']->society_calendar != "") {
         $privatecal = new GoogleCalendar();
         $data['cals'] = $privatecal->getTen($data['services']->society_calendar, 8);
     }
     $data['sermon'] = Sermon::with(['series' => function ($query) use($socid) {
         $query->where('society_id', '=', $socid);
     }])->orderBy('servicedate', 'DESC')->first();
     if (!$data['sermon'] or !$data['sermon']->series) {
         $data['sermon'] = "None";
     } else {
         if ($data['sermon']->preachable_type == 'App\\Models\\Minister') {
             $data['preacher'] = Minister::find($data['sermon']->preachable_id);
         } elseif ($data['sermon']->preachable_type == 'App\\Models\\Guest') {
             $data['preacher'] = Guest::find($data['sermon']->preachable_id);
         } else {
             $data['preacher'] = Preacher::find($data['sermon']->preachable_id);
         }
     }
     $data['welcome_page'] = "together a transforming discipleship movement";
     $data['welcome_page_pic'] = "/public/images/715.jpg";
     if ($data['services']->roster) {
         $data['roster'] = $data['services']->roster;
     }
     $data['society'] = Society::where('society', '=', $society)->first();
     if ($data['society']->roster) {
         $data['roster'] = $data['society']->roster;
     }
     $webpage = Webpage::where('society_id', '=', $data['society']->id)->get();
     foreach ($webpage as $pg) {
         $data[$pg->fieldname] = $pg->fieldvalue;
         $data[$pg->fieldname . '_pic'] = $pg->pageimage;
     }
     $data['route'] = Route::getCurrentRoute()->getPath();
     if ($data['route'] != "{society}" and $data['route'] != "/") {
         $linkadd = Helpers::makeUrl(strtolower($society), '');
     } else {
         $linkadd = "";
     }
     $menu['link'] = $linkadd . "#sundays";
     $menu['label'] = "Sundays";
     $menu['longlabel'] = "Sunday services";
     $data['menu'][] = $menu;
     $data['youth'] = Mission::where('society_id', '=', $data['society']->id)->where('category', '=', 'youth')->orderBy('created_at')->take(5)->get();
     if (count($data['youth'])) {
         $menu['link'] = $linkadd . "#youth";
         $menu['label'] = "Youth";
         $menu['longlabel'] = "Children and Youth";
         $data['menu'][] = $menu;
     }
     $data['groups'] = Group::where('society_id', '=', $data['society']->id)->where('publish', '=', 1)->get();
     if (count($data['groups'])) {
         foreach ($data['groups'] as $obj) {
             $dum[0] = $obj->groupname;
             $dum[1] = $obj->latitude;
             $dum[2] = $obj->longitude;
             $dum[3] = Helpers::makeUrl(strtolower($data['services']->society), 'groups/' . $obj->slug);
             $fin[] = $dum;
         }
         $data['fin'] = json_encode($fin);
         $menu['link'] = "#groups";
         $menu['label'] = "Groups";
         $menu['longlabel'] = "Small groups";
         $data['menu'][] = $menu;
     } else {
         $data['fin'] = "";
     }
     $data['missions'] = Mission::where('society_id', '=', $data['society']->id)->where('category', '=', 'project')->take(5)->get();
     if (count($data['missions'])) {
         $menu['link'] = $linkadd . "#projects";
         $menu['label'] = "Projects";
         $menu['longlabel'] = "Mission projects";
         $data['menu'][] = $menu;
     }
     $blogs = Blog::with('individual')->orderBy('created_at', 'desc')->take(10)->get();
     if (count($blogs)) {
         $first = true;
         foreach ($blogs as $blog) {
             $societies = explode(',', $blog->societies);
             if (in_array($data['society']->id, $societies)) {
                 if ($first) {
                     $data['firstblog'] = $blog;
                     $first = false;
                 } else {
                     $data['blogs'][] = $blog;
                 }
             }
         }
         if (isset($data['firstblog'])) {
             $menu['link'] = $linkadd . "#blog";
             $menu['label'] = "Blog";
             $menu['longlabel'] = "Latest blogs";
             $data['menu'][] = $menu;
         }
     }
     $menu['link'] = $linkadd . "#contact";
     $menu['label'] = "Contact";
     $menu['longlabel'] = "Contact us";
     $data['menu'][] = $menu;
     $data['counter'] = 1;
     $view->with('data', $data);
 }
Example #19
0
 /**
  * Bind data to the view.
  *
  * @param View $view
  */
 public function compose(View $view)
 {
     if (array_keys_exist(['module', 'model', 'errors'], $view->getData())) {
         BlenderForm::init($view['module'], $view['model'], $view['errors']);
     }
 }
Example #20
0
 public function compose(View $view)
 {
     $viewdata = $view->getData();
     $thumbnail = $this->file->findFileByZoneForEntity('thumbnail', $viewdata['post']);
     $view->with('thumbnail', $thumbnail);
 }