本文整理汇总了PHP中Input::json方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::json方法的具体用法?PHP Input::json怎么用?PHP Input::json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Input
的用法示例。
在下文中一共展示了Input::json方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
public function update($id)
{
//get the json from the request.
$updateModel = Input::json()->all();
//update the user model based on the json data sent.
$updateUser = User::find($id);
$updateUser->position_id = $updateModel['position_id'];
if (array_key_exists('phone', $updateModel)) {
$updateUser->phone = UsersApiController::getAllNumbers($updateModel['phone']);
} else {
$updateUser->phone = NULL;
}
$updateUser->schedule_color = $updateModel['schedule_color'];
$updateUser->acc_crud_assets = $updateModel['acc_crud_assets'];
$updateUser->acc_room = $updateModel['acc_room'];
$updateUser->acc_avlog = $updateModel['acc_avlog'];
$updateUser->acc_inv = $updateModel['acc_inv'];
$updateUser->acc_emp = $updateModel['acc_emp'];
$updateUser->acc_useradm = $updateModel['acc_useradm'];
$updateUser->acc_sysadm = $updateModel['acc_sysadm'];
$updateUser->acc_crud_timesheet = $updateModel['acc_crud_timesheet'];
$updateUser->acc_view_timesheet = $updateModel['acc_view_timesheet'];
$updateUser->acc_gen_timesheet = $updateModel['acc_gen_timesheet'];
$updateUser->acc_crud_schedule = $updateModel['acc_crud_schedule'];
$updateUser->acc_notifications = $updateModel['acc_notifications'];
$updateUser->acc_super_user = $updateModel['acc_super_user'];
//save the updated user to the database
$updateUser->save();
//send the response
return $updateUser->toJson();
}
示例2: action_update
public function action_update($id)
{
// RESTful update from Backbone
$officer = Officer::find($id);
$json = Input::json(true);
if (isset($json["command"])) {
if (Auth::officer()->is_role_or_higher(Officer::ROLE_SUPER_ADMIN) && !$officer->is_role_or_higher(Officer::ROLE_SUPER_ADMIN) && Auth::officer()->id != $officer->id) {
if ($json["command"] == "ban") {
$officer->ban();
}
if ($json["command"] == "unban") {
$officer->unban();
}
$officer->save();
$officer = Officer::find($id);
}
return Response::json($officer->to_array());
}
// We can update the officer's role if we are an Admin or a Super Admin.
// If we're a Super Admin, we can change the roles of other Super Admins.
// Super Admins can never modify their own role.
if (Auth::officer()->is_role_or_higher(Officer::ROLE_ADMIN)) {
if (isset($json["role"]) && ($officer->role != Officer::ROLE_SUPER_ADMIN || Auth::officer()->is_role_or_higher(Officer::ROLE_SUPER_ADMIN)) && ($officer->role != Officer::ROLE_SUPER_ADMIN || Auth::officer()->id != $officer->id)) {
$officer->role = $json["role"];
}
}
$officer->save();
return Response::json($officer->to_array());
}
示例3: action_update
public function action_update()
{
$deliverable = Config::get('deliverable');
$deliverable->fill(Input::json(true));
$deliverable->save();
return Response::json($deliverable->to_array());
}
示例4: sendMail
public function sendMail()
{
Mail::send('hello', array('mail_to' => Input::json('mail_to'), 'mail_subject' => Input::json('mail_subject')), function ($message) {
$message->to(Input::json('mail_to'), 'John Smith')->subject(Input::json('mail_subject'));
});
return Response::json(array('flash' => 'Mail Sent Successfully!!!!!'));
}
示例5: login
public function login()
{
try {
$user = Sentry::getUserProvider()->findByLogin(Input::json('email'));
$throttle = Sentry::getThrottleProvider()->findByUserId($user->id);
$throttle->setSuspensionTime(10);
$throttle->setAttemptLimit(3);
$throttle->check();
$credentials = ['email' => Input::json('email'), 'password' => Input::json('password')];
$user = Sentry::authenticate($credentials, false);
} catch (Cartalyst\Sentry\Users\WrongPasswordException $e) {
return Response::json(array('flash' => 'Invalid username or password'), 500);
} catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
return Response::json(array('flash' => 'Login field is required'), 500);
} catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
return Response::json(array('flash' => 'Password field is required'), 500);
} catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
return Response::json(array('flash' => 'Invalid username or password'), 500);
} catch (Cartalyst\Sentry\Users\UserNotActivatedException $e) {
return Response::json(array('flash' => 'This account is inactive'), 500);
} catch (Cartalyst\Sentry\Throttling\UserSuspendedException $e) {
$time = $throttle->getSuspensionTime();
return Response::json(array('flash' => 'This account is suspended for ' . $time . ' minutes'), 500);
} catch (Cartalyst\Sentry\Throttling\UserBannedException $e) {
return Response::json(array('flash' => 'This account has been banned'), 500);
}
$user_details = User::join('users_groups', 'users.id', '=', 'users_groups.user_id')->join('groups', 'users_groups.group_id', '=', 'groups.id')->where('users.id', '=', $user->id)->select('users.id', 'users.email', 'users.first_name', 'users.last_name', 'groups.name as role', 'users.activated_at', 'users.last_login', 'users.created_at', 'users.updated_at')->get();
return Response::json($user_details[0], 200);
}
示例6: update
public function update($id)
{
try {
//get the json from the request.
$updateModel = Input::json()->all();
//select the vendor name of the new selected vendor
$vendorQueryResult = Vendor::find($updateModel['vendor_id']);
$newVendorName = $vendorQueryResult->name;
//update the item model based on the json data sent.
$updateItem = Item::find($id);
$updateItem->description = $updateModel['description'];
$updateItem->email_threshold = $updateModel['email_threshold'];
$updateItem->item_url = $updateModel['item_url'];
$updateItem->name = $updateModel['name'];
$updateItem->on_order_quantity = $updateModel['on_order_quantity'];
$updateItem->vendor_id = $updateModel['vendor_id'];
$updateItem->quantity = $updateItem->quantity + $updateModel['adjustmentQty'];
if ($updateItem->quantity < 0) {
$updateItem->quantity = 0;
}
//save the updated item to the database
$updateItem->save();
//append the new vendor name to the model to send back in the response
$updateItem->vendor_name = $newVendorName;
$updateItem->adjustmentQty = 0;
//send the response
echo $updateItem->toJson();
} catch (Exception $e) {
return json_encode('{"error":{"text":' . $e->getMessage() . '}}');
}
}
示例7: update
public function update($id)
{
//gets the input from Backbone
$updateModel = Input::json()->all();
//find the checkout that needs to be edited and sets the properties.
$updateChecklist = OpenCloseChecklist::find($id);
$updateChecklist->task_date = $updateModel['task_date'];
$updateChecklist->cico_system_on = $updateModel['cico_system_on'];
$updateChecklist->printers_on = $updateModel['printers_on'];
$updateChecklist->print_stations_on = $updateModel['print_stations_on'];
$updateChecklist->open_main_doors = $updateModel['open_main_doors'];
$updateChecklist->open_side_doors = $updateModel['open_side_doors'];
$updateChecklist->opened_by = $updateModel['opened_by'];
$updateChecklist->cico_system_off = $updateModel['cico_system_off'];
$updateChecklist->printers_off = $updateModel['printers_off'];
$updateChecklist->print_stations_off = $updateModel['print_stations_off'];
$updateChecklist->close_main_doors = $updateModel['close_main_doors'];
$updateChecklist->close_side_doors = $updateModel['close_side_doors'];
$updateChecklist->refill_printer_paper = $updateModel['refill_printer_paper'];
$updateChecklist->push_in_chairs = $updateModel['push_in_chairs'];
$updateChecklist->turn_off_machines = $updateModel['turn_off_machines'];
$updateChecklist->recycle_prints = $updateModel['recycle_prints'];
$updateChecklist->lock_cae_office_doors = $updateModel['lock_cae_office_doors'];
$updateChecklist->closed_by = $updateModel['closed_by'];
//save the updated checkout and returns it to Backbone
$updateChecklist->save();
return $updateChecklist->toJSON();
}
示例8: post_subscribe
public function post_subscribe()
{
\Fuel\Core\Lang::load("global");
$email = Input::json("email");
if ($email !== null && preg_match("/^[a-zA-Z0-9.!#\$%&\"*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+\$/", $email) === 1) {
// Call API
$api = new \Libraries\Api();
$return = $api->executeAPIMethod("POST", "newsletters", array("email" => $email));
// Success/error
if ($return["code"] == 200) {
// Success
$this->jsonSuccess(\Fuel\Core\Lang::get("subscribe_to_newsletter.success"), array("apiReturn" => $return));
} else {
if ($return["code"] == 412) {
$this->jsonSuccess(\Fuel\Core\Lang::get("subscribe_to_newsletter.already_subscribed"));
} else {
// Error...
$this->jsonError(\Fuel\Core\Lang::get("subscribe_to_newsletter.error"));
}
}
} else {
// Error, not valid...
$this->jsonError(\Fuel\Core\Lang::get("subscribe_to_newsletter.error"));
}
}
示例9: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
$input = Input::json();
$task = Task::find($id);
$task->title = $input->get('title');
$task->completed = $input->get('completed');
$task->save();
}
示例10: login
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function login()
{
if (Auth::attempt(array('email' => Input::json('username'), 'password' => Input::json('password')))) {
return Response::json(Auth::user());
} else {
return Response::json(array('flash' => 'Invalid Username or Password Supplied'), 500);
}
}
示例11: getRawRequest
protected function getRawRequest()
{
$json = \Input::json()->all();
if (sizeof($json) == 0) {
throw new ParseErrorException();
}
return $json;
}
示例12: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
$todo = $this->todo->findOrFail($id);
$input = Input::json();
$todo->update($input->get('todo'));
$todo = $todo->toArray();
return Response::json(compact('todo'));
}
示例13: login
public function login()
{
if (Auth::attempt(array('room' => Input::json('room'), 'password' => Input::json('password')))) {
return Response::json(Auth::user());
} else {
return Response::json(array('flash' => array('notification' => 'Invalid room or password', 'class' => 'alert')), 401);
}
}
示例14: login
public function login()
{
if (Auth::attempt(array('email' => Input::json('email'), 'password' => Input::json('password')))) {
return Response::json(Auth::user());
} else {
return Response::json(array('flash' => Lang::get('messages.auth_failed')), 401);
}
}
示例15: store
public function store($notebookId, $noteId, $versionId)
{
$note = self::getNote($notebookId, $noteId, $versionId);
if ($note->pivot->umask < PaperworkHelpers::UMASK_READWRITE) {
return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_ERROR, array('message' => 'Permission Error'));
}
if (Input::hasFile('file') && Input::file('file')->isValid() || Input::json() != null && Input::json() != "") {
$fileUpload = null;
$newAttachment = null;
if (Input::hasFile('file')) {
$fileUpload = Input::file('file');
$newAttachment = new Attachment(array('filename' => $fileUpload->getClientOriginalName(), 'fileextension' => $fileUpload->getClientOriginalExtension(), 'mimetype' => $fileUpload->getMimeType(), 'filesize' => $fileUpload->getSize()));
} else {
$fileUploadJson = Input::json();
$fileUpload = base64_decode($fileUploadJson->get('file'));
$newAttachment = new Attachment(array('filename' => $fileUploadJson->get('clientOriginalName'), 'fileextension' => $fileUploadJson->get('clientOriginalExtension'), 'mimetype' => $fileUploadJson->get('mimeType'), 'filesize' => count($fileUpload)));
}
$newAttachment->save();
// Move file to (default) /app/storage/attachments/$newAttachment->id/$newAttachment->filename
$destinationFolder = Config::get('paperwork.attachmentsDirectory') . '/' . $newAttachment->id;
if (!File::makeDirectory($destinationFolder, 0700)) {
$newAttachment->delete();
return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_ERROR, array('message' => 'Internal Error'));
}
// Get Version with versionId
//$note = self::getNote($notebookId, $noteId, $versionId);
$tmp = $note ? $note->version()->first() : null;
$version = null;
if (is_null($tmp)) {
$newAttachment->delete();
File::deleteDirectory($destinationFolder);
return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_NOTFOUND, array('message' => 'version->first'));
}
while (!is_null($tmp)) {
if ($tmp->id == $versionId || $versionId == 0) {
$version = $tmp;
break;
}
$tmp = $tmp->previous()->first();
}
if (is_null($version)) {
$newAttachment->delete();
File::deleteDirectory($destinationFolder);
return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_NOTFOUND, array('message' => 'version'));
}
if (Input::hasFile('file')) {
$fileUpload->move($destinationFolder, $fileUpload->getClientOriginalName());
} else {
file_put_contents($destinationFolder . '/' . $fileUploadJson->get('clientOriginalName'), $fileUpload);
}
$version->attachments()->attach($newAttachment);
// Let's push that parsing job, which analyzes the document, converts it if needed and parses the crap out of it.
Queue::push('DocumentParserWorker', array('user_id' => Auth::user()->id, 'document_id' => $newAttachment->id));
return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_SUCCESS, $newAttachment);
} else {
return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_ERROR, array('message' => 'Invalid input'));
}
}