public function projects($search = null, $categories = null, $orderby = null, $paginate = true)
 {
     $result = null;
     /**
      * As buscas não são complementares: ou se filtra por termo ou por categoria(s)
      * mas nunca por ambos.
      */
     if ($paginate) {
         /**
          * SEARCH
          * Se existe um termo de busca, retorna a lista filtrada pelo termo
          */
         if (!is_null($search) && !empty($search)) {
             return Project::where('name', 'like', "%{$search}%")->paginate(env('PAGINATION_ITEMS', 10));
         }
         /**
          * CATEGORIES
          * Se existe uma ou mais categoria(s), retorna a lista filtrada por ela(s)
          */
         if (!is_null($categories) && !empty($categories)) {
             /**
              * Compila-se uma lista distinta projetos associados às caregorias informadas
              */
             $projectsFromCategories = DB::table('category_project')->whereIn('category_id', $categories)->distinct()->get(['project_id']);
             $projectIds = [];
             /**
              * Compila-se uma lista apenas com os IDs dos projetos pois
              * a lista acima possui array com objetos: [0 => StdClass('project_id': 1)]
              */
             foreach ($projectsFromCategories as $value) {
                 $projectIds[] = $value->project_id;
             }
             /**
              * Por fim retorna-se a lista dos projetos
              */
             return Project::whereIn('id', $projectIds)->paginate(env('PAGINATION_ITEMS', 10));
         }
         /**
          * ORDER BY
          * Se existe ordenação, retorna a lista ordenada pela instrução recebida
          */
         if (!is_null($orderby) && !empty($orderby)) {
             $order = explode('|', $orderby);
             return Project::orderBy($order[0], $order[1])->paginate(env('PAGINATION_ITEMS', 10));
         }
         /**
          * Caso nem exista nem termo de busca nem categorias, retorna-se a lista completa, paginada.
          */
         return Project::paginate(env('PAGINATION_ITEMS', 10));
     }
     /**
      * Este, sem paginação, visa atender à API
      */
     return Project::where('name', 'like', "%{$search}%")->get();
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $query = Project::orderBy("created_at", "desc");
     $paginate = new PaginateService($query);
     $this->data->projects = $paginate->data();
     $this->data->paging = $paginate->paging();
     if (Request::ajax()) {
         return $this->json();
     }
     return $this->view();
 }
 public function index()
 {
     $search['text'] = Input::get('search_text');
     $search['type'] = Input::get('search_type');
     if ($search['type'] == 'user') {
         $list = Project::where('manage', 'like', "%{$search['text']}%")->orderBy('id', 'desc')->paginate(15);
     } else {
         if ($search['type'] == 'name') {
             $list = Project::where('name', 'like', "%{$search['text']}%")->orderBy('id', 'desc')->paginate(15);
         } else {
             $list = Project::orderBy('id', 'desc')->paginate(15);
         }
     }
     return View::make('admin.project_list')->withlist($list)->withsearch($search);
 }
Example #4
0
 public function welcome()
 {
     if (!Schema::hasTable('settings')) {
         $data['firsttime'] = "yes";
         return view('firsttime', $data)->with('okmessage', 'Please create a user before you can use Connexion');
     }
     $user = Auth::user();
     if ($user and $user->individual_id) {
         $today = date('d-m-Y');
         $data['tasks'] = Task::where('donedate', '=', '')->where('project_id', '<>', 0)->where('individual_id', $user->individual_id)->orderBy('duedate')->get();
         $data['personal'] = Task::where('donedate', '=', '')->where('project_id', '=', 0)->where('individual_id', $user->individual_id)->orderBy('duedate')->get();
         $data['individuals'] = Individual::orderBy('surname')->get();
         $data['projects'] = Project::with('undonetask')->where('individual_id', $user->individual_id)->orderBy('project')->get();
         $data['projectselect'] = Project::orderBy('project')->lists('project', 'id');
         $data['page_title'] = Helpers::getSetting('circuit_name') . " Circuit";
         $data['page_description'] = "Administrator home page";
         $socs = Permission::where('user_id', '=', $user->id)->select('society_id')->get();
         foreach ($socs as $soc) {
             $thissoc = Society::where('id', '=', $soc->society_id)->get();
             $dum['googleCalendarId'] = $thissoc[0]->society_calendar;
             $dum['color'] = $thissoc[0]->calendar_colour;
             $data['cals'][] = $dum;
         }
         $dum['googleCalendarId'] = Helpers::getSetting('circuit_calendar');
         $dum['color'] = 'black';
         $data['cals'][] = $dum;
         if (Helpers::is_online() and $user->googlecalendar != "") {
             $privatecal = new GoogleCalendar();
             $pcals = $privatecal->getTen($user->googlecalendar);
             foreach ($pcals as $pcal) {
                 $pcal['color'] = $user->calendar_colour;
                 $data['pcals'][] = $pcal;
             }
         } else {
             $data['pcals'] = array();
         }
         if (!count($socs)) {
             $soc = strtolower($user->individual->household->society->society);
             return redirect()->action('SocietiesController@show', $soc);
         } else {
             return view('home', $data);
         }
     } elseif ($user) {
         return view('shared.registered');
     } else {
         return view('landingwebpage');
     }
 }
Example #5
0
 public function feed()
 {
     $feed = Feed::make();
     // cache the feed for 60 minutes (second parameter is optional)
     $feed->setCache(0, 'NorthCoastCaresFeed');
     // check if there is cached feed and build new only if is not
     if (!$feed->isCached()) {
         // creating rss feed with our most recent 20 posts
         $organisations = Organisation::orderBy('created_at', 'desc')->take(20)->get();
         $projects = Project::orderBy('created_at', 'desc')->take(20)->get();
         // set your feed's title, description, link, pubdate and language
         $feed->title = 'North Coast Cares';
         $feed->description = 'Community and faith-based organisations working for good on the KZN North Coast';
         $feed->logo = 'https://scontent-cdg2-1.xx.fbcdn.net/hphotos-xta1/v/t1.0-9/12144733_644650369011345_1628028338195896677_n.png?oh=8ec9cc8612020671b85bc1fe338c7213&oe=56C020F3';
         $feed->link = url('feed');
         $feed->setDateFormat('datetime');
         // 'datetime', 'timestamp' or 'carbon'
         $feed->pubdate = date('d-m-Y');
         $feed->lang = 'en';
         $feed->setShortening(true);
         // true or false
         $feed->setTextLimit(400);
         // maximum length of description text
         foreach ($organisations as $organisation) {
             // set item's title, author, url, pubdate, description and content
             if ($organisation->photo != "") {
                 $fulldescrip = "<img height=\"60\" src=\"" . url($organisation->photo) . "\">" . $organisation->description;
             } else {
                 $fulldescrip = $organisation->description;
             }
             $feed->add("New " . strtoupper($organisation->organisationtype) . ": " . $organisation->organisation, "North Coast Cares", url('/organisations/' . $organisation->id), $organisation->created_at, $fulldescrip, $organisation->description);
         }
         foreach ($projects as $project) {
             // set item's title, author, url, pubdate, description and content
             if ($project->photo != "") {
                 $fulldescrip = "<img height=\"60\" src=\"" . url($project->photo) . "\">" . $project->description;
             } else {
                 $fulldescrip = $project->description;
             }
             $feed->add("New PROJECT: " . $project->project, "North Coast Cares", url('/projects/' . $project->id), $project->created_at, $fulldescrip, $project->description);
         }
     }
     // first param is the feed format
     // optional: second param is cache duration (value of 0 turns off caching)
     // optional: you can set custom cache key with 3rd param as string
     return $feed->render('atom');
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $projects = Project::orderBy('created_at', 'desc')->get();
     return view('frontend.projects.index', compact('projects'));
 }
Example #7
0
 function getGroupModal(Group $group)
 {
     $data['group'] = $group;
     $data['assistants'] = [0 => ''];
     $users = User::isAssistant()->orderBy('lastname')->get();
     foreach ($users as $user) {
         $data['assistants'][$user->id] = $user->name;
     }
     $data['projects'] = [0 => 'Onbekend'] + Project::orderBy('name')->pluck('name', 'id')->all();
     return $this->modal('Groep bewerken', 'modals.group', $data);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     return Project::orderBy('created_at', 'desc')->limit(6)->get();
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $lists = Project::orderBy('created_at', 'desc')->get();
     return response()->json($lists);
 }
Example #10
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $data['fin'] = Helpers::mapme('project');
     $data['projects'] = Project::orderBy('project')->get();
     return view('projects.index', $data);
 }
function retrieveProject()
{
    $results = array();
    $queries = \App\models\Project::orderBy('id', 'desc')->get();
    foreach ($queries as $query) {
        $results[] = ['id' => $query->id, 'value' => $query->title, 'class' => $query->client_id];
    }
    return json_encode($results);
}