当前位置: 首页>>代码示例>>PHP>>正文


PHP Event::first方法代码示例

本文整理汇总了PHP中Event::first方法的典型用法代码示例。如果您正苦于以下问题:PHP Event::first方法的具体用法?PHP Event::first怎么用?PHP Event::first使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Event的用法示例。


在下文中一共展示了Event::first方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: action_edit

 public function action_edit($id)
 {
     $post = \Blog\Models\Post::find($id);
     if ($post === null) {
         return Event::first('404');
     }
     if (Str::lower(Request::method()) == "post") {
         $validator = Validator::make(Input::all(), self::$rules);
         if ($validator->passes()) {
             $post->title = Input::get('title');
             if (Input::get('slug')) {
                 $post->slug = Str::slug(Input::get('slug'));
             } else {
                 $post->slug = Str::slug(Input::get('title'));
             }
             $post->intro = Input::get('intro');
             $post->content = Input::get('content');
             $post->author_id = Input::get('author_id');
             $post->category_id = Input::get('category_id');
             $post->publicated_at = Input::get('publicated_at_date') . ' ' . Input::get('publicated_at_time');
             $post->save();
             return Redirect::to_action('blog::admin.post@list');
         } else {
             return Redirect::back()->with_errors($validator)->with_input();
         }
     } else {
         $categories = array();
         $originalCategories = \Blog\Models\Category::all();
         foreach ($originalCategories as $cat) {
             $categories[$cat->id] = $cat->name;
         }
         return View::make('blog::admin.post.new')->with_post($post)->with('editMode', true)->with('categories', $categories);
     }
 }
开发者ID:marmaray,项目名称:OLD-laravel-France-website,代码行数:34,代码来源:post.php

示例2: update

 public static function update($view, $id)
 {
     // Get the Account
     $response = API::get(array('account', $id));
     // Handle response codes other than 200 OK
     if (!$response->success) {
         return Event::first($response->code);
     }
     // The response body is the Account
     $account = $response->get();
     // Get Roles and put it in a nice array for the dropdown
     $roles = array('' => '') + model_array_pluck(API::get(array('role', 'all'))->get('results'), function ($role) {
         return $role->lang->name;
     }, 'id');
     // Get the Roles that belong to a User and put it in a nice array for the dropdown
     $active_roles = array();
     if (isset($account->roles)) {
         $active_roles = model_array_pluck($account->roles, 'id', '');
     }
     // Get Languages and put it in a nice array for the dropdown
     $languages = model_array_pluck(API::get(array('language', 'all'))->get('results'), function ($language) {
         return $language->name;
     }, 'id');
     $view->text('name', __('admin::account.update.form.name'), Input::old('name', $account->name));
     $view->text('email', __('admin::account.update.form.email'), Input::old('email', $account->email));
     $view->password('password', __('admin::account.update.form.password'));
     $view->multiple('roles[]', __('admin::account.update.form.roles'), $roles, Input::old('roles', $active_roles));
     $view->dropdown('language_id', __('admin::account.update.form.language'), $languages, Input::old('language_id', $account->language->id));
     $view->actions(function ($view) {
         $view->submit(__('admin::account.update.buttons.edit'), 'primary');
     });
 }
开发者ID:reith2004,项目名称:admin,代码行数:32,代码来源:module.php

示例3: action_resolve

 public function action_resolve($post_id)
 {
     if ($post = Post::where_id($post_id)->first(array('id', 'slug'))) {
         return Redirect::to_action('blog::home@show', array($post->id, $post->slug));
     } else {
         return Event::first('404');
     }
 }
开发者ID:marmaray,项目名称:OLD-laravel-France-website,代码行数:8,代码来源:home.php

示例4: action_index

 public function action_index()
 {
     if (Auth::guest()) {
         return Event::first('404');
     }
     $topics = Forumtopic::getPosted();
     return View::make('forums::posted.index', array('topics' => $topics));
 }
开发者ID:marmaray,项目名称:OLD-laravel-France-website,代码行数:8,代码来源:posted.php

示例5: action_index

 public function action_index($slug, $id)
 {
     $topics = Forumtopic::getHomePageList($id);
     if (!$topics) {
         return Event::first('404');
     }
     $pagination = $topics->links();
     $topics = $topics->results;
     $category = Forumcategory::where_id($id)->first(array('id', 'slug', 'title'));
     return View::make('forums::category.index', array('category' => $category, 'topics' => $topics, 'pagination' => $pagination));
 }
开发者ID:marmaray,项目名称:OLD-laravel-France-website,代码行数:11,代码来源:category.php

示例6: error

 /**
  * Return an error page, optionally with data/message
  *
  * @param  int           HTTP status code
  * @param  array|string  Data or message
  */
 public static function error($status = 500, $data = array())
 {
     is_string($data) && ($data = array('message' => $data));
     $data['error'] = true;
     if (Request::ajax() || Request::accepts('application/json')) {
         return parent::json($data, $status);
     }
     if ($status == 404) {
         return parent::error($status, $data);
     }
     return \Event::first('response.error', [$status, $data]);
 }
开发者ID:SerdarSanri,项目名称:laravel-squire,代码行数:18,代码来源:response.php

示例7: get_profile

 public function get_profile($id, $action = 'essentials')
 {
     $user = u::find($id);
     if ($user === NULL) {
         return \Event::first('404');
     } else {
         if (u::current()->id == $id || u::current()->isAdmin()) {
             return \View::make('fluxbb::user.profile.' . $action)->with('user', $user);
         } else {
             return \View::make('fluxbb::user.profile.view')->with('user', $user);
         }
     }
 }
开发者ID:nathanking101,项目名称:core,代码行数:13,代码来源:User.php

示例8: exception

 /**
  * Handle an exception and display the exception report.
  *
  * @param  Exception  $exception
  * @return void
  */
 public static function exception($exception)
 {
     static::log($exception);
     // If detailed errors are enabled, we'll just format the exception into
     // a simple error message and display it on the screen. We don't use a
     // View in case the problem is in the View class.
     if (Config::get('error.detail')) {
         echo "<html><h2>Unhandled Exception</h2>\n\t\t\t\t  <h3>Message:</h3>\n\t\t\t\t  <pre>" . $exception->getMessage() . "</pre>\n\t\t\t\t  <h3>Location:</h3>\n\t\t\t\t  <pre>" . $exception->getFile() . " on line " . $exception->getLine() . "</pre>\n\t\t\t\t  <h3>Stack Trace:</h3>\n\t\t\t\t  <pre>" . $exception->getTraceAsString() . "</pre></html>";
     } else {
         $response = Event::first('500');
         return Response::prepare($response)->send();
     }
     exit(1);
 }
开发者ID:bamper,项目名称:laravel.com,代码行数:20,代码来源:error.php

示例9: get_post

 public function get_post($pid)
 {
     // If a post ID is specified we determine topic ID and page number so we can show the correct message
     $post = Post::where('id', '=', $pid)->select(array('topic_id', 'posted'))->first();
     if ($post === NULL) {
         return \Event::first('404');
     }
     $tid = $post->topic_id;
     $posted = $post->posted;
     // Determine on what page the post is located (depending on $forum_user['disp_posts'])
     $num_posts = Post::where('topic_id', '=', $tid)->where('posted', '<', $posted)->count('id') + 1;
     $disp_posts = $this->user()->dispPosts();
     $p = ceil($num_posts / $disp_posts);
     // FIXME: second parameter for $page number
     return $this->get_topic($tid);
 }
开发者ID:nathanking101,项目名称:core,代码行数:16,代码来源:Home.php

示例10: post_add_pdf

 public function post_add_pdf()
 {
     $rules = Config::get('rules.add_pdf');
     $validation = Validator::make(Input::all(), $rules);
     if ($validation->passes()) {
         $pdf = Input::file('pdf');
         if (is_file($pdf['tmp_name']) and $pdf['error'] === UPLOAD_ERR_OK) {
             if (Pdfs::add(Input::all())) {
                 return Redirect::to('add_pdf')->with('success', TRUE);
             } else {
                 return Event::first('500', 'The PDF could not be added due to a system error. We apologize for any inconvenience.');
             }
         }
         Session::flash('failed', TRUE);
     }
     return Redirect::to('add_pdf')->with_input()->with_errors($validation);
 }
开发者ID:bankorh,项目名称:ecom1_laravel,代码行数:17,代码来源:admin.php

示例11: delete

 public function delete($view, $id)
 {
     // Get the Account
     $response = API::get(array('module', $id));
     // Handle response codes other than 200 OK
     if (!$response->success) {
         return Event::first($response->code);
     }
     // The response body is the Account
     $module = $response->get();
     $view->page_header(function ($view) {
         $view->float_right(function ($view) {
             $view->search();
         });
         $view->title(__('admin::module.delete.title'));
     });
     $view->well(function ($view) use($module) {
         $view->raw(__('admin::module.delete.message', array('name' => $module->name, 'email' => $module->email)));
     });
     $view->form(Module::form('module.delete', $id), 'DELETE', prefix('admin') . 'module/delete/' . $id);
 }
开发者ID:reith2004,项目名称:admin,代码行数:21,代码来源:module.php

示例12: post_forgot_password

 public function post_forgot_password()
 {
     $rules = Config::get('rules.forgot_password');
     $validation = Validator::make(Input::get(), $rules);
     if ($validation->passes()) {
         $new_password = User::new_password(Input::get('email'));
         if (!$new_password) {
             return Event::first('500', 'Your password could not be changed due to a system error. We apologize for any inconvenience.');
         }
         //$message = "Your password to log into <whatever site> has been temporarily changed to '$new_password'. Please log in using that password and this email address. Then you may change your password to something more familiar.";
         //mail(Input::get('email'), 'Your temporary password.', $message, 'From: admin@example.com');
         Session::flash('success', TRUE);
     }
     return Redirect::to('forgot_password')->with_input()->with_errors($validation);
 }
开发者ID:bankorh,项目名称:ecom1_laravel,代码行数:15,代码来源:account.php

示例13: test_delegate_setter_gh_98

 public function test_delegate_setter_gh_98()
 {
     Venue::$use_custom_set_state_setter = true;
     $event = Event::first();
     $event->state = 'MEXICO';
     $this->assert_equals('MEXICO#', $event->venue->state);
     Venue::$use_custom_set_state_setter = false;
 }
开发者ID:sebcode,项目名称:php-activerecord,代码行数:8,代码来源:ActiveRecordTest.php

示例14: action_postedit

 public function action_postedit($topic_slug, $topic_id, $message_id)
 {
     $topic = Forumtopic::find($topic_id);
     if (is_null($topic)) {
         return Event::first('404');
     }
     $category = $topic->category;
     $message = Forummessage::find($message_id);
     if (is_null($message)) {
         return Event::first('404');
     }
     if ($message->user->id != Auth::user()->id && !Auth::user()->is('Forumer')) {
         return Event::first('404');
     }
     $rules = array('content' => 'required|min:30');
     $content = trim(Input::get('content'));
     $toValidate = compact('content');
     $editTitle = false;
     if ($topic->messages[0]->id == $message->id && trim(Input::get('title')) != $topic->title) {
         $editTitle = true;
         $rules['title'] = 'required|min:2';
         $title = trim(Input::get('title'));
         $toValidate['title'] = $title;
     }
     $validator = Validator::make($toValidate, $rules);
     if ($validator->fails()) {
         return Redirect::back()->with_errors($validator)->with_input();
     }
     if ($editTitle) {
         $topic->title = $toValidate['title'];
         $topic->slug = Str::slug($toValidate['title']);
         $originalSlug = $topic->slug;
         $incSlug = 0;
         do {
             try {
                 $topic->save();
                 $incSlug = 0;
             } catch (Exception $e) {
                 if ($e->getCode() == 23000) {
                     $incSlug++;
                 }
                 $topic->slug = $originalSlug . '-' . $incSlug;
             }
         } while ($incSlug != 0);
     }
     $message->content = BBCodeParser::parse($content);
     $message->content_bbcode = $content;
     $message->save();
     $topic->touch();
     $topic_id = $topic->id;
     $topic_slug = $topic->slug;
     $url = URL::to_action('forums::topic@index', compact('topic_slug', 'topic_id')) . '?page=last#message' . $message->id;
     return Redirect::to($url);
 }
开发者ID:marmaray,项目名称:OLD-laravel-France-website,代码行数:54,代码来源:topic.php

示例15: load

 /**
  * Load all of the language lines from a language file.
  *
  * @param  string  $bundle
  * @param  string  $language
  * @param  string  $file
  * @return bool
  */
 public static function load($bundle, $language, $file)
 {
     if (isset(static::$lines[$bundle][$language][$file])) {
         return true;
     }
     // We use a "loader" event to delegate the loading of the language
     // array, which allows the develop to organize the language line
     // arrays for their application however they wish.
     $lines = Event::first(static::loader, func_get_args());
     static::$lines[$bundle][$language][$file] = $lines;
     return count($lines) > 0;
 }
开发者ID:Shahriar1824,项目名称:laravel-tutorial,代码行数:20,代码来源:lang.php


注:本文中的Event::first方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。