本文整理汇总了PHP中Api::to方法的典型用法代码示例。如果您正苦于以下问题:PHP Api::to方法的具体用法?PHP Api::to怎么用?PHP Api::to使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Api
的用法示例。
在下文中一共展示了Api::to方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: post
public function post($user = false)
{
$title = Lang::get('core.email');
if (is_array(Input::get('to')) && count(Input::get('to')) > 0) {
$_results = false;
foreach (Input::get('to') as $user_id) {
$user = $this->user->find($user_id);
if (!empty($user)) {
$_results = LCP::sendEmail($user, Input::get('template'));
} else {
$_results = false;
}
}
if ($_results == true) {
$message = Lang::get('admin/users/messages.email.success');
return Theme::make('admin/users/email_results', compact('title', 'message', '_results'));
} else {
$message = Lang::get('admin/users/messages.email.error');
return Theme::make('admin/users/email_results', compact('title', 'message', '_results'));
}
} elseif (isset($user)) {
if (LCP::sendEmail($user, Input::get('template'))) {
return Api::to(array('success', Lang::get('admin/users/messages.email.success'))) ?: Redirect::to('admin/users/' . $user->id . '/email')->with('success', Lang::get('admin/users/messages.email.success'));
} else {
return Api::to(array('error', Lang::get('admin/users/messages.email.error'))) ?: Redirect::to('admin/users/' . $user->id . '/email')->with('error', Lang::get('admin/users/messages.email.error'));
}
} else {
$message = Lang::get('admin/users/messages.email.error');
Theme::make('admin/users/email_results', compact('title', 'message'));
}
}
示例2: edit
public function edit($post)
{
$validator = Validator::make(Input::all(), $this->rules);
if ($validator->passes()) {
return $this->post->createOrUpdate($post->id) ? Api::to(array('success', Lang::get('admin/blogs/messages.update.success'))) ?: Redirect::to('admin/slugs/' . $post->id . '/edit')->with('success', Lang::get('admin/blogs/messages.update.success')) : Api::to(array('error', Lang::get('admin/blogs/messages.update.error'))) ?: Redirect::to('admin/slugs/' . $post->id . '/edit')->with('error', Lang::get('admin/blogs/messages.update.error'));
} else {
return Api::to(array('error', Lang::get('admin/blogs/messages.update.error'))) ?: Redirect::to('admin/slugs/' . $post->id . '/edit')->withInput()->withErrors($validator);
}
}
示例3: edit
public function edit($role)
{
if (in_array(Input::old('name', $role->name), \Role::$protected) && Input::old('name', $role->name) != Input::get('name') || in_array(Input::get('name'), \Role::$protected) && Input::old('name', $role->name) != Input::get('name')) {
return Api::to(array('error', Lang::get('admin/roles/messages.update.error'))) ?: Redirect::to('admin/roles/' . $role->id . '/edit')->with('error', Lang::get('admin/roles/messages.update.error'));
}
$inputs = Input::except('csrf_token');
$save = $this->role->createOrUpdate($role->id, $this->permission->preparePermissionsForSave($inputs['permissions']));
$errors = $save->errors();
return count($errors->all()) == 0 ? Api::to(array('success', Lang::get('admin/roles/messages.update.success'))) ?: Redirect::to('admin/roles/' . $role->id . '/edit')->with('success', Lang::get('admin/roles/messages.update.success')) : (Api::to(array('error', Lang::get('admin/roles/messages.update.error'))) ?: Redirect::to('admin/roles/' . $role->id . '/edit')->withErrors($errors));
}
示例4: edit
public function edit($comment)
{
$rules = array('content' => 'required|min:3');
$validator = Validator::make(Input::all(), $rules);
if ($validator->passes()) {
return $this->comment->createOrUpdate($comment->id) ? Api::to(array('success', Lang::get('admin/comments/messages.update.success'))) ?: Redirect::to('admin/comments/' . $comment->id . '/edit')->with('success', Lang::get('admin/comments/messages.update.success')) : Api::to(array('error', Lang::get('admin/comments/messages.update.error'))) ?: Redirect::to('admin/comments/' . $comment->id . '/edit')->with('error', Lang::get('admin/comments/messages.update.error'));
} else {
return Api::to(array('error', Lang::get('admin/comments/messages.update.error'))) ?: Redirect::to('admin/comments/' . $comment->id . '/edit')->withInput()->withErrors($validator);
}
}
示例5: post
public function post()
{
$settings = Input::get('settings');
if (isset($settings) && is_array($settings)) {
foreach ($settings as $var => $val) {
Setting::set($var, $val);
}
Setting::save();
}
return Api::to(array('success', Lang::get('admin/settings/messages.update.success'))) ?: Redirect::to('admin/settings')->with('success', Lang::get('admin/settings/messages.update.success'));
}
示例6: edit
public function edit($role)
{
if (in_array(Input::old('name', $role->name), $this->protected_roles) && Input::old('name', $role->name) != Input::get('name') || in_array(Input::get('name'), $this->protected_roles) && Input::old('name', $role->name) != Input::get('name')) {
return Api::to(array('error', Lang::get('admin/roles/messages.update.error'))) ?: Redirect::to('admin/roles/' . $role->id . '/edit')->with('error', Lang::get('admin/roles/messages.update.error'));
}
$validator = Validator::make(Input::all(), $this->rules);
if ($validator->passes()) {
$inputs = Input::except('csrf_token');
return $this->role->createOrUpdate($role->id, $this->permission->preparePermissionsForSave($inputs['permissions'])) ? Api::to(array('success', Lang::get('admin/roles/messages.update.success'))) ?: Redirect::to('admin/roles/' . $role->id . '/edit')->with('success', Lang::get('admin/roles/messages.update.success')) : Api::to(array('error', Lang::get('admin/roles/messages.update.error'))) ?: Redirect::to('admin/roles/' . $role->id . '/edit')->with('error', Lang::get('admin/roles/messages.update.error'));
}
return Api::to(array('error', Lang::get('admin/roles/messages.update.error'))) ?: Redirect::to('admin/roles/' . $role->id . '/edit')->withInput()->withErrors($validator);
}
示例7: putEdit
/**
* put edit
*
* @return Response
*/
public function putEdit($todo)
{
$rules = array('title' => 'required');
$validator = Validator::make(Input::all(), $rules);
if ($validator->passes()) {
$todo->title = Input::get('title');
$todo->description = Input::get('description');
$todo->status = Input::get('status');
$todo->due_at = Carbon::parse(Input::get('due_at'));
return $todo->save() ? Api::to(array('success', Lang::get('admin/todos/messages.create.success'))) ?: Redirect::to('admin/todos/' . $todo->id . '/edit')->with('success', Lang::get('admin/todos/messages.create.success')) : Api::to(array('error', Lang::get('admin/todos/messages.create.error'))) ?: Redirect::to('admin/todos/' . $todo->id . '/edit')->with('error', Lang::get('admin/todos/messages.create.error'));
} else {
return Api::to(array('error', Lang::get('admin/todos/messages.create.error'))) ?: Redirect::to('admin/todos/' . $todo->id . '/edit')->withErrors($validator);
}
}
示例8: putEdit
/**
* Update the specified resource in storage.
*
* @param $comment
* @return Response
*/
public function putEdit($comment)
{
$rules = array('content' => 'required|min:3');
$validator = Validator::make(Input::all(), $rules);
// Check if the form validates with success
if ($validator->passes()) {
$comment->content = Input::get('content');
if ($comment->save()) {
return Api::to(array('success', Lang::get('admin/comments/messages.update.success'))) ?: Redirect::to('admin/comments/' . $comment->id . '/edit')->with('success', Lang::get('admin/comments/messages.update.success'));
} else {
return Api::to(array('error', Lang::get('admin/comments/messages.update.error'))) ?: Redirect::to('admin/comments/' . $comment->id . '/edit')->with('error', Lang::get('admin/comments/messages.update.error'));
}
} else {
return Api::to(array('error', Lang::get('admin/comments/messages.update.error'))) ?: Redirect::to('admin/comments/' . $comment->id . '/edit')->withInput()->withErrors($validator);
}
}
示例9: postIndex
/**
* Update the specified resource in storage.
*
* @param $comment
* @return Response
*/
public function postIndex()
{
$rules = array();
$validator = Validator::make(Input::all(), $rules);
if ($validator->passes()) {
$settings = Input::get('settings');
if (isset($settings) && is_array($settings)) {
foreach ($settings as $var => $val) {
Setting::set($var, $val);
}
Setting::save();
}
return Api::to(array('success', Lang::get('admin/settings/messages.update.success'))) ?: Redirect::to('admin/settings')->with('success', Lang::get('admin/settings/messages.update.success'));
} else {
return Api::to(array('error', Lang::get('admin/settings/messages.update.error'))) ?: Redirect::to('admin/settings')->withInput()->withErrors($validator);
}
}
示例10: putEdit
/**
* Update the specified resource in storage.
*
* @param $post
* @return Response
*/
public function putEdit($statuses)
{
$rules = array('title' => 'required|min:3');
$validator = Validator::make(Input::all(), $rules);
// Check if the form validates with success
if ($validator->passes()) {
if ((int) Input::get('close_status') == 1) {
TicketStatuses::where('close_status', '=', '1')->update(array('close_status' => '0'));
}
if ((int) Input::get('default_flag') == 1) {
TicketStatuses::where('default_flag', '=', '1')->update(array('default_flag' => '0'));
}
if ((int) Input::get('default_button') == 1) {
TicketStatuses::where('default_button', '=', '1')->update(array('default_button' => '0'));
}
if ((int) Input::get('default_category') == 1) {
TicketStatuses::where('default_category', '=', '1')->update(array('default_category' => '0'));
}
$statuses->title = Input::get('title');
$statuses->color = Input::get('color');
$statuses->sort = (int) Input::get('sort');
$statuses->show_active = (int) Input::get('show_active');
$statuses->default_flag = (int) Input::get('default_flag');
$statuses->default_button = (int) Input::get('default_button');
$statuses->default_category = (int) Input::get('default_category');
$statuses->auto_close = (int) Input::get('auto_close');
$statuses->close_status = (int) Input::get('close_status');
return $statuses->save() ? Api::to(array('success', Lang::get('l4cp-support::messages.update.success'))) ?: Redirect::to('admin/support/statuses/' . $statuses->id . '/edit')->with('success', Lang::get('l4cp-support::messages.update.success')) : Api::to(array('error', Lang::get('l4cp-support::messages.update.error'))) ?: Redirect::to('admin/support/statuses/' . $statuses->id . '/edit')->with('error', Lang::get('l4cp-support::messages.update.error'));
} else {
return Api::to(array('error', Lang::get('l4cp-support::messages.update.error'))) ?: Redirect::to('admin/support/statuses/' . $statuses->id . '/edit')->withInput()->withErrors($validator);
}
}
示例11: putEdit
/**
* Update the specified resource in storage.
*
* @param $post
* @return Response
*/
public function putEdit($spam)
{
$rules = array('type' => 'required', 'content' => 'required');
$validator = Validator::make(Input::all(), $rules);
// Check if the form validates with success
if ($validator->passes()) {
$spam->type = Input::get('type');
$spam->content = Input::get('content');
return $spam->save() ? Api::to(array('success', Lang::get('l4cp-support::messages.update.success'))) ?: Redirect::to('admin/support/spam/' . $spam->id . '/edit')->with('success', Lang::get('l4cp-support::messages.update.success')) : Api::to(array('error', Lang::get('l4cp-support::messages.update.error'))) ?: Redirect::to('admin/support/spam/' . $spam->id . '/edit')->with('error', Lang::get('l4cp-support::messages.update.error'));
} else {
return Api::to(array('error', Lang::get('l4cp-support::messages.update.error'))) ?: Redirect::to('admin/support/spam/' . $spam->id . '/edit')->withInput()->withErrors($validator);
}
}
示例12: edit
public function edit($comment)
{
$save = $this->comment->createOrUpdate($comment->id);
$errors = $save->errors();
return count($errors->all()) == 0 ? Api::to(array('success', Lang::get('admin/comments/messages.update.success'))) ?: Redirect::to('admin/comments/' . $comment->id . '/edit')->with('success', Lang::get('admin/comments/messages.update.success')) : (Api::to(array('error', Lang::get('admin/comments/messages.update.error'))) ?: Redirect::to('admin/comments/' . $comment->id . '/edit')->withErrors($errors));
}
示例13: putEdit
/**
* Update the specified resource in storage.
*
* @param $post
* @return Response
*/
public function putEdit($department)
{
$rules = array('name' => 'required|min:3', 'flags' => 'required');
$validator = Validator::make(Input::all(), $rules);
// Check if the form validates with success
if ($validator->passes()) {
$department->name = Input::get('name');
$department->description = Input::get('description');
$department->email = Input::get('email');
$department->pop_host = Input::get('pop_host');
$department->pop_port = Input::get('pop_port');
$department->pop_user = Input::get('pop_user');
$department->pop_pass = Input::get('pop_pass');
$department->clients_only = (int) Input::get('clients_only');
$department->auto_respond = (int) Input::get('auto_respond');
$department->hidden = (int) Input::get('hidden');
$department->sort = (int) Input::get('sort');
$department->saveFlags(Input::get('flags'));
return $department->save() ? Api::to(array('success', Lang::get('l4cp-support::messages.update.success'))) ?: Redirect::to('admin/support/departments/' . $department->id . '/edit')->with('success', Lang::get('l4cp-support::messages.update.success')) : Api::to(array('error', Lang::get('l4cp-support::messages.update.error'))) ?: Redirect::to('admin/support/departments/' . $department->id . '/edit')->with('error', Lang::get('l4cp-support::messages.update.error'));
} else {
return Api::to(array('error', Lang::get('l4cp-support::messages.update.error'))) ?: Redirect::to('admin/support/departments/' . $department->id . '/edit')->withInput()->withErrors($validator);
}
}
示例14: putEdit
/**
* Update the specified resource in storage.
*
* @param $post
* @return Response
*/
public function putEdit($escalations)
{
$rules = array('name' => 'required|min:3');
$validator = Validator::make(Input::all(), $rules);
// Check if the form validates with success
if ($validator->passes()) {
$escalations->name = Input::get('name');
$escalations->delay = (int) Input::get('delay');
$escalations->reply = Input::get('reply');
$escalations->notify_admins = (int) Input::get('notify_admins');
$escalations->flag = (int) Input::get('flag');
$escalations->priority = json_encode(Input::get('priorities'));
$escalations->new_status = (int) Input::get('new_status');
$escalations->new_priority = (int) Input::get('new_priority');
$escalations->new_department = (int) Input::get('new_department');
$escalations->saveDeps(Input::get('departments'));
$escalations->saveStatuses(Input::get('statuses'));
$escalations->saveFlags(explode(',', Input::get('flags')));
return $escalations->save() ? Api::to(array('success', Lang::get('l4cp-support::messages.update.success'))) ?: Redirect::to('admin/support/escalations/' . $escalations->id . '/edit')->with('success', Lang::get('l4cp-support::messages.update.success')) : Api::to(array('error', Lang::get('l4cp-support::messages.update.error'))) ?: Redirect::to('admin/support/escalations/' . $escalations->id . '/edit')->with('error', Lang::get('l4cp-support::messages.update.error'));
} else {
return Api::to(array('error', Lang::get('l4cp-support::messages.update.error'))) ?: Redirect::to('admin/support/escalations/' . $escalations->id . '/edit')->withInput()->withErrors($validator);
}
}
示例15: putEdit
/**
* Update the specified resource in storage.
*
* @param $post
* @return Response
*/
public function putEdit($tickets)
{
$rules = array('title' => 'required|min:3');
$validator = Validator::make(Input::all(), $rules);
// Check if the form validates with success
if ($validator->passes()) {
$tickets->user_id = Input::get('user_id');
//$tickets->admin_id = Confide::user()->id;
$tickets->department_id = Input::get('department_id');
$tickets->name = Input::get('name');
$tickets->email = Input::get('email');
$tickets->title = Input::get('title');
$tickets->attachment = Input::get('attachment');
$tickets->message = Input::get('content');
$tickets->priority = Input::get('priority');
$tickets->status = Input::get('status');
$tickets->saveFlags(explode(',', Input::get('flags')));
foreach (Input::get('notes') as $id => $note) {
$not = TicketNotes::find($id);
if (!empty($not)) {
if (trim($note) != '') {
$not->fill(array('id' => $id, 'content' => $note))->push();
} else {
$not->delete();
}
} else {
$not = new TicketNotes(array('id' => $id, 'content' => $note, 'admin_id' => Confide::user()->id));
$tickets->notes()->save($not);
}
}
Support::Trigger('edit', $tickets);
return $tickets->save() ? Api::to(array('success', Lang::get('l4cp-support::messages.update.success'))) ?: Redirect::to('admin/support/' . $tickets->id . '/edit')->with('success', Lang::get('l4cp-support::messages.update.success')) : Api::to(array('error', Lang::get('l4cp-support::messages.update.error'))) ?: Redirect::to('admin/support/' . $tickets->id . '/edit')->with('error', Lang::get('l4cp-support::messages.update.error'));
} else {
return Api::to(array('error', Lang::get('l4cp-support::messages.update.error'))) ?: Redirect::to('admin/support/' . $tickets->id . '/edit')->withInput()->withErrors($validator);
}
}