本文整理汇总了PHP中Schedule::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Schedule::findOrFail方法的具体用法?PHP Schedule::findOrFail怎么用?PHP Schedule::findOrFail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Schedule
的用法示例。
在下文中一共展示了Schedule::findOrFail方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showEditTask
/**
* Generate the view for editing a task specified by $id.
*
* @param int $id
* @return view editTaskView
*/
public function showEditTask($id)
{
$schedule = Schedule::findOrFail($id);
$entries = $schedule->getEntries()->with('getJobType')->GetResults();
$jobtypes = Jobtype::where('jbtyp_is_archived', '=', '0')->orderBy('jbtyp_title', 'ASC')->get();
return View::make('editTaskView', compact('schedule', 'jobtypes', 'entries'));
}
示例2: update
/**
* Update the specified schedule in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
$schedule = Schedule::findOrFail($id);
$validator = Validator::make($data = Input::all(), Schedule::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
$schedule->update($data);
return Redirect::route('schedules.index');
}
示例3: countStatisticsById
/**
* Calculates the sum of all shifts in a given period for a given person id.
*
* @return int $subjectTotal
*/
public function countStatisticsById($id, $from, $till)
{
// get all events for the month, currently jan15 for testing
$events = ClubEvent::where('evnt_date_start', '>', $from)->where('evnt_date_start', '<', $till)->get();
$subject = Person::find($id);
$subjectTotal = 0;
foreach ($events as $event) {
// for each event - get its schedule
$schedule = Schedule::findOrFail($event->getSchedule->id);
// for each schedule - get its entries that have this person's id
$entries = ScheduleEntry::where('schdl_id', '=', $schedule->id)->where('prsn_id', '=', $subject->id)->get();
// for each entry - get its job type weight
foreach ($entries as $entry) {
$weight = $entry->getJobType->jbtyp_statistical_weight;
//and add it to subject's total
$subjectTotal += $weight;
}
}
return $subjectTotal;
}
示例4: deleteData
/**
* Delete Schedule
*
* @return bool
*/
public function deleteData($schedule_id)
{
$validator = Validator::make(array('schedule_id' => $schedule_id), array('schedule_id' => array('required')));
// Validation did not pass
if ($validator->fails()) {
throw new Exception($validator->messages());
}
try {
$schedule = Schedule::findOrFail($schedule_id);
$schedule->delete();
return true;
} catch (Exception $ex) {
return $ex;
}
}
示例5: onUpdate
/**
* Updates schedule entries of a specific schedule.
*
* If a password is needed, check it's correct and throw an error to the session if it's not,
* update all entries in bulk otherwise.
*
* @param int $id
*
* @return RedirectResponse
*/
private function onUpdate($id)
{
$schedule = Schedule::findOrFail($id);
$entries = ScheduleEntry::where('schdl_id', '=', $id)->get();
// Check if that schedule needs a password
if ($schedule->schdl_password !== '') {
//get password for specific id here, similar to enty->id
if (!Hash::check(Input::get('password'), $schedule->schdl_password)) {
Session::put('message', Config::get('messages_de.schedule-pw-needed'));
Session::put('msgType', 'danger');
return Redirect::back();
}
}
foreach ($entries as $entry) {
// Remember old value for logging
$oldPerson = $entry->getPerson;
// Entry was empty
if (!isset($entry->prsn_id)) {
// Entry is not empty now
if (!Input::get('userName' . $entry->id) == '') {
// Add new entry data
$this->onAdd($entry);
// log revision
ScheduleController::logRevision($entry->getSchedule, $entry, "Dienst eingetragen", $oldPerson, $entry->getPerson()->first());
// new value
}
// Otherwise no change found - do nothing
} else {
// Same person there?
if ($entry->getPerson->prsn_name == Input::get('userName' . $entry->id) and Person::where('id', '=', $entry->prsn_id)->first()->prsn_ldap_id == Input::get('ldapId' . $entry->id)) {
// Was comment updated?
if ($entry->entry_user_comment != Input::get('comment' . $entry->id)) {
$entry->entry_user_comment = Input::get('comment' . $entry->id);
}
// Otherwise no change found - do nothing
} else {
// Was entry deleted?
if (Input::get('userName' . $entry->id) == '') {
$this->onDelete($entry);
// log revision
ScheduleController::logRevision($entry->getSchedule, $entry, "Dienst ausgetragen", $oldPerson, $entry->getPerson()->first());
// new value
} else {
// delete old data
$this->onDelete($entry);
// add new data
$this->onAdd($entry);
// log revision
ScheduleController::logRevision($entry->getSchedule, $entry, "Dienst geändert", $oldPerson, $entry->getPerson()->first());
// new value
}
}
}
}
}
示例6: showId
/**
* Generates the view for a specific event, including the schedule.
*
* @param int $id
* @return view ClubEventView
* @return ClubEvent $clubEvent
* @return ScheduleEntry[] $entries
* @return RedirectResponse
*/
public function showId($id)
{
$clubEvent = ClubEvent::with('getPlace')->findOrFail($id);
if (!Session::has('userId') and $clubEvent->evnt_is_private == 1) {
Session::put('message', Config::get('messages_de.access-denied'));
Session::put('msgType', 'danger');
return Redirect::action('MonthController@showMonth', array('year' => date('Y'), 'month' => date('m')));
}
$schedule = Schedule::findOrFail($clubEvent->getSchedule->id);
$entries = ScheduleEntry::where('schdl_id', '=', $schedule->id)->with('getJobType', 'getPerson', 'getPerson.getClub')->get();
$clubs = Club::orderBy('clb_title')->lists('clb_title', 'id');
$persons = Cache::remember('personsForDropDown', 10, function () {
$timeSpan = new DateTime("now");
$timeSpan = $timeSpan->sub(DateInterval::createFromDateString('3 months'));
return Person::whereRaw("prsn_ldap_id IS NOT NULL AND (prsn_status IN ('aktiv', 'kandidat') OR updated_at>='" . $timeSpan->format('Y-m-d H:i:s') . "')")->orderBy('clb_id')->orderBy('prsn_name')->get();
});
$revisions = json_decode($clubEvent->getSchedule->entry_revisions, true);
if (!is_null($revisions)) {
// deleting ip adresses from output for privacy reasons
foreach ($revisions as $entry) {
unset($entry["from ip"]);
}
}
return View::make('clubEventView', compact('clubEvent', 'entries', 'clubs', 'persons', 'revisions'));
}