public function training($id) { $year = 2016; $subscription = Subscription::with('watched')->find($id); foreach ($subscription->watched as $item) { if (!($course = $this->trainingRepository->findById($item->item_id, $subscription, $year))) { continue; } if (isset($course['question'])) { $course['id'] = $item->item_id; } $title = $this->makeTitle($course); if (isset($course['type']) && $course['type'] == 'quiz') { if (isset($course['questions'])) { continue; } } $item->setAttribute('title', $title); } $watched = new Collection($subscription->watched->toArray()); $watched = $watched->sortBy('title'); return view('admin.training')->with('watched', $watched)->with('name', $subscription->name); }
Route::any('news/sync', function (NewsSync $news) { return $news->sync(); }); Route::any('cities', function () { return State::where('code', 'RJ')->first()->cities()->orderBy('name')->get(); }); Route::any('schools/{city}', ['middleware' => 'cors', function ($city) { $city = mb_strtoclean($city); return School::where('city', '~*', strtoupper($city))->orderBy('name')->get(); }]); Route::get('download/{file}', ['as' => 'download', 'uses' => function ($file) { $path = env('LOCAL_BASE_DIR') . DIRECTORY_SEPARATOR . env('BASE_DIR') . DIRECTORY_SEPARATOR . env('SITE_DIR') . DIRECTORY_SEPARATOR; return response()->download(public_path($path) . $file); }]); Route::any('dados', function ($city) { $all = Subscription::all(); foreach ($all as $person) { } }); Route::group(['prefix' => 'admin/2016'], function () { Route::get('/', ['as' => 'admin.home', 'uses' => function () { return redirect()->route('admin.subscriptions'); }]); Route::get('subscriptions', ['as' => 'admin.subscriptions', 'uses' => 'Admin@index']); Route::get('schools', ['as' => 'admin.schools', 'uses' => 'Admin@schools']); Route::get('elected', ['as' => 'admin.elected', 'uses' => 'Admin@elected']); Route::get('{city}', ['as' => 'admin.city', 'uses' => 'Admin@city']); Route::get('training/{subscription}', ['as' => 'admin.training', 'uses' => 'Admin@training']); }); Route::get('auth.logout', ['as' => 'auth.logout', 'uses' => function () { return view('admin.index');
public function update($id) { $subscription = Subscription::find($id); $subscription->update(Input::only($subscription->getFillable())); $subscription->save(); return redirect()->route('admin.city', ['city' => $subscription->city]); }
public function login($registration, $birthdate) { $person = Subscription::where(\DB::raw("trim(both ' ' from registration)"), trim($registration))->where(\DB::raw("trim(both ' ' from birthdate)"), trim($birthdate))->first(); Session::put('logged-user', $person); return $person; }
public function createSubscription($input) { $model = new Subscription(); $input = $input->only($model->getFillable()); if ($subscription = $model->where('cpf', $input['cpf'])->where('registration', $input['registration'])->first()) { throw new AlreadySubscribed(); } $subscription = Subscription::firstOrCreate($input); event(new SubscriptionWasCreated($subscription)); return $subscription; }