public function store(Request $request)
 {
     $this->validate($request, ['tag' => 'required|max:80']);
     $interest = $request->all();
     Interest::create($interest);
     return redirect('admin/dashboard/interest');
 }
Beispiel #2
0
 public function interest()
 {
     DB::beginTransaction();
     Interest::create(['res' => Input::get('id'), 'wanderer' => Session::get(MateMiddleware::$VERIFY)]);
     DB::commit();
     return 'recorded';
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Interest::create(['name' => 'PHP']);
     Interest::create(['name' => 'Laravel']);
     Interest::create(['name' => 'Sass']);
     Interest::create(['name' => 'Ruby on Rails']);
 }
 public function edit($id)
 {
     try {
         $student = Student::findOrFail($id);
     } catch (Exception $e) {
         App::abort(404);
     }
     $interestsTable = Interest::all();
     $studentInterests = (string) $student->interests;
     $studentData = array('student' => $student, 'interestsTable' => $interestsTable, 'studentInterests' => $studentInterests);
     //dd($strInterests);
     return view('students.edit', $studentData);
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function checkprofile()
 {
     $mecanex_user = Auth::user()->mecanex_user;
     $terms = Term::all();
     $interests = Interest::all();
     $listterms = [];
     $listscores = [];
     foreach ($interests as $interest) {
         array_push($listterms, $interest->interest);
     }
     foreach ($terms as $term) {
         $temp_user = $mecanex_user->profilescore->find($term->id);
         $user_term_score = $temp_user->pivot->profile_score;
         array_push($listscores, $user_term_score);
     }
     $userprofile = array_combine($listterms, $listscores);
     return view('user.checkprofile', compact('userprofile'));
 }
Beispiel #6
0
 /**
  * Create a new user using register page.
  *
  */
 public function createRegister()
 {
     $countries = Country::all();
     $interests = Interest::all();
     return view('index', compact('countries', 'interests'));
 }
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     $user = User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
     $profile = Profile::create(['user_id' => $user->id, 'name' => $data['name'], 'surname' => $data['surname'], 'gender' => $data['gender'], 'birth_date' => $data['birth_year'] . '-' . $data['birth_month'] . '-' . $data['birth_day'], 'location' => $data['location'], 'interested_in' => $data['interested_in'], 'description' => $data['bio']]);
     if (isset($data['interest'])) {
         foreach ($data['interest'] as $interest) {
             $interest = Interest::firstOrCreate(['name' => $interest]);
             $profile->interests()->attach($interest->id);
         }
     }
     if (isset($data['profile_photo'])) {
         $image = Image::create(['profile_id' => $profile->id, 'photo_url' => $data['profile_photo']]);
         $profile->profile_photo_id = $image->id;
         $profile->save();
     }
     return $user;
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(InterestRequest $request, $username)
 {
     $interests = $request->except('_method');
     $user = MecanexUser::where('username', $username)->get()->first();
     if (empty($user)) {
         $response = ["error" => "User doesn`t exist"];
         $statusCode = 404;
     } elseif (count($user->interest) == 0) {
         $response = ["message" => "User has not set any interests, To create interests, try store"];
         $statusCode = 404;
     } else {
         //check if what sends is correct or else it crushes
         //updates interests and user scores
         $key_values = array();
         foreach ($interests as $key => $value) {
             $interest = Interest::where('short_name', $key)->get(array('id'))->first();
             $key_values[$interest->id] = $value;
             $user->interest()->sync([$interest->id => ['interest_score' => $value]], false);
             $term = Term::where('term', $key)->firstOrFail();
             $value = $value / 5;
             $user->term()->sync([$term->id => ['user_score' => $value]], false);
         }
         //there must be a more clever way to do this (foreach maybe)
         //created 2 arrays one with the term ids ($term_ids) and the other with the scores ($term_scores)
         $terms = Term::get(array('id'));
         $all_terms = [];
         foreach ($terms as $term) {
             array_push($all_terms, $term->id);
         }
         $all_terms_length = count($all_terms);
         ksort($key_values);
         $term_ids = array_keys($key_values);
         $term_ids_length = count($term_ids);
         //update adjacency matrix
         for ($i = 0; $i <= $term_ids_length - 1; $i++) {
             for ($j = 0; $j <= $all_terms_length - 1; $j++) {
                 if ($term_ids[$i] == $all_terms[$j]) {
                     continue;
                 } elseif ($term_ids[$i] > $all_terms[$j]) {
                     $temp_user_matrix = MecanexUserTermHomeTermNeighbour::where('mecanex_user_id', $user->id)->where('term_home_id', $all_terms[$j])->where('term_neighbor_id', $term_ids[$i])->get()->first();
                     $temp_user = $user->term->find($all_terms[$j]);
                     $user_term_score_a = $temp_user->pivot->user_score;
                     $temp_user = $user->term->find($term_ids[$i]);
                     $user_term_score_b = $temp_user->pivot->user_score;
                     $new_score = $user_term_score_b * $user_term_score_a;
                     //						}
                 } else {
                     $temp_user_matrix = MecanexUserTermHomeTermNeighbour::where('mecanex_user_id', $user->id)->where('term_home_id', $term_ids[$i])->where('term_neighbor_id', $all_terms[$j])->get()->first();
                     $temp_user = $user->term->find($all_terms[$j]);
                     $user_term_score_a = $temp_user->pivot->user_score;
                     $temp_user = $user->term->find($term_ids[$i]);
                     $user_term_score_b = $temp_user->pivot->user_score;
                     $new_score = $user_term_score_b * $user_term_score_a;
                 }
                 $temp_user_matrix->link_score = $new_score;
                 $temp_user_matrix->save();
             }
         }
         //update profile
         for ($j = 1; $j <= $all_terms_length; $j++) {
             $profile_score = 0;
             for ($i = 1; $i <= $all_terms_length; $i++) {
                 $temp_user = $user->term->find($i);
                 $user_term_score = $temp_user->pivot->user_score;
                 //get score of user
                 if ($i == $j) {
                     $link_score = 0;
                 } elseif ($i > $j) {
                     $temp_user_matrix = MecanexUserTermHomeTermNeighbour::where('mecanex_user_id', $user->id)->where('term_home_id', $j)->where('term_neighbor_id', $i)->get()->first();
                     $link_score = $temp_user_matrix->link_score;
                 } else {
                     $temp_user_matrix = MecanexUserTermHomeTermNeighbour::where('mecanex_user_id', $user->id)->where('term_home_id', $i)->where('term_neighbor_id', $j)->get()->first();
                     $link_score = $temp_user_matrix->link_score;
                 }
                 $profile_score = $profile_score + $user_term_score * $link_score;
             }
             $user->profilescore()->sync([$j => ['profile_score' => $profile_score]], false);
         }
         $response = ["message" => "User Interests were saved"];
         $statusCode = 201;
     }
     return response($response, $statusCode)->header('Content-Type', 'application/json');
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     //authorization
     if (!$this->adminAuth() && !$this->userAuth(Auth::User()->id)) {
         return view('errors.404');
     }
     $interests = Interest::all();
     $countries = Country::all();
     $user = Generalinfo::where('user_id', $id)->get();
     $userinterest = UserInterest::where('user_id', $id)->get()->toArray();
     $userinterest = array_pluck($userinterest, 'interest_id');
     $this->data['userinterest'] = $userinterest;
     // $data['userinterest']= $userinterest
     return view('generalinfos.edit', compact('user', 'interests', 'countries'), $this->data);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     //
     $interestId = Request::get('id');
     Interest::where('id', $interestId)->delete();
     return redirect("interests");
 }
Beispiel #11
0
 public function getInterestsOptions()
 {
     return Interest::lists('name', 'id')->toArray();
 }
Beispiel #12
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $data = Interest::paginate(10);
     return $data;
 }
Beispiel #13
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $data = Interest::all();
     return view('account.interest.index', compact('data'));
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     //authorization
     if (!$this->adminAuth() && !$this->userAuth(Auth::User()->id)) {
         return view('errors.404');
     }
     $interests = Interest::all();
     $countries = Country::all();
     $user = Generalinfo::where('user_id', $id)->get();
     $userinterest = UserInterest::where('user_id', $id)->get();
     return view('generalinfos.edit', compact('user', 'interests', 'countries', 'userinterest'));
 }
 /**
  * Show the form for editing the specified Prospects.
  * @param  int $id
  * @return Response
  */
 public function edit($id)
 {
     $prospects = $this->prospectsRepository->find($id);
     if (empty($prospects)) {
         Flash::error('Prospects not found');
         return redirect(route('prospects.index'));
     }
     $users = \DB::table('users')->lists('email', 'id');
     $gyms = \DB::table('gyms')->lists('nomefantasia', 'id');
     $cities = \DB::table('cities')->lists('city', 'id');
     $states = \DB::table('states')->lists('state', 'id');
     $countries = \DB::table('countries')->lists('country', 'id');
     $hearabouts = \DB::table('hearabouts')->lists('hearabout', 'id');
     $visittypes = \DB::table('visittypes')->lists('type', 'id');
     $contactstatus = \DB::table('contactstatus')->lists('status', 'id');
     $contactsteps = \DB::table('contactsteps')->lists('step', 'id');
     $consultores = \DB::table('users')->lists('email', 'id');
     $maritalstats = \DB::table('maritalstats')->lists('stat', 'id');
     $interests = \App\Interest::all();
     $interestb = \DB::table('interest_prospect')->where('prospect_id', $id)->get(['interest_id']);
     return view('prospects.edit')->with('prospects', $prospects)->with('users', $users)->with('gyms', $gyms)->with('cities', $cities)->with('states', $states)->with('countries', $countries)->with('hearabouts', $hearabouts)->with('visittypes', $visittypes)->with('contactstatus', $contactstatus)->with('contactsteps', $contactsteps)->with('consultores', $consultores)->with('maritalstats', $maritalstats)->with('interests', $interests)->with('interestb', $interestb);
 }
Beispiel #16
0
 public function run()
 {
     DB::table('interests')->delete();
     Interest::create(['id' => '1', 'interest' => 'Arts and culture', 'short_name' => 'arts']);
     Interest::create(['id' => '2', 'interest' => 'Disasters', 'short_name' => 'disasters']);
     Interest::create(['id' => '3', 'interest' => 'Education', 'short_name' => 'education']);
     Interest::create(['id' => '4', 'interest' => 'Environment and nature', 'short_name' => 'environment']);
     Interest::create(['id' => '5', 'interest' => 'Health', 'short_name' => 'health']);
     Interest::create(['id' => '6', 'interest' => 'Lifestyle and consumerism', 'short_name' => 'lifestyle']);
     Interest::create(['id' => '7', 'interest' => 'The Media', 'short_name' => 'media']);
     Interest::create(['id' => '8', 'interest' => 'National holidays, festivals, anniversaries, annual events', 'short_name' => 'holidays']);
     Interest::create(['id' => '9', 'interest' => 'Politics and economics', 'short_name' => 'politics']);
     Interest::create(['id' => '10', 'interest' => 'Religion and belief', 'short_name' => 'religion']);
     Interest::create(['id' => '11', 'interest' => 'Society and social issues', 'short_name' => 'society']);
     Interest::create(['id' => '12', 'interest' => 'Transportation, science and technology', 'short_name' => 'transportation']);
     Interest::create(['id' => '13', 'interest' => 'Wars and conflict', 'short_name' => 'wars']);
     Interest::create(['id' => '14', 'interest' => 'Work and production', 'short_name' => 'work']);
 }
 private function syncTags(Interest $interest, array $tags)
 {
     $interest->tags()->sync($tags);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $mecanex_user = Auth::user()->mecanex_user;
     //get the input
     $arts = $request->arts;
     $disasters = $request->disasters;
     $education = $request->education;
     $environment = $request->environment;
     $health = $request->health;
     $lifestyle = $request->lifestyle;
     $media = $request->media;
     $holidays = $request->holidays;
     $politics = $request->politics;
     $religion = $request->religion;
     $society = $request->society;
     $transportation = $request->transportation;
     $wars = $request->wars;
     $work = $request->work;
     $mecanex_user->interest()->sync([1 => ['interest_score' => $arts], 2 => ['interest_score' => $disasters], 3 => ['interest_score' => $education], 4 => ['interest_score' => $environment], 5 => ['interest_score' => $health], 6 => ['interest_score' => $lifestyle], 7 => ['interest_score' => $media], 8 => ['interest_score' => $holidays], 9 => ['interest_score' => $politics], 10 => ['interest_score' => $religion], 11 => ['interest_score' => $society], 12 => ['interest_score' => $transportation], 13 => ['interest_score' => $wars], 14 => ['interest_score' => $work]]);
     //initialize user profile - update table users_terms_scores
     //for every interest sort_name find the id of the profile terms
     $interests = Interest::all();
     $user_interests = $mecanex_user->interest;
     $term_ids = [];
     foreach ($user_interests as $user_interest) {
         $short_name = $user_interest->short_name;
         array_push($term_ids, $user_interest->id);
         $term = Term::where('term', $short_name)->firstOrFail();
         $mecanex_user->term()->sync([$term->id => ['user_score' => $user_interest->pivot->interest_score / 5]], false);
         //normalization
     }
     $terms = Term::all()->count();
     for ($i = 0; $i <= $terms - 1; $i++) {
         for ($j = $i + 1; $j <= $terms - 1; $j++) {
             $temp_user_matrix = MecanexUserTermHomeTermNeighbour::where('mecanex_user_id', $mecanex_user->id)->where('term_home_id', $term_ids[$i])->where('term_neighbor_id', $term_ids[$j])->get()->first();
             $temp_user = $mecanex_user->term->find($term_ids[$i]);
             $user_term_score_a = $temp_user->pivot->user_score;
             $temp_user = $mecanex_user->term->find($term_ids[$j]);
             $user_term_score_b = $temp_user->pivot->user_score;
             $new_score = $user_term_score_a * $user_term_score_b;
             $temp_user_matrix->link_score = $new_score;
             $temp_user_matrix->save();
         }
     }
     for ($j = 1; $j <= $terms; $j++) {
         $profile_score = 0;
         for ($i = 1; $i <= $terms; $i++) {
             $temp_user = $mecanex_user->term->find($i);
             $user_term_score = $temp_user->pivot->user_score;
             //get score of user
             if ($i == $j) {
                 $link_score = 0;
             } elseif ($i > $j) {
                 $temp_user_matrix = MecanexUserTermHomeTermNeighbour::where('mecanex_user_id', $mecanex_user->id)->where('term_home_id', $j)->where('term_neighbor_id', $i)->get()->first();
                 $link_score = $temp_user_matrix->link_score;
             } else {
                 $temp_user_matrix = MecanexUserTermHomeTermNeighbour::where('mecanex_user_id', $mecanex_user->id)->where('term_home_id', $i)->where('term_neighbor_id', $j)->get()->first();
                 $link_score = $temp_user_matrix->link_score;
             }
             $profile_score = $profile_score + $user_term_score * $link_score;
         }
         $mecanex_user->profilescore()->sync([$j => ['profile_score' => $profile_score]], false);
     }
     return Redirect::route('interest.edit');
 }
 public function postInterest(Request $request)
 {
     $user = $request->user();
     $interest = new Interest();
     $interest->user_id = $user->id;
     $interest->property_id = $request->property_id;
     $interest->is_confirmed = FALSE;
     $interest->save();
     return redirect('properties/search');
 }