本文整理汇总了PHP中Group::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Group::findOrFail方法的具体用法?PHP Group::findOrFail怎么用?PHP Group::findOrFail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Group
的用法示例。
在下文中一共展示了Group::findOrFail方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateGroup
function updateGroup($id)
{
$app = Slim\Slim::getInstance();
$json = decodeJsonOrFail($app->request->getBody());
$group = Group::findOrFail($id);
$group->update($json);
echo $group->toJson();
}
示例2: update
/**
* Update the specified group in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
$group = Group::findOrFail($id);
$validator = Validator::make($data = Input::all(), Group::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
$group->update($data);
return Redirect::route('groups.index');
}
示例3: fire
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
$user = User::findOrFail($this->argument('username'));
$group = Group::findOrFail($this->argument('group'));
$moderator = new GroupModerator();
$moderator->group()->associate($group);
$moderator->user()->associate($user);
$moderator->type = $this->option('admin') ? 'admin' : 'moderator';
$moderator->save();
$this->info($user->name . ' is now moderator of ' . $group->urlname);
}
示例4: sendMessageToGroup
function sendMessageToGroup($id)
{
$app = Slim\Slim::getInstance();
$group = Group::findOrFail($id);
$json = decodeJsonOrFail($app->request->getBody());
if (!isset($json['from'])) {
$json['from'] = null;
}
if (!isset($json['from_user_id'])) {
$json['from_user_id'] = null;
}
$message = new Message($json);
$message->group()->associate($group);
$message->save();
echo $message->toJson();
}
示例5: getGroup
public function getGroup($group, $limit = 20, $page = 0)
{
if (!$this->auth) {
return $this->error('not authorized', 401);
}
if (!$this->user->isDev() or !$this->user->isHax() or !$this->user->isGroup($group)) {
return $this->error('not authorized', 401);
}
try {
$group = Group::findOrFail($group);
$limit = $limit > 50 ? 50 : $limit;
$offset = $page <= 0 ? 0 : $limit * $page;
$notifications = $group->notifications()->take($limit)->skip($offset);
return $this->response($notifications->get());
} catch (ModelNotFoundException $e) {
return $this->error('group not found', 404);
}
}
示例6: edit
public function edit($id)
{
$groupbyid = Group::findOrFail($id);
$groupbyid = ['groupbyid' => $groupbyid];
return View::make('group.edit', $groupbyid)->withTitle("Ubah Group");
}
示例7: destroygroup
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroygroup($id)
{
$group = Group::findOrFail($id);
$group->delete();
return Redirect::action('GroupController@index')->with('success', Lang::get('groups.delete_success'));
}
示例8: deleteAction
public function deleteAction()
{
try {
$form = new GroupForm();
if ($form->isValidForDelete()) {
$group = Group::findOrFail(Input::get("id"));
$group->delete();
}
//return Redirect::route("group/index");
} catch (\Illuminate\Database\QueryException $e) {
//001 Codigo error
}
return Redirect::route("group/index");
}
示例9: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
try {
$group = Group::findOrFail($id);
//prepare the meeting time for user friendly display
$meetingTime = substr($group->meeting_time, 0, 1) == '0' ? substr($group->meeting_time, 1, 1) : substr($group->meeting_time, 0, 2);
$group->meeting_time = $meetingTime . ':' . substr($group->meeting_time, -2, 2);
$nextMeeting = $this->determineNextMeetingDate($group);
if (Request::wantsJson()) {
return Response::json(['group' => $group, 'nextMeeting' => $nextMeeting->toFormattedDateString()]);
} else {
return View::make('groups.show')->with(['group' => $group, 'nextMeeting' => $nextMeeting->toFormattedDateString()]);
}
} catch (Exception $e) {
Log::error('Failed to find a specific record', array(404, "group: " . $group));
App::abort(404);
//this goes directly to the missing method in global.php
}
}
示例10: update
/**
* Update the specified member in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
$member = Member::findOrFail($id);
$validator = Validator::make($data = Input::all(), Member::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
if (Input::get('branch_id') != null) {
$branch = Branch::findOrFail(Input::get('branch_id'));
$member->branch()->associate($branch);
}
if (Input::get('group_id') != null) {
$group = Group::findOrFail(Input::get('group_id'));
$member->group()->associate($group);
}
//$member->photo = Input::get('photo');
//$member->signature = Input::get('signature');
if (Input::hasFile('photo')) {
$destination = public_path() . '/uploads/photos';
$filename = str_random(12);
$ext = Input::file('photo')->getClientOriginalExtension();
$photo = $filename . '.' . $ext;
Input::file('photo')->move($destination, $photo);
$member->photo = $photo;
}
if (Input::hasFile('signature')) {
$destination = public_path() . '/uploads/photos';
$filename = str_random(12);
$ext = Input::file('signature')->getClientOriginalExtension();
$photo = $filename . '.' . $ext;
Input::file('signature')->move($destination, $photo);
$member->signature = $photo;
}
$member->name = Input::get('name');
$member->id_number = Input::get('id_number');
$member->membership_no = Input::get('membership_no');
$member->phone = Input::get('phone');
$member->email = Input::get('email');
$member->address = Input::get('address');
$member->monthly_remittance_amount = Input::get('monthly_remittance_amount');
$member->gender = Input::get('gender');
$member->update();
return Redirect::route('members.index');
}
示例11: show
/**
* Display the specified resource.
*
* @param int $groupId
* @param int $id
* @return Response
*/
public function show($groupId, $id)
{
$score = Group::findOrFail($groupId)->scores()->findOrFail($id);
return response()->json($score);
}