/**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     //
     $member = Member::find($id);
     $member->delete();
     return \Redirect::to('admin.member.index');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($memberId, $pointId)
 {
     $point = Point::find($pointId);
     $member = Member::find($memberId);
     $member->update(['total_points' => $member->total_points - $point->point]);
     $point->Delete('set null');
     return redirect()->action('MembersController@show', $memberId);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index($id)
 {
     if ($id != null || intval($id) > 0) {
         $user = Member::find(intval($id));
         $payment = Payment::filterByServiceAndMember(1, $user->id)->first();
         //membership
         $journal = Journal::where('payment_id', $payment->id);
         return view('backend.memberships.payment', compact('user', 'payment', 'journal'));
     }
 }
 public function update(Request $request, $id)
 {
     $member = Member::find($id);
     $medicalrecord = MedicalRecord::firstOrCreate(['member_id' => $member->id]);
     $medicalrecord->fill($request->all());
     $medicalrecord->member()->associate($member);
     $medicalrecord->save();
     Flash::success("<b>¡Se ha actualizado la ficha medica de " . $member->first_name . " de manera exitosa!</b>");
     return redirect()->route('admin.member.show', $member->id);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     if (urlRequest::has('setstatus')) {
         $setStatus = (int) urlRequest::get('setstatus');
         $member = Member::find($id);
         $member->status = $setStatus;
         $member->save();
         return redirect()->back();
     }
 }
 public function verify($id, \Illuminate\Http\Request $request)
 {
     $user_status = "inactive";
     $key = explode('-', $id);
     $member = Member::find($key[0]);
     if ($member->hash_key == $key[1]) {
         $member->status = 1;
         $member->save();
         $user_status = "active";
     }
     return view('emails.verify', compact('user_status'));
 }
 public function index()
 {
     foreach (Member::all() as $item) {
         sleep(2);
         // ip-api.com ban any IP addresses doing over 150 requests per minute
         $json = json_decode(file_get_contents("http://ip-api.com/json/{$item->ip}"));
         $item->city = $json->city;
         $item->country = $json->country;
         $member = Member::find($item->id);
         $member->city = $item->city;
         $member->country = $item->country;
         $member->save();
     }
     return "Ready";
 }
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     //This id is passed by the controller that calls the request class
     $member = Member::find($this->id);
     switch ($this->method()) {
         case 'GET':
         case 'DELETE':
             return [];
         case 'POST':
             return ['name' => 'required|unique:members,name', 'position' => 'required', 'order' => 'numeric', 'image' => 'required|image|mimes:jpeg,bmp,png|max:1500'];
         case 'PUT':
         case 'PATCH':
             return ['name' => 'required|unique:members,name,' . $member->id, 'position' => 'required', 'order' => 'numeric', 'image' => 'image|mimes:jpeg,bmp,png|max:1500'];
         default:
             break;
     }
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create($member_id)
 {
     $memberships = Membership::all()->lists('description', 'id');
     $membershipsAll = Membership::all();
     $member = Member::find($member_id);
     $rangeArray = array();
     $rangeDates = \App\Affiliation::orderBy('finalization', 'DEC')->where('member_id', $member_id)->where('finalization', '>=', Carbon::now())->get();
     foreach ($rangeDates as $range) {
         $initiationRange = new Carbon($range->initiation);
         $finalizationRange = new Carbon($range->finalization);
         $diference = $initiationRange->diffInDays($finalizationRange);
         for ($i = 0; $i <= $diference; $i++) {
             array_unshift($rangeArray, "'" . $initiationRange->copy()->format('Y-m-d') . "'");
             $initiationRange->addDay();
         }
     }
     return view('affiliation.create')->with('memberships', $memberships)->with('membershipsAll', $membershipsAll)->with('member', $member)->with('affiliationRange', $rangeArray);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $member = Member::find($id);
     $user = Auth::user();
     $isMemberProfile = false;
     $isFollowing = false;
     if (Auth::check()) {
         if ($member->user_id == Auth::User()->id) {
             $isMemberProfile = true;
         }
         if (Follow::where('artist_id', $member->id)->where('user_id', $user->id)->count()) {
             $isFollowing = true;
         }
     }
     //if not an image url from facebook
     if (filter_var($member->user->avatar, FILTER_VALIDATE_URL) === FALSE) {
         $member->user->avatar = url('uploads/images/thumbnail/' . $member->user->avatar);
     }
     return view('pages.artist', ['artist' => $member, 'isArtistProfile' => $isMemberProfile, 'isFollowing' => $isFollowing]);
 }
Beispiel #11
0
 public function loadResources()
 {
     $resources = DB::table('events_resources')->where('event_id', $this->id)->get();
     foreach ($resources as $resource) {
         if ($resource->member_id >= 1) {
             if ($member = Member::find($resource->member_id)) {
                 $resource->member = $member->first_name . " " . $member->last_name;
             } else {
                 $resource->member = "Desconocido";
             }
         } else {
             $resource->member = "Ninguno";
         }
         $joinResource = Resource::find($resource->resource_id);
         if ($joinResource) {
             $resource->type = $joinResource->type;
         } else {
             $resource->type = "Desconocido";
         }
     }
     $this->resources = $resources;
 }
 public function store(Request $request)
 {
     $anthropometricm = new AnthropometricMeasurement($request->all());
     $leftanthropometric = new LeftAnthropometric($request->all());
     $rightanthropometric = new RightAnthropometric($request->all());
     if ($anthropometricm->height == 0) {
         $imc = 0;
     } else {
         $imc = $anthropometricm->weight / ($anthropometricm->height / 100 * ($anthropometricm->height / 100));
     }
     $anthropometricm->imc = $imc;
     //$anthropometricm->save();
     $member = Member::find($request->member_id);
     $leftanthropometric->save();
     $rightanthropometric->save();
     $anthropometricm->leftAnthropometric()->associate($leftanthropometric);
     $anthropometricm->rightAnthropometric()->associate($rightanthropometric);
     $anthropometricm->member()->associate($member);
     $anthropometricm->save();
     Flash::success("¡ Se ha registrado la ficha antropometrica de " . $member->first_name . " exitosamente !");
     return redirect()->route('admin.member.show', $member->id);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, MemberRequest $request)
 {
     $member = Member::find($id);
     $oldOrder = $member->order;
     $newOrder = $request->input('order');
     $type = $request->input('type');
     /* 
     Laravel can not handle using the request manager the validation
     of the size image that exceeds the configuration of php.in
     */
     if ($this->imageHelper->fileImageSizeExceeded($request->file('image'))) {
         //Set the message and the error class
         Session::flash('message', 'The file image can not be greater than 2MB!');
         Session::flash('alert-class', 'alert-danger');
         return redirect()->back();
     }
     //Fill this member with the new form information
     $member->fill($request->all());
     //Getting the max permitted position
     $maxPosition = Member::where('type', $type)->count();
     //If the admin informed a greater position, set the position as the maximum one
     if ($member->order > $maxPosition) {
         $member->order = $maxPosition;
         $newOrder = $maxPosition;
     }
     //Setting the right order
     $this->imageHelper->adjustUpdateOrder($type, $oldOrder, $newOrder, $member);
     //Checking if there was uploaded a image
     if ($request->file('image') != null) {
         //Delete the old member image from the filesystem
         File::delete($member->path);
         //Moves and sets the new uploaded image
         $this->imageHelper->uploadImage($request, $member);
     }
     $member->save();
     //Sending the user to the accounts page
     return redirect()->route('member/index');
 }
Beispiel #14
0
 /**
  * Upload Tattoo
  *
  * @return View
  */
 public function uploadTattoo(Request $request)
 {
     $user = Auth::user();
     if ($request->hasFile('tattoo')) {
         //upload an image to the /img/tmp directory and return the filepath.
         //dd($request);
         $file = $request->file('tattoo');
         $tmpFilePath = '/uploads/images/original/';
         $tmpFileName = 'tattoo-' . time() . '-' . $file->getClientOriginalName();
         //save original file
         $file = $file->move(public_path() . $tmpFilePath, $tmpFileName);
         $path = $tmpFilePath . $tmpFileName;
         //edit image
         $img = \Image::make($file);
         // $img->backup();
         // reset image (return to backup state)
         // $img->reset();
         $img->fit(360);
         //240*240
         $img->save('uploads/images/thumbnail/' . $tmpFileName);
         // reset image (return to backup state)
         // $img->reset();
         $img->fit(120);
         //100*100
         $img->save('uploads/images/small/' . $tmpFileName, 40);
         $img->destroy();
         //save tattoo in DB
         $tattoo = new Tattoo();
         $tattoo->title = $request->input('title');
         $tattoo->url = $tmpFileName;
         $tattoo->description = $request->input('description');
         $tattoo->user_id = $user->id;
         $tattoo->approved = false;
         if ($request->input('type') == 'member') {
             $member = Member::find($request->input('id'));
             if ($user->id == $member->user->id) {
                 $tattoo->approved = false;
                 //member - self tattoos ll never be approved for public place, only visible to member page(always, no approval needed)
                 $tattoo->save();
             }
             return redirect('profile')->with('success', "Successfully uploaded!");
         } elseif ($request->input('type') == 'artist') {
             $artist = Artist::find($request->input('id'));
             //if uploaded by self
             if ($artist->user->id == $user->id) {
                 $tattoo->approved = true;
             }
             $artist->tattoos()->save($tattoo);
             return redirect('artist/' . $artist->user->slug)->with('success', "Successfully uploaded!");
         } elseif ($request->input('type') == 'studio') {
             $studio = Studio::find($request->input('id'));
             //if uploaded by self
             if ($studio->user->id == $user->id) {
                 $tattoo->approved = true;
             }
             $studio->tattoos()->save($tattoo);
             return redirect('studio/' . $studio->user->slug)->with('success', "Successfully uploaded!");
         } else {
             session()->flash('error', "Error in uploading tattoo!! Please try again..");
         }
     } else {
         session()->flash('error', "Please select a file!!");
     }
     return redirect('/');
 }
 public function addMember(Request $request, $eventId)
 {
     if (!Auth::check()) {
         return response()->json($this->notLoginJson, 401);
     } else {
         $user = Auth::user();
         if (!$user->hasRole('admin')) {
             return response()->json($this->needPermissionsJson, 401);
         }
     }
     $memberId = $request->input('member_id');
     $event = Event::find($eventId);
     if ($event) {
         $member = $event->members()->where('member_id', $memberId)->count();
         if ($member > 0) {
             return response()->json(['message' => 'Miembro ya registrado'], 400);
         } else {
             $event->members()->attach($memberId);
             $member = Member::find($memberId);
             return response()->json($member);
         }
     } else {
         return response()->json($this->eventNotFoundJson, 404);
     }
 }
 public function destroy($id)
 {
     $member = Member::find($id);
     $member->delete();
     return redirect('member');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function timecard($id)
 {
     $member = Member::find($id);
     if (NULL == $member) {
         return response()->json("", 404);
     } else {
         $devices = Visit::where('memberID', $id)->select('deviceID')->groupBy('deviceID')->get();
         $times = array();
         foreach ($devices as $did) {
             $total_hrs = 0;
             $visits = Visit::where('memberID', $id)->where('deviceID', $did->deviceID)->select('checkIn', 'checkOut')->get();
             foreach ($visits as $visit) {
                 if ($visit->checkOut != NULL) {
                     $date_time_in = strtotime($visit->checkIn);
                     $date_time_out = strtotime($visit->checkOut);
                     $total_hrs += round(abs($date_time_out - $date_time_in) / 3600, 2);
                 }
             }
             array_push($times, ['checkInDevice' => $did->deviceID, 'totalTime' => $total_hrs, 'visits' => $visits]);
         }
         $member->times = $times;
         return response()->json($member, 200);
     }
 }
Beispiel #18
0
 public function SaveProject(Request $request)
 {
     $project = new Project();
     $project->fill($request->except('_token', 'submitBtn'));
     $project->save();
     $member = Member::find($request->get('member_id'));
     if ($request->get('submitBtn') == 'save') {
         return redirect()->route('thank.you');
     }
     return back()->withMember($member)->withMessage('project saved');
 }
 /**
  * return a small box that is green or red if the shop is open or clsoed
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function isOpenWidget($did)
 {
     $device = CheckInDevice::find($did);
     if (NULL == $device) {
         return response()->json("", 404);
     } else {
         $open = false;
         $actives = Visit::where('deviceID', $did)->where('checkOut', NULL)->select('memberID')->get();
         foreach ($actives as $visit) {
             $member = Member::find($visit->memberID);
             if (NULL != $member) {
                 if (true == $member->hasKeys) {
                     $open = true;
                     break;
                 }
             }
         }
         return response()->view('isOpenWidget', ['isopen' => $open]);
     }
 }
 public function DelTeam($id, $id_team)
 {
     $db = Team::find($id_team);
     $db->status = 0;
     $db->save();
     $now = date('Y-m-d');
     foreach ($db->tl as $tl) {
         $db_tl = Teamleader::find($tl->id);
         $db_tl->status = 0;
         $db_tl->end = $now;
         $db_tl->save();
     }
     foreach ($db->store as $store) {
         $db_st = Store::find($store->id);
         $db_st->status = 0;
         $db_st->save();
         foreach ($store->members as $gm) {
             $db_gm = Member::find($gm->id);
             $db_gm->status = 0;
             $db_gm->end = $now;
             $db_gm->save();
             foreach ($gm->get_users as $gu) {
                 if ($gm->status == 1) {
                     $db_em = Employee::find($gu->id);
                     $db_em->status = 0;
                     $db_em->save();
                 }
             }
         }
     }
     Alert::success('Berhasil menonaktifkan !')->persistent("Close");
     return redirect('project/view/' . $id)->with('message', 'Stop Team Success!');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     //
     $member = Member::find($id);
     $member->delete();
     // redirect
     $members = Member::all();
     session()->flash('flash_message', 'Member deleted successfully!');
     return redirect()->back();
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     if (urlRequest::has('setstatus')) {
         $setStatus = (int) urlRequest::get('setstatus');
         $member = Member::find($id);
         $member->status = $setStatus;
         $member->save();
         return redirect()->back();
     }
     $data = $this->member->whereId((int) $id)->with('person.contacts', 'person.files', 'person.education')->first();
     return view('admin.show', compact('data'));
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($mid, $id)
 {
     //
     $member = Member::find($mid);
     if (NULL == $member) {
         return response()->json("", 404);
     } else {
         $device = MemberDevice::find($id);
         if (NULL == $device) {
             return response()->json("", 404);
         } else {
             $device->delete();
             $member->load('devices', 'subgroups');
             return response()->json($member, 200);
         }
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($memberId, $pointId)
 {
     $tambay_point = TambayPoint::find($pointId);
     $member = Member::find($memberId);
     $member->update(['total_points' => $member->total_points - $tambay_point->point]);
     $tambay_point->Delete('set null');
     return redirect()->action('TambayPointsController@index');
 }
Beispiel #25
0
 public function destroy($id)
 {
     $member = Member::find($id);
     $member->delete();
     Flash::error("¡El miembro " . $member->first_name . " fue eliminado de manera exitosa!");
     return redirect()->route('admin.member.index');
 }
 public function DelTeam($id, $id_team)
 {
     // Start Check Authorization
     /**
      * 1. FullAccess - 1
      * 2. HRD - 3
      * 3. Creator - 5
      * 4. Handler - 7
      */
     $invalid_auth = 1;
     $authRole = Auth::user()->UserRoles->role;
     if ($authRole == 7 or $authRole == 1 or $authRole == 3) {
         $invalid_auth = 0;
     }
     if ($invalid_auth == 1) {
         Alert::error('Anda tidak memilik akses ini')->persistent('close');
         return redirect('project/view/' . $id);
     }
     // End Check Authorization
     $db = Team::find($id_team);
     $db->status = 0;
     $db->save();
     $now = date('Y-m-d');
     foreach ($db->tl as $tl) {
         $db_tl = Teamleader::find($tl->id);
         $db_tl->status = 0;
         $db_tl->end = $now;
         $db_tl->save();
     }
     foreach ($db->store as $store) {
         $db_st = Store::find($store->id);
         $db_st->status = 0;
         $db_st->save();
         foreach ($store->members as $gm) {
             $db_gm = Member::find($gm->id);
             $db_gm->status = 0;
             $db_gm->end = $now;
             $db_gm->save();
             foreach ($gm->get_users as $gu) {
                 if ($gm->status == 1) {
                     $db_em = Employee::find($gu->id);
                     $db_em->status = 0;
                     $db_em->save();
                 }
             }
         }
     }
     Alert::success('Berhasil menonaktifkan !')->persistent("Close");
     return redirect('project/view/' . $id)->with('message', 'Stop Team Success!');
 }
 public function insertQuery(Request $request)
 {
     $type = $request->input('type');
     $tag = $request->input('tags');
     $id = $request->input('id');
     $mode = $request->input('mode');
     ////////////////////////////////////
     //mode = 0 edit , mode = 1 insert///
     ////////////////////////////////////
     if ($type == 'events') {
         $validator = Validator::make($request->all(), ['title' => 'required', 'address' => 'required', 'body' => 'required', 'tags' => 'required|array']);
         if ($validator->fails()) {
             return redirect()->back()->withErrors($validator)->withInput()->with(array('errorcode' => 'events', 'tags' => $this->returnTags()));
         } else {
             if ($mode == 1) {
                 $event = new Event();
                 $content = new Content();
             } else {
                 $event = Event::find($id);
                 $content = $event->content;
             }
             $content->title = $request->input('title');
             $event->address = $request->input('address');
             $content->body = $request->input('body');
             $content->type = $type;
             $content->save();
             $start = $request->input('start-day') . "|" . $request->input('start-month') . "|" . $request->input('start-year') . "|" . $request->input('start-hour') . ":" . $request->input('start-minute');
             $end = $request->input('end-day') . "|" . $request->input('end-month') . "|" . $request->input('end-year') . "|" . $request->input('end-hour') . ":" . $request->input('end-minute');
             $event->start = $start;
             $event->end = $end;
             $event->highlight = $request->input('highlight') == NULL ? 0 : 1;
             $files = $request->file('img');
             foreach ($files as $file) {
                 if ($file->isValid()) {
                     $photo = new Photo();
                     $tempName = $file->getClientOriginalName();
                     $extension = explode(".", $tempName);
                     $name = $extension[0] . "-" . time() . "." . $extension[1];
                     $destination = 'upload';
                     $file->move($destination, $name);
                     $photo->path = $destination . "/" . $name;
                     $content->photos()->save($photo);
                 }
             }
             if (!empty($tag)) {
                 foreach ($tag as $insertTag) {
                     $row = Tag::where('title', '=', $insertTag)->first();
                     $content->tags()->save($row);
                 }
             }
             $cat = Category::where('title', '=', $request->input('category'))->first();
             if ($cat != null) {
                 $content->categories()->attach($cat->id);
             }
             $content->event()->save($event);
             return redirect('admin');
         }
     } elseif ($type == 'members') {
         $validator = Validator::make($request->all(), ['firstname' => 'required', 'lastname' => 'required', 'email' => 'required']);
         if ($validator->fails()) {
             return redirect()->back()->withErrors($validator)->withInput()->with(array('errorcode' => 'members', 'tags' => $this->returnTags()));
         } else {
             if ($mode == 1) {
                 $member = new Member();
             } else {
                 $member = Member::find($id);
             }
             $member->firstname = $request->input('firstname');
             $member->lastname = $request->input('lastname');
             $member->email = $request->input('email');
             //$member->password = $request->input('password');
             $member->researchareas = $request->input('researchareas') == NULL ? NULL : $request->input('researchareas');
             $member->industrialareas = $request->input('intery') == NULL ? NULL : $request->input('industry');
             $member->tel = $request->input('telephone') == NULL ? NULL : $request->input('telephone');
             $member->mobile = $request->input('mobile') == NULL ? NULL : $request->input('mobile');
             $member->position = $request->input('position') == NULL ? NULL : $request->input('position');
             $member->googleplus = $request->input('googleplus') == NULL ? NULL : $request->input('pinterest');
             $member->facebook = $request->input('facebook') == NULL ? NULL : $request->input('facebook');
             $member->twitter = $request->input('twitter') == NULL ? NULL : $request->input('instagram');
             $member->linkedin = $request->input('linkedin') == NULL ? NULL : $request->input('linkedin');
             if ($request->hasFile('img')) {
                 $file = $request->file('img');
                 if ($file->isValid()) {
                     $photo = new Photo();
                     $tempName = $file->getClientOriginalName();
                     $extension = explode(".", $tempName);
                     $name = $extension[0] . "-" . time() . "." . $extension[1];
                     $destination = 'upload';
                     $file->move($destination, $name);
                     //$photo->title = $request->input('photoTitle');
                     $photo->path = $destination . "/" . $name;
                     Photo::where("member_id", $member->id)->delete();
                     $member->photo()->save($photo);
                 }
             }
             if ($request->hasFile('cv')) {
                 $file = $request->file('cv');
                 if ($file->isValid()) {
                     $tempName = $file->getClientOriginalName();
                     $extension = explode(".", $tempName);
                     $name = $extension[0] . "-" . time() . "." . $extension[count($extension) - 1];
                     $destination = 'upload';
                     $file->move($destination, $name);
                     $member->cv = $destination . "/" . $name;
                 }
             }
             $member->save();
             if ($mode == 0) {
                 $record = Member::find($id)->records;
                 foreach ($record as $rec) {
                     $rec->delete();
                 }
             }
             $recordArray = $request->input('rec');
             if (!empty($recordArray)) {
                 foreach ($recordArray as $key) {
                     if (empty($key['delete'])) {
                         $key['delete'] = 'off';
                     }
                     if ($key['delete'] != "on" && $key['institute'] != "") {
                         $record = new Record();
                         $record->institute = $key['institute'];
                         $record->position = $key['position'];
                         $record->start = $key['start'];
                         $record->end = $key['end'];
                         $record->type = $key['type'];
                         $member->records()->save($record);
                     }
                 }
             }
             // $cat = Category::where('title', '=', $request->input('category'))->first();
             return redirect('admin');
         }
     } elseif ($type == 'researches') {
         $validator = Validator::make($request->all(), ['author' => 'required', 'title' => 'required', 'abstract' => 'required']);
         if ($validator->fails()) {
             return redirect()->back()->withErrors($validator)->withInput()->with(array('errorcode' => 'researches', 'tags' => $this->returnTags()));
         } else {
             if ($mode == 1) {
                 $research = new Research();
                 $content = new Content();
             } else {
                 $research = Research::find($id);
                 $content = $research->content;
             }
             $content->title = $request->input('title');
             $content->body = $request->input('abstract');
             $content->type = $type;
             $content->save();
             $research->author = $request->input('author');
             $research->publisher = $request->input('publisher') == NULL ? NULL : $request->input('publisher');
             $date = $request->input('date-year') . "|" . $request->input('date-month') . "|" . $request->input('date-day') . "|" . $request->input('date-hour') . ":" . $request->input('date-minute');
             $research->date = $date;
             $research->external = $request->input("external") == NULL ? true : false;
             $research->pages = $request->input('pages') == NULL ? NULL : $request->input('pages');
             //                $research->abstract = $request->input('abstract') == NULL ? NULL : $request->input('abstract');
             $research->keywords = $request->input('keywords') == NULL ? NULL : $request->input('keywords');
             $research->link = $request->input('link') == NULL ? NULL : $request->input('link');
             $path = $request->file('path');
             if (!empty($path) && $path->isValid()) {
                 $tempName = $path->getClientOriginalName();
                 $extension = explode(".", $tempName);
                 $name = $extension[0] . time() . "." . $extension[count($extension) - 1];
                 $destination = 'upload';
                 $path->move($destination, $name);
                 $research->path = $destination . "/" . $name;
             }
             if (!empty($tag)) {
                 foreach ($tag as $insertTag) {
                     $row = Tag::where('title', '=', $insertTag)->first();
                     $content->tags()->save($row);
                 }
             }
             $research->content()->associate($content);
             $research->save();
             $cat = Category::where('title', '=', $request->input('category'))->first();
             if ($cat != null) {
                 $content->categories()->attach($cat->id);
             }
             return redirect('admin');
         }
     } elseif ($type == 'galleries') {
         $validator = Validator::make($request->all(), ['title' => 'required', 'body' => 'required']);
         if ($validator->fails()) {
             return redirect()->back()->withErrors($validator)->withInput()->with(array('errorcode' => 'galleries', 'tags' => $this->returnTags()));
         } else {
             if ($mode == 1) {
                 $content = new Content();
             } else {
                 $content = Content::find($id);
             }
             $content->title = $request->input('title');
             $content->body = $request->input('body');
             $content->type = $type;
             $content->save();
             if ($request->hasFile('img')) {
                 $file = $request->file('img');
                 for ($i = 0; $i < count($file); $i++) {
                     if ($file[$i]->isValid()) {
                         $photo = new Photo();
                         $tempName = $file[$i]->getClientOriginalName();
                         $extension = explode(".", $tempName);
                         $name = $extension[0] . "-" . time() . (string) $i . "." . $extension[count($extension) - 1];
                         $destination = 'upload';
                         $file[$i]->move($destination, $name);
                         $photo->title = $request->input('imgtitle')[$i];
                         $photo->path = $destination . "/" . $name;
                         $photo->highlight = $request->input("highlight")[$i] == "true" ? 1 : 0;
                         $content->photos()->save($photo);
                     }
                 }
             }
             if ($mode != 1) {
                 if (!empty($request->input('oldimg'))) {
                     foreach ($request->input('oldimg') as $img) {
                         if (empty($img['delete'])) {
                             $img['delete'] = "off";
                             $image = Photo::find($img['id']);
                             $image->title = $img['title'];
                             $image->highlight = $img['highlight'] == "true" ? 1 : 0;
                             $image->save();
                         }
                         if ($img['delete'] == "on") {
                             $temp = Photo::find($img['id']);
                             $temp->delete();
                         }
                     }
                 }
             }
             if (!empty($tag)) {
                 foreach ($tag as $insertTag) {
                     $row = Tag::where('title', '=', $insertTag)->first();
                     $content->tags()->save($row);
                 }
             }
             $cat = Category::where('title', '=', $request->input('category'))->first();
             if ($cat != null) {
                 $content->categories()->attach($cat->id);
             }
             return redirect('admin');
         }
     } elseif ($type == 'tags') {
         $input = $request->all();
         $split = explode("#", $input['body']);
         for ($i = 0; $i < count($split); $i++) {
             if (!empty($split[$i]) && $split[$i] != '') {
                 $tag = new Tag();
                 $tag->title = trim($split[$i]);
                 $tag->save();
             }
         }
         return redirect('admin');
     } elseif ($type == 'categories') {
         $cat = new Category();
         $cat->title = $request->input("title");
         $cat->parent = $request->input("cat-id");
         if ($cat->parent == 0) {
             $cat->parent = null;
         }
         $cat->save();
         return redirect('admin');
     } elseif ($type == "variables") {
         $var = Variable::find($id);
         $var->title = $request->input("title");
         $var->subtitle = $request->input("subtitle");
         $var->body = $request->input("body");
         if ($request->hasFile('img')) {
             $file = $request->file('img');
             if ($file->isValid()) {
                 $tempName = $file->getClientOriginalName();
                 $extension = explode(".", $tempName);
                 $name = $extension[0] . "-" . time() . "." . $extension[count($extension) - 1];
                 $destination = 'upload';
                 $file->move($destination, $name);
                 //$photo->title = $request->input('photoTitle');
                 $var->body = $destination . "/" . $name;
             }
         }
         $var->save();
         return redirect('admin');
     } else {
         $validator = Validator::make($request->all(), ['title' => 'required', 'body' => 'required', 'tags' => 'required|array']);
         if ($validator->fails()) {
             return redirect()->back()->withErrors($validator)->withInput()->with(array('errorcode' => 'news', 'tags' => $this->returnTags()));
         } else {
             if ($mode == 1) {
                 $news = new Content();
             } else {
                 $news = Content::find($id);
             }
             $news->title = $request->input('title');
             $news->body = $request->input('body');
             $news->type = $type;
             $news->save();
             if ($request->hasFile('img')) {
                 $files = $request->file('img');
                 if ($mode == 0) {
                     $oldphoto = Photo::where("content_id", $id)->first();
                     $oldphoto->delete();
                 }
                 foreach ($files as $file) {
                     if ($file->isValid()) {
                         $photo = new Photo();
                         $tempName = $file->getClientOriginalName();
                         $extension = explode(".", $tempName);
                         $name = $extension[0] . "-" . time() . "." . $extension[count($extension) - 1];
                         $destination = 'upload';
                         $file->move($destination, $name);
                         //$photo->title = $request->input('photoTitle');
                         $photo->path = $destination . "/" . $name;
                         $news->photos()->save($photo);
                     }
                 }
             }
             if (!empty($tag)) {
                 foreach ($tag as $insertTag) {
                     $row = Tag::where('title', '=', $insertTag)->first();
                     $news->tags()->save($row);
                 }
             }
             $cat = Category::find($request->input('cat-id'));
             if ($cat != null) {
                 $news->categories()->attach($cat->id);
             }
             return redirect('admin');
         }
     }
 }
 public function changePassword(Request $request)
 {
     $user = Login::where('remember_token', '=', $request->header('token'))->where('login_from', '=', $request->ip())->join('members', 'members.id', '=', 'logins.member_id')->where('logins.status', '=', '1')->first();
     if (Auth::attempt(['username' => $user->username, 'password' => $request['old']])) {
         $member = Member::find($user->member_id);
         $member->password = Hash::make($request['new']);
         //return $member->password;
         $member->save();
         $returnData = array('status' => 'ok', 'code' => 200);
         return Response::json($returnData, 200);
     } else {
         $returnData = array('status' => 'fail');
         return Response::json($returnData, 401);
     }
 }
Beispiel #29
0
 /**
  * Display the artist followers
  * @param  int  $id
  * @return Response
  */
 public function memberFollowers($id)
 {
     $member = Member::find($id);
     $followers = $member->user->followers;
     $isMemberProfile = false;
     if (Auth::check()) {
         if ($member->user_id == Auth::User()->id) {
             $isMemberProfile = true;
         }
     }
     return view('ajax.followers', ['followers' => $followers, 'isSelf' => $isMemberProfile, 'profile' => $member]);
 }
Beispiel #30
0
                        <td class="inbox-small-cells"><a href="#">
                                
                                
                                <i class="fa fa-star inbox-started"></i>
                            
                            
                            </a>
                            
                            
                            
                            &nbsp;&nbsp;&nbsp;
                        <?php 
$message_id = $inbox->message_id;
$sender = Author::find($message_id)->mail_author;
$fname = Member::find($sender)->first_name;
$lname = Member::find($sender)->last_name;
?>
                        {{$fname}}
                        
                        </td>
                        <td class="view-message  dont-show">{{$inbox->message->subject}}</td>
                        <td class="view-message ">{{HelperController::convertTimeWithAMPM($inbox->created_at)}}</td>
                        <td class="view-message  text-right">
                            <a data-toggle="modal" href="{{action('MailController@read',$inbox->message->id)}}" class="btn btn-sm btn-send">Read</a>   
                        </td>
                    </tr>