本文整理汇总了PHP中Request::ajax方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::ajax方法的具体用法?PHP Request::ajax怎么用?PHP Request::ajax使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Request
的用法示例。
在下文中一共展示了Request::ajax方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: destroy
public function destroy($event_id)
{
if (Request::ajax()) {
//get tag_id
if (!($tag_id = DB::table('event_tags')->where('event_id', '=', $event_id)->pluck('tag_id'))) {
Session::put('adminDangerAlert', 'Unable to find tag ID. Contact an administrator.');
return;
}
//Check if event is tagged in articles/video before deleting
if (DB::table('article_tags')->where('tag_id', '=', $tag_id)->get() || DB::table('video_tags')->where('tag_id', '=', $tag_id)->get()) {
Session::put('adminInfoAlert', 'You cannot delete this event because it is tagged in either an article or video.');
return;
} else {
//delete article
if ($event = $this->event->find($event_id)) {
$event->delete();
Session::put('adminSuccessAlert', 'Event deleted.');
return;
} else {
Session::put('adminDangerAlert', 'Something went wrong attempting to delete the event.');
return;
}
}
}
}
示例2: getTagPosts
public function getTagPosts($name)
{
try {
$tag = Tag::where('name', $name)->first();
if (!$tag) {
throw new Exception("Tag not found");
}
$posts = $tag->posts()->paginate(8);
$i = 0;
foreach ($posts as $post) {
if (!PrivacyHelper::checkPermission(Auth::user(), $post)) {
unset($posts[$i]);
$i++;
continue;
}
$i++;
$post->makrdown = str_limit($post->makrdown, $limit = 500, $end = '...');
$Parsedown = new Parsedown();
$post->HTML = $Parsedown->text($post->makrdown);
}
if (Request::ajax()) {
return View::make('posts._list')->with('data', $posts);
} else {
if (count($posts) == 0) {
return Redirect::intended(URL::action('ProfileController@getProfile', array($id)));
}
$this->layout->content = View::make('posts.list')->with('data', $posts);
}
} catch (Exception $e) {
throw $e;
}
}
示例3: login_post
public function login_post()
{
if (!Request::ajax()) {
App::abort('401');
}
$data = array('status' => 'success', 'message' => '');
try {
// Set login credentials
$credentials = array('email' => Input::get('email'), 'password' => Input::get('password'));
$remember = Input::get('remember') ? Input::get('remember') : false;
// Try to authenticate the user
$user = Sentry::authenticate($credentials, $remember);
$data['status'] = 'success';
$data['message'] = 'Login Success. Redirecting';
} catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
$data['status'] = 'error';
$data['message'] = 'Login field is required.';
} catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
$data['status'] = 'error';
$data['message'] = 'Password field is required.';
} catch (Cartalyst\Sentry\Users\WrongPasswordException $e) {
$data['status'] = 'error';
$data['message'] = 'Wrong password, try again.';
} catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
$data['status'] = 'error';
$data['message'] = 'User was not found.';
} catch (Cartalyst\Sentry\Users\UserNotActivatedException $e) {
$data['status'] = 'error';
$data['message'] = 'User is not activated.';
}
$response = Response::make(json_encode($data), 200);
$response->header('Content-Type', 'text/json');
return $response;
}
示例4: paymentRequest
/**
* function name: paymentRequest
* @return mixed
*/
public function paymentRequest($status = '', $page = 1)
{
$paymentReq = new PaymentRequestBaseModel();
$options = array('status' => $status);
$this->data['status'] = $status;
$publisher = Input::has('publisher') ? Input::get('publisher') : '';
$month = Input::has('month') ? Input::get('month') : 0;
$year = Input::has('year') ? Input::get('year') : 0;
$field = Input::has('field') ? Input::get('field') : '';
$order = Input::has('order') ? Input::get('order') : '';
$options['publisher'] = $publisher;
$options['month'] = $month;
$options['year'] = $year;
$options['field'] = $field;
$options['order'] = $order;
$items = $paymentReq->getItems('', ITEM_PER_PAGE, $page, $options);
$dataPaging['items'] = $items;
$dataPaging['options'] = array('publisher' => $publisher, 'month' => $month, 'year' => $year, 'field' => $field, 'order' => $order);
$dataPaging['total'] = $paymentReq->sumAmountPublisher($options);
if (Request::ajax()) {
return View::make('publisher_manager.approve_tools_publisher_manager.paymentRequestPaging', $dataPaging);
} else {
$this->data['listItems'] = View::make('publisher_manager.approve_tools_publisher_manager.paymentRequestPaging', $dataPaging);
}
$this->layout->content = View::make('publisher_manager.approve_tools_publisher_manager.paymentRequest', $this->data);
}
示例5: postLogin
public function postLogin()
{
if (Request::ajax()) {
$userdata = array('usuario' => Input::get('usuario'), 'password' => Input::get('password'));
if (Auth::attempt($userdata, Input::get('remember', 0))) {
//buscar los permisos de este usuario y guardarlos en sesion
$query = "SELECT m.nombre as modulo, s.nombre as submodulo,\n su.agregar, su.editar, su.eliminar,\n CONCAT(m.path,'.', s.path) as path, m.icon\n FROM modulos m \n JOIN submodulos s ON m.id=s.modulo_id\n JOIN submodulo_usuario su ON s.id=su.submodulo_id\n WHERE su.estado = 1 AND m.estado = 1 AND s.estado = 1\n and su.usuario_id = ?\n ORDER BY m.nombre, s.nombre ";
$res = DB::select($query, array(Auth::id()));
$menu = array();
$accesos = array();
foreach ($res as $data) {
$modulo = $data->modulo;
//$accesos[] = $data->path;
array_push($accesos, $data->path);
if (isset($menu[$modulo])) {
$menu[$modulo][] = $data;
} else {
$menu[$modulo] = array($data);
}
}
$usuario = Usuario::find(Auth::id());
Session::set('language', 'Español');
Session::set('language_id', 'es');
Session::set('menu', $menu);
Session::set('accesos', $accesos);
Session::set('perfilId', $usuario['perfil_id']);
Session::set("s_token", md5(uniqid(mt_rand(), true)));
Lang::setLocale(Session::get('language_id'));
return Response::json(array('rst' => '1', 'estado' => Auth::user()->estado));
} else {
$m = '<strong>Usuario</strong> y/o la <strong>contraseña</strong>';
return Response::json(array('rst' => '2', 'msj' => 'El' . $m . 'son incorrectos.'));
}
}
}
示例6: clearAll
public function clearAll()
{
$this->notificationRepository->clearAll();
if (!\Request::ajax()) {
return \Redirect::to(\URL::previous());
}
}
示例7: getGrafico2
public function getGrafico2()
{
if (Request::ajax()) {
$resultados = Proyecto::getResultados2();
return Response::Json($resultados);
}
}
示例8: errors
public static function errors($code = 404, $title = '', $message = '')
{
$ajax = Request::ajax();
if (!$code) {
$code = 500;
$title = 'Internal Server Error';
$message = 'We got problems over here. Please try again later!';
} else {
if ($code == 404) {
$title = 'Oops! You\'re lost.';
$message = 'We can not find the page you\'re looking for.';
}
}
if (Request::ajax()) {
return Response::json(['error' => ['message' => $message]], $code);
}
$arrData = [];
$arrData['content'] = View::make('frontend.errors.error')->with(['title' => $title, 'code' => $code, 'message' => $message]);
$arrData['metaInfo'] = Home::getMetaInfo();
$arrData['metaInfo']['meta_title'] = $title;
$arrData['types'] = Home::getTypes();
$arrData['categories'] = Home::getCategories();
$arrData['headerMenu'] = Menu::getCache(['header' => true]);
return View::make('frontend.layout.default')->with($arrData);
}
示例9: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$validator = $this->validate();
if ($validator->fails()) {
if (Request::ajax()) {
return Response::json(array('success' => false, 'messages' => $validator->messages()));
}
return Redirect::back()->withErrors($validator->messages())->withInput(Input::all());
}
$donor = new Donor();
$donor->name = Input::get('name');
$donor->dob = Input::get('dob');
$donor->nic = Input::get('nic');
$donor->gender = Input::get('gender');
$donor->telephone = Input::get('telephone');
$donor->blood_group_id = Input::get('blood_group_id');
$donor->email = Input::get('email');
$donor->address = Input::get('address');
$donor->details = Input::get('details');
$donor->save();
if (Request::ajax()) {
return Response::json(array('success' => true, 'donors' => [''] + Donor::all()->lists('name_with_blood_group', 'id'), 'donor_id' => $donor->id));
}
Session::flash('success', 'Successfully created donor!');
return Redirect::route('donor.index');
}
示例10: create
public function create()
{
if (\Request::ajax()) {
return response()->json(['url' => \Request::url(), 'title' => 'Contact | Jonas Vanderhaegen', 'path' => \Request::path(), 'view' => view('pages.messages.create')->render()]);
}
return view('pages.messages.create');
}
示例11: signup
public function signup()
{
if (!Allow::enabled_module('users')) {
return App::abort(404);
}
$json_request = array('status' => FALSE, 'responseText' => '', 'responseErrorText' => '', 'redirect' => FALSE);
if (Request::ajax()) {
$validator = Validator::make(Input::all(), User::$rules);
if ($validator->passes()) {
$account = User::where('email', Input::get('email'))->first();
if (is_null($account)) {
if ($account = self::getRegisterAccount(Input::all())) {
if (Allow::enabled_module('downloads')) {
if (!File::exists(base_path('usersfiles/account-') . $account->id)) {
File::makeDirectory(base_path('usersfiles/account-') . $account->id, 777, TRUE);
}
}
Mail::send('emails.auth.signup', array('account' => $account), function ($message) {
$message->from('uspensky.pk@gmail.com', 'Monety.pro');
$message->to(Input::get('email'))->subject('Monety.pro - регистрация');
});
$json_request['responseText'] = 'Вы зарегистрированы. Мы отправили на email cсылку для активации аккаунта.';
$json_request['status'] = TRUE;
}
} else {
}
} else {
$json_request['responseText'] = 'Неверно заполнены поля';
$json_request['responseErrorText'] = $validator->messages()->all();
}
} else {
return App::abort(404);
}
return Response::json($json_request, 200);
}
示例12: post_ban
public function post_ban()
{
if (Request::ajax()) {
$error = '';
$get = Input::all();
$banUsername = $get['bUsername'];
$banReason = $get['bReason'];
$user = User::where('username', '=', $banUsername)->first();
// belki kullanıcı zaten banlı olabilir.admin değğilse tekrar banlayamasın
if ($user->username == Sentry::user()->username) {
$error = 'Lütfen kendinizi banlamayınız.';
die("ban");
}
$ban = $user->bans()->first();
// Kullanıcı Zaten Banlıysa,bitiş tarihini geri döndür.
if ($ban) {
die($ban->ban_end);
}
// Güvenlik Koaaaaaaaaaaaaaaaaaaaaaaaaantrolü
$date = date('Y-m-d H:i:s');
$bandate = date('Y-m-d H:i:s', strtotime('+1 day', strtotime($date)));
$banData = Ban::create(array('user_id' => $user->id, 'ban_ip' => $user->ip_address, 'ban_email' => $user->user_email, 'ban_start' => $date, 'ban_end' => $bandate, 'ban_reason' => $banReason, 'ban_moderatorid' => Sentry::user()->id));
die("OK");
}
}
示例13: index
public function index()
{
if (\Request::ajax()) {
return Post::all();
}
return view('post.index');
}
示例14: getdates
public function getdates()
{
if (\Request::ajax()) {
$user_id = \Auth::user()->id;
$ann_scol = \Input::get('ann_scol');
$type = \Input::get('type');
$checkYear = SchoolYear::where('user_id', $user_id)->where('ann_scol', $ann_scol)->where('type', $type)->first();
if ($checkYear) {
echo json_encode($checkYear);
die;
} else {
/*
$tab = [
'startch1'=> '',
'endch1' => '',
'startch2' => '',
'endch2' => '',
];*/
$tab = [];
echo json_encode($tab);
die;
}
}
}
示例15: index
public function index()
{
if (\Request::ajax()) {
return User::all();
}
return view('user.index');
}