Example #1
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $data['user'] = User::find($id);
     $data['users_menu'] = 1;
     $data['staff'] = Staff::select(\DB::raw('concat (fname," ",lname) as full_name, id'))->lists('full_name', 'id');
     $data['roles'] = Role::noncoder()->lists('name', 'id');
     //get the id(s) of the roles of this user in an array
     $roles = array();
     foreach ($data['user']->roles as $value) {
         $roles[] = $value->id;
     }
     $data['user_roles'] = $roles;
     $data['permissions'] = [];
     return view('settings.users.modal_edit_user', $data);
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     //
     $post = Post::findOrFail($id);
     //Populate the select(dropdowns)
     //$department_options = Department::lists('name', 'id');
     //$department_id = $post->department_id;
     $department_options = Department::lists('name', 'id');
     $department_selected = $post->departments->lists('id');
     //$project_options = Project::lists('name', 'id');
     //$project_id = $post->project_id;
     $source_options = Source::lists('name', 'id');
     $source_selected = $post->sources->lists('id');
     $staff_options = Staff::select('Id', DB::raw('CONCAT(first_name, " ", last_name) AS full_name'))->orderBy('first_name')->lists('full_name', 'Id');
     $staff_selected = $post->staffs->lists('id');
     // Show the page
     return view('posts.forms.edit', compact('post', 'department_options', 'department_selected', 'source_options', 'source_selected', 'staff_options', 'staff_selected'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function postCategory(Request $request)
 {
     Input::flash();
     $detail = Input::get('detail');
     $staff_options = Staff::select('Id', DB::raw('CONCAT(first_name, " ", last_name) AS full_name'))->orderBy('first_name')->lists('full_name', 'Id')->toArray();
     $posts = Post::with(array('departments' => function ($query) {
         $query->addSelect(array('name'));
     }))->with(array('staffs' => function ($query) {
         $query->addSelect(array(DB::raw("concat(staff.first_name, ' ', staff.last_name) as `name`")));
     }));
     if (Input::has('media_mention')) {
         $posts = $posts->mediamention();
     }
     if (Input::has('presentation')) {
         $posts = $posts->presentation();
     }
     if (Input::has('meeting')) {
         $posts = $posts->meeting();
     }
     if (Input::has('testimonial')) {
         $posts = $posts->testimonial();
     }
     if (Input::has('sponsored_event')) {
         $posts = $posts->sponsoredevent();
     }
     if (Input::has('on_campus_collaboration')) {
         $posts = $posts->orWhere('on_campus_collaboration', 1);
     }
     if (Input::has('off_campus_collaboration')) {
         $posts = $posts->offcampuscollaboration();
     }
     if (Input::has('achievement')) {
         $posts = $posts->achievement();
     }
     if (Input::has('satifaction_survey')) {
         $posts = $posts->satifactionsurvey();
     }
     if (Input::has('other')) {
         $posts = $posts->orWhere('other', 1);
     }
     if (Input::has('staff')) {
         if (Input::get('staff') != 0) {
             $posts = $posts->whereHas('staffs', function ($query) {
                 $query->where('id', '=', Input::get('staff'));
             });
         }
     }
     if (Input::has('publish_date_from') || Input::has('publish_date_to')) {
         $from = date('Y-m-d', strtotime(Input::get('publish_date_from')));
         if (Input::has('publish_date_to')) {
             $to = date('Y-m-d', strtotime(Input::get('publish_date_to')));
         } else {
             $to = date('Y-m-d', strtotime(Carbon::now()));
         }
         $posts = $posts->whereBetween('publish_date', array($from, $to));
     }
     $posts = $posts->get();
     //dd($posts);
     /*$posts = $posts->with(['departments' => function($query) {
     		    $query->select('name');
     		}])->get();*/
     // I do this mapping to flatten the nested arrays
     //    			$posts = array_map(function($val)
     //    			    {
     //    			      return array_dot($val);
     //    			    }, $posts);
     $action = Input::get('action', 'none');
     if ($action == 'query') {
         return view('posts.report_category', compact('posts', 'staff_options', 'detail'))->withInput(Input::all());
     } else {
         if ($action == 'excel') {
             if ($detail == 1) {
                 Excel::create('Export', function ($excel) use($posts) {
                     $excel->sheet('Data', function ($sheet) use($posts) {
                         //$sheet->fromArray($posts);
                         $sheet->loadView('posts.category_full')->with('posts', $posts);
                     });
                 })->export('xls');
             } else {
                 Excel::create('Export', function ($excel) use($posts) {
                     $excel->sheet('Data', function ($sheet) use($posts) {
                         //$sheet->fromArray($posts);
                         $sheet->loadView('posts.category')->with('posts', $posts);
                     });
                 })->export('xls');
             }
         }
     }
     /*
         			Excel::create('posts', function($excel) use($posts) {
         			    $excel->sheet('Category', function($sheet) use($posts) {
         			        $sheet->fromArray($posts);
         			    });
         			})->export('xls');
     */
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $data['title'] = 'Edit Class';
     $data['classes_menu'] = 1;
     $data['staffs'] = Staff::select(\DB::raw('concat (fname," ",lname) as full_name, id'))->where('staff_type_id', 1)->lists('full_name', 'id')->prepend('Please Select');
     $data['subjects'] = Subject::lists('subject', 'id')->prepend('Please Select');
     $data['class'] = StudentClass::find($id);
     $data['staffs'] = Staff::select(\DB::raw('concat (fname," ",lname) as full_name, id'))->where('staff_type_id', 1)->lists('full_name', 'id');
     return view('settings.class.edit', $data);
 }