예제 #1
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (Session::has('user_id')) {
         $session_user_id = Session::get('user_id');
         if ($request->user_id == $session_user_id) {
             $path = $request->path() . '?user_id=' . $request->user_id . '&day=' . $request->day;
             $requestlog = new RequestLog();
             $requestlog->PID = $session_user_id;
             $requestlog->request = $path;
             $requestlog->save();
             if ($request->day != Day::first()->pluck('day')) {
                 $data['status'] = 112;
                 $data['description'] = "You cannot request for a different day!";
                 return json_encode($data);
             } else {
                 return $next($request);
             }
         } else {
             $data['status'] = 110;
             $data['description'] = "Session mismatch!";
             return json_encode($data);
             return Day::first()->pluck('day');
         }
     } else {
         $data['status'] = 111;
         $data['description'] = 'Session not set!';
         return json_encode($data);
     }
 }
예제 #2
0
 public function getHome()
 {
     $dates = [];
     $recipes = Recipe::all();
     for ($i = 0; $i < 7; $i++) {
         array_push($dates, Carbon::now()->startOfWeek()->addDays($i));
     }
     $datas = Day::whereBetween('date', array($dates[0], end($dates)))->get();
     foreach ($dates as $key => $date) {
         if ($datas->whereLoose('date', $date)->first() != '') {
             $day = $datas->whereLoose('date', $date)->first();
         } else {
             $day = Day::create(['date' => $date]);
         }
         $dates[$key] = $day;
     }
     $ingredients_list = collect();
     foreach ($dates as $day) {
         foreach ($day->recipes as $recipe) {
             foreach ($recipe->ingredients as $ingredient) {
                 if ($ingredients_list->where('id', $ingredient->id)->first() && $ingredients_list->where('id', $ingredient->id)->first()->pivot->unit == $ingredient->pivot->unit) {
                     $ingredients_list->where('id', $ingredient->id)->first()->total += $ingredient->pivot->quantity;
                 } else {
                     $ingredients_list->push($ingredient);
                     $ingredients_list->where('id', $ingredient->id)->first()->total = $ingredient->pivot->quantity;
                 }
             }
         }
     }
     $supply = Auth::user()->ingredients;
     return view('page.home')->with(['days' => $dates, 'ingredients_list' => $ingredients_list, 'supply' => $supply]);
 }
예제 #3
0
 function save_instructor(Request $request)
 {
     $acam = Session::get('phaseterm');
     $instructor = $request->instructor;
     $class_id = $request->cl_id;
     // no point if the instructor = 0
     if ($instructor != 0) {
         $time = Time::getPeriod($class_id);
         $day = Day::getShortDay($class_id);
         $conflict = Api::checkInstructor($instructor, $time, $day);
         if ($conflict == false) {
             $class = Classallocation::find($class_id);
             $class->instructor = $instructor;
             $class->save();
             if ($request->ajax == 0) {
                 Session::flashdata('message', htmlAlert('Successfully Assigned', 'success'));
                 return back();
             }
         } else {
             if ($request->ajax == 0) {
                 Session::flashdata('message', htmlAlert('Conflict'));
                 return back();
             } else {
                 echo 'conflict';
             }
         }
     } else {
         if ($request->ajax == 0) {
             Session::flashdata('message', htmlAlert('Please Select a instructor'));
             return back();
         } else {
             echo 'no';
         }
     }
 }
예제 #4
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $store = Store::find($id);
     $days = Day::all();
     $brands = Brand::lists('brand_name', 'id')->all();
     $payment_types = PaymentType::lists('type_name', 'id')->all();
     return view('admin.stores.edit', compact('store', 'days', 'brands', 'payment_types'));
 }
 public function edit($id)
 {
     $data = [];
     $data['article'] = ArticleCategory::with('articles')->get();
     $data['content'] = \App\Doctor::find($id);
     $data['list_province'] = \App\Province::lists('name', 'id');
     $data['list_city'] = \App\City::lists('name', 'id');
     $data['list_specialization'] = \App\Specialization::lists('name', 'id');
     $data['days'] = \App\Day::lists('name', 'id');
     return view('frontend.pages.clinic.doctor-edit', compact('data'));
 }
예제 #6
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     \App\Day::truncate();
     \App\Day::create(['name' => 'Minggu']);
     \App\Day::create(['name' => 'Senin']);
     \App\Day::create(['name' => 'Selasa']);
     \App\Day::create(['name' => 'Rabu']);
     \App\Day::create(['name' => 'Kamis']);
     \App\Day::create(['name' => 'Jumat']);
     \App\Day::create(['name' => 'Sabtu']);
 }
예제 #7
0
 public function postAutoAssign(Request $request)
 {
     // Weekend booths only = 1
     // if this is a weekend booth, can assign to everyone
     // if this is a weekday booth, can only assign to troops with 0
     $isWeekend = Day::find($request->date)->weekend;
     $brownies = User::getTroops('Brownie', $isWeekend)->toArray();
     $juniors = User::getTroops('Junior', $isWeekend)->toArray();
     $cadettes = User::getTroops('Cadette', $isWeekend)->toArray();
     $seniors = User::getTroops('Senior', $isWeekend)->toArray();
     $ambassadors = User::getTroops('Ambassador', $isWeekend)->toArray();
     $all = array_merge($brownies, $juniors, $cadettes, $seniors, $ambassadors);
     $nonCsa = array_merge($brownies, $juniors);
     $csa = array_merge($cadettes, $seniors, $ambassadors);
     if ($isWeekend) {
         $booths = Booth::getBooths($request->date, '', $isWeekend);
         if ($booths->count()) {
             shuffle($all);
             foreach ($booths as $key => $booth) {
                 $booth = Booth::find($booth['id']);
                 $id = array_rand($all);
                 $troop = $all[$id];
                 $booth->user_id = $troop['id'];
                 $booth->save();
             }
         }
     } else {
         $earlyBooths = Booth::getBooths($request->date, true, $isWeekend);
         $lateBooths = Booth::getBooths($request->date, false, $isWeekend);
         if ($earlyBooths->count()) {
             shuffle($nonCsa);
             foreach ($earlyBooths as $key => $booth) {
                 $booth = Booth::find($booth['id']);
                 $id = array_rand($nonCsa);
                 $troop = $nonCsa[$id];
                 $booth->user_id = $troop['id'];
                 $booth->save();
             }
         }
         if ($lateBooths->count()) {
             shuffle($csa);
             foreach ($lateBooths as $key => $booth) {
                 $booth = Booth::find($booth['id']);
                 $id = array_rand($csa);
                 $troop = $csa[$id];
                 $booth->user_id = $troop['id'];
                 $booth->save();
             }
         }
     }
     return redirect('/admin/booths');
 }
예제 #8
0
파일: Room.php 프로젝트: Jheysoon/lcis-2
 function room($roomId)
 {
     $data['system'] = $this->system;
     $room = Classroom::findOrFail($roomId);
     $data['room_id'] = $roomId;
     $data['room_name'] = $room->legacycode;
     $data['location'] = $room->location;
     $data['days'] = Day::where('id', '!=', 8)->get();
     $data['times'] = Time::all();
     $schedCollection = new SchedCollection();
     $data['table_day'] = $schedCollection->getSchedRoom($roomId, $this->system);
     return view('edp.room_sched', $data);
 }
예제 #9
0
파일: Sched.php 프로젝트: Jheysoon/lcis-2
 public function show($id)
 {
     $inst = Party::find($id);
     if ($inst instanceof ModelNotFoundException) {
         return view('errors.404');
     }
     $data['instructor'] = $inst;
     $data['classes'] = Classallocation::where('academicterm', $this->system->phaseterm)->where('instructor', $id);
     $data['days'] = Day::where('id', '!=', 8)->get();
     $data['times'] = Time::all();
     $schedCollection = new SchedCollection();
     $data['table_day'] = $schedCollection->getSchedInstructor($id, $this->system);
     return view('instructor.sched', $data);
 }
예제 #10
0
 function add_day_period(Request $request, $id)
 {
     if ($request->has('day')) {
         $valid = $this->assign($request);
         if ($valid) {
             return redirect('add_day_period/' . $id);
         }
     } elseif ($request->has('submit')) {
         $this->error = htmlAlert('Please select a day');
     }
     $data['cid'] = $id;
     $data['error'] = $this->error;
     $data['cl'] = Classallocation::find($id);
     $data['days'] = Day::where('id', '!=', 8)->get();
     $data['times'] = Time::where('id', '!=', 12)->get();
     return view('dean.assigned_subj', $data);
 }
예제 #11
0
 public function search(Request $request)
 {
     $data = array();
     $data['days'] = \App\Day::lists('name', 'id');
     $data['article'] = ArticleCategory::with('articles')->get();
     $data['city'] = \App\City::all();
     $data['specialization'] = \App\Specialization::all();
     $data['city_k'] = urldecode($request->input('city'));
     $data['specialization_k'] = urldecode($request->input('specialization'));
     $data['keyword'] = urldecode($request->input('keyword'));
     $data['gender_k'] = $request->input('gender');
     $data['practice_day_k'] = $request->input('practice_day');
     $data['city_obj'] = \App\City::where('name', 'like', '%' . $data['city_k'] . '%')->lists('id');
     $arr_specialization = \App\Specialization::where('name', 'like', '%' . $data['specialization_k'] . '%')->lists('id');
     /*$result = \App\Specialization::where('name','like','%'.$data['specialization_k'].'%')
       ->whereHas('doctors', function($query) use($data){
           $query->whereIn('city_id', $data['city_obj'])
               ->where('name','like', '%'.$data['keyword'].'%')
               ->whereHas('day', function($query) use($data){
                 if(!empty($data['practice_day_k']) > 0)
                   $query->whereIn('days.id', $data['practice_day_k']);
               })
           ;
           if(!empty($data['gender_k'])){
             $query->where('gender',$data['gender_k']);
           }
       })->
       with('doctors')->get();*/
     $result = \App\Doctor::whereIn('city_id', $data['city_obj'])->where('name', 'like', '%' . $data['keyword'] . '%')->whereHas('day', function ($query) use($data) {
         if (!empty($data['practice_day_k']) > 0) {
             $query->whereIn('days.id', $data['practice_day_k']);
         }
     });
     if (!empty($data['gender_k'])) {
         $result->where('gender', $data['gender_k']);
     }
     $result = $result->paginate(10);
     $data['article'] = ArticleCategory::with('articles')->get();
     $data['content'] = $result;
     return view('frontend.pages.home.search-result', compact('data'));
 }
예제 #12
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(HomeFormRequest $request)
 {
     // SEARCH STUFF TO FIX. NEED TO REDIRECT TO ANOTHER PAGE AND SHOW RESULTS THERE. https://laracasts.com/lessons/search-essentials
     // $query = $request->get('q');
     // $articles = $query
     // ? Article::search($query)->get()
     // : Article::all();
     //LONGER WAY OF CODING
     // if ($query)
     // {
     //     $articles = Article::where('lat', 'LIKE', "%$query%")->get();
     // }
     // else
     // {
     //     $articles = Article::all();
     // }
     // $days = Day::lists('dayname', 'id');
     // $categories = Category::lists('name', 'id');
     // ADD ANY/ALL OPTION
     $days = array(8 => 'Any') + Day::lists('dayname', 'id')->toArray();
     $categories = array(4 => 'All') + Category::lists('name', 'id')->toArray();
     return view('home', compact('categories', 'days'));
 }
예제 #13
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $schedules = Schedule::find($id);
     $academicRegistrations = AcademicRegistration::lists('academic_year', 'id');
     $programStudies = ProgramStudy::lists('name', 'id');
     $courses = Course::lists('course_name', 'id');
     $studies = Study::lists('study_name', 'id');
     $lecturers = Lecturer::lists('name', 'id');
     $days = Day::lists('day', 'id');
     return view('dashboard.admin.schedule.edit', ['schedule' => $schedules, 'academicRegistration' => $academicRegistrations, 'programStudy' => $programStudies, 'course' => $courses, 'study' => $studies, 'lecturer' => $lecturers, 'day' => $days]);
 }
예제 #14
0
 public function get_day()
 {
     $current_day = Day::first();
     return $current_day->day;
 }
예제 #15
0
파일: Api.php 프로젝트: Jheysoon/lcis-2
 public static function checkInstructor($instructor, $time, $day)
 {
     $instructor_sched = Day_period::getInstructorsSched($instructor);
     $subject_time = explode(' / ', $time);
     $subject_day = explode(' / ', $day);
     foreach ($instructor_sched as $sched) {
         if (!in_array('TBA', $subject_day)) {
             $inst_day = Day::find($sched->day);
             if (!in_array($inst_day, $subject_day)) {
                 $from = Time::find($sched->from_time);
                 $to = Time::find($sched->to_time);
                 foreach ($subject_time as $key) {
                     $keys = explode('-', $key);
                     $isConflict = intersectCheck($from->time, $keys[0], $to->time, $keys[1]);
                     if ($isConflict) {
                         return true;
                     }
                 }
             }
         }
     }
     return false;
 }
예제 #16
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $days = Day::all();
     return view('dashboard.admin.day.index', ['day' => $days]);
 }
예제 #17
0
 public function generate()
 {
     $dates = [];
     $recipes = Recipe::all();
     for ($i = 0; $i < 7; $i++) {
         array_push($dates, Carbon::now()->startOfWeek()->addDays($i));
     }
     $datas = Day::whereBetween('date', array($dates[0], end($dates)))->get();
     foreach ($dates as $date) {
         if ($datas->whereLoose('date', $date)->first() != '') {
             $day = $datas->whereLoose('date', $date)->first();
             $day->recipes()->detach();
             $day->recipes()->attach($recipes->random()->id);
         } else {
             $day = Day::create(['date' => $date]);
             $day->recipes()->attach($recipes->random()->id);
         }
     }
     return redirect('/');
 }
예제 #18
0
use App\Http\Controllers\RoomsController;
use App\Http\Controllers\TimeslotsController;
use App\Room;
use App\Timeslot;
Route::model('room', 'App\\Room');
Route::get('/', function () {
    return view('welcome');
});
Route::get('/home', HomeController::class . '@index');
Route::get('/week', function () {
    return View::make('control-pages.week', ['rooms' => Room::all()]);
});
Route::resource('room', RoomsController::class);
Route::resource('timeslot', TimeslotsController::class);
Route::get('/api/week', function () {
    return ['Maandag' => Timeslot::where('day_id', '1')->orderBy('begin')->get(), 'Dinsdag' => Timeslot::where('day_id', '2')->orderBy('begin')->get(), 'Woensdag' => Timeslot::where('day_id', '3')->orderBy('begin')->get(), 'Donderdag' => Timeslot::where('day_id', '4')->orderBy('begin')->get(), 'Vrijdag' => Timeslot::where('day_id', '5')->orderBy('begin')->get(), 'Zaterdag' => Timeslot::where('day_id', '6')->orderBy('begin')->get(), 'Zondag' => Timeslot::where('day_id', '7')->orderBy('begin')->get()];
});
Route::get('/api/week/{room}', function (Room $room) {
    $days_list = \App\Day::all();
    $days = [];
    foreach ($days_list as $day) {
        $days[$day->day] = [];
    }
    foreach ($room->timeslots as $timeslot) {
        $days[$timeslot->day->day][] = $timeslot;
    }
    return $days;
});
Route::get('/api/rooms', function () {
    return \App\Room::with('timeslots')->get();
});
예제 #19
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $days = Day::find($id);
     $days->delete();
     Session::flash('message', 'You have successfully deleted day');
     return Redirect::to('dashboard/admin/days');
 }
예제 #20
0
 public function edit($id)
 {
     $article = Article::find($id);
     $deals = Deal::all()->lists('dealname', 'dayID');
     $categories = Category::lists('name', 'id');
     $days = Day::lists('dayname', 'id');
     return view('articles.edit', compact('article', 'categories', 'days', 'deals'));
 }
 /**
  * @param Requests\TimeslotRequest $request
  * @return \stdClass
  */
 public function getFormInput(Requests\TimeslotRequest $request)
 {
     $input = new \stdClass();
     $input->day = Day::find($request->get('day_id'));
     $input->begin = Carbon::createFromFormat('d-m-Y H:i:s', $request->get('begin'));
     $input->end = Carbon::createFromFormat('d-m-Y H:i:s', $request->get('end'));
     $roomIds = array_flatten($request->get('rooms'));
     $roomIds = array_map('intval', $roomIds);
     $input->rooms = Room::whereIn('id', $roomIds)->get();
     return $input;
 }
예제 #22
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     //
     $data = array();
     $data['content'] = \App\Doctor::find($id);
     $data['list_province'] = \App\Province::lists('name', 'id');
     $data['list_city'] = \App\City::lists('name', 'id');
     $data['list_specialization'] = \App\Specialization::lists('name', 'id');
     $data['days'] = \App\Day::lists('name', 'id');
     return view('pages.admin.doctor.edit')->with('data', $data);
 }
 public function getCustomerPoint($action, $id)
 {
     $city_options = \App\City::lists('name', 'id');
     $days_options = \App\Day::lists('name', 'id');
     $status_options = ['active' => 'Activo', 'inactive' => 'Inactivo'];
     $type_options = ['agency' => 'Agencia', 'branch' => 'Sucursal', 'atm' => 'Cajero'];
     $product_options = \App\Product::where('status', 'active')->whereIn('type', ['important_product', 'product'])->lists('name', 'id');
     return AdminItem::get_request('customer-point', $action, $id, $this, ['parent' => 'parent'], ['city_options' => $city_options, 'days_options' => $days_options, 'status_options' => $status_options, 'type_options' => $type_options, 'product_options' => $product_options]);
 }