Пример #1
0
 public static function store(array $seance)
 {
     $seance = array_only($seance, array('id', 'movieId', 'cinemaId', 'date', 'time', 'startTime'));
     $seance['movie_id'] = $seance['movieId'];
     unset($seance['movieId']);
     $seance['cinema_id'] = $seance['cinemaId'];
     unset($seance['cinemaId']);
     $seance['start_time'] = $seance['startTime'];
     unset($seance['startTime']);
     if (Seances::find($seance['id']) == null) {
         $seances = Seances::updateOrCreate($seance);
     }
     // $seances->save();
 }
Пример #2
0
 public function getList(Request $request, $id = null)
 {
     if ($id != null) {
         $s = Seances::find($id);
         $c = Cinemas::find($s->cinema_id);
         $city_id = $c->city_id;
     } else {
         $city_id = $request->input('city_id');
     }
     $users = new User();
     if ($request->input('gender')) {
         $users = $users->where("gender", '=', $request->input('gender'));
     }
     if ($request->input('city_id') != 0) {
         $users = $users->where("city_id", '=', $city_id);
     }
     if ($request->input('age_from') != 0) {
         $users = $users->where(DB::raw("TIMESTAMPDIFF(YEAR,birth_date,CURDATE())"), '>=', $request->input('age_from'));
     }
     if ($request->input('age_to') != 0) {
         $users = $users->where(DB::raw("TIMESTAMPDIFF(YEAR,birth_date,CURDATE())"), '<=', $request->input('age_to'));
     }
     $users = $users->where("status", "enable");
     $users = $users->where("id", '<>', $request->user()->id);
     $users = $users->get();
     $cities = Cities::orderBy('city')->get();
     $cityList = [];
     $cityList[0] = 'Любой';
     foreach ($cities as $key => $value) {
         $cityList[$value->id] = $value->city;
     }
     foreach ($users as $key => $user) {
         if ($user->ava != 'noava.jpeg') {
             $img = $user->ava;
             $users[$key]->ava = '/upload/' . $img;
         } else {
             $users[$key]->ava = '/images/noava.jpeg';
         }
         $age = Helper::ageCalculator($user->birth_date);
         $users[$key]->age = $age == null ? " " : $age;
         if ($user->city_id != '0') {
             $users[$key]->city = Cities::find($user->city_id)->city;
         } else {
             $users[$key]->city = " ";
         }
     }
     return view()->make('search.user_filter', array('users' => $users, 'cityList' => $cityList, 'city_id' => $city_id, 'age_from' => $request->input('age_from') ? $request->input('age_from') : 0, 'age_to' => $request->input('age_to') ? $request->input('age_to') : 0, 'gender' => $request->input('gender'), 'id' => $id));
 }
Пример #3
0
 public static function getMessage(Request $request)
 {
     $name = User::find($request->input('user_id'))->name;
     $my_name = $request->user()->name;
     $seance = Seances::find($request->input('seance'));
     $movie = Movies::find($seance->movie_id)->title;
     $cinema = Cinemas::find($seance->cinema_id)->title;
     $date = $seance->date;
     $time = $seance->time;
     $msg = [];
     $msg[0] = "Привет, " . $name . "! \n\r" . "Приглашаю тебя пойти со мной в кино на фильм \"" . $movie . "\" в кинотеатр " . $cinema . ". \n\r" . "Сеанс, на который предлагаю пойти: " . $date . " в " . $time . ". \n\r" . "Очень надеюсь на твой ответ, \n\r" . $my_name . ".";
     $msg[1] = "Доброго времени суток, " . $name . "! \n\r" . "Приглашаю Вас посетить кинотеатр " . $cinema . " и посмотреть фильм \"" . $movie . "\".\n\r" . "Сеанс, на который предлагаю пойти: " . $date . " в " . $time . ". \n\r" . "С нетерпением жду Вашего ответа, \n\r" . $my_name . ".";
     $fixnum = rand(0, 1);
     $array = array('message' => $msg[$fixnum], 'seance_id' => $request->input('seance'));
     return response()->json($array);
 }