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


PHP models\Article类代码示例

本文整理汇总了PHP中app\models\Article的典型用法代码示例。如果您正苦于以下问题:PHP Article类的具体用法?PHP Article怎么用?PHP Article使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: make

 /**
  * Return a fresh instance of the model (called on `create()`).
  *
  * @return \Illuminate\Database\Eloquent\Model
  */
 protected function make()
 {
     $model = new Article();
     $model->publish_date = new Carbon();
     $model->save();
     return $model;
 }
开发者ID:bjrnblm,项目名称:blender,代码行数:12,代码来源:ArticleController.php

示例2: testValidateCorrect

 public function testValidateCorrect()
 {
     $model = new Article(['name' => 'name', 'text' => 'text', 'created_at' => 'created_at', 'updated_at' => 'updated_at', 'user_id' => null]);
     $this->specify('event wrong', function () use($model) {
         expect('model should not validate', $model->validate())->true();
     });
 }
开发者ID:vitalik74,项目名称:event-app,代码行数:7,代码来源:ArticleTest.php

示例3: actionFeed

 public function actionFeed()
 {
     $this->layout = false;
     $article = new Article();
     $data = $article->getArticle();
     return $this->render('feed', $data);
 }
开发者ID:tqsq2005,项目名称:blog-cms,代码行数:7,代码来源:BlogController.php

示例4: index

 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     $article = new Article();
     if (Request::isMethod('post')) {
         $rules = ['title' => 'required', 'intro' => 'required', 'content' => 'required'];
         $validator = Validator::make(Input::all(), $rules);
         if ($validator->fails()) {
             $messages = $validator->messages();
             return Redirect::to('oszdmeg-te-is')->withErrors($messages)->withInput();
         } else {
             $article = new Article();
             $article->title = Input::get('title');
             $article->intro = Input::get('intro');
             $article->content = Input::get('content');
             $article->display_author_name = Input::get('display_author_name') == 'on' ? Input::get('display_author_name') : 1;
             $article->type_id = 2;
             $article->seo_url = Helpers::seo_url($article->title);
             $article->user = Auth::id();
             $article->save();
             Session::flash('message', 'Köszönjük!.Egyik adminisztrátorunk engedélyezni fogja cikkedet a következő 30 percben.');
             return Redirect::to('/');
         }
     }
     return view('share.index')->with('article', $article);
 }
开发者ID:Thor89,项目名称:horgaszkalandok,代码行数:30,代码来源:ShareController.php

示例5: syncTags

 protected function syncTags(Article $article, $tagIds)
 {
     if (!empty($tagIds)) {
         $article->tags()->sync($tagIds);
     } else {
         $article->tags()->detach();
     }
 }
开发者ID:ruslankus,项目名称:lavarel-lessons,代码行数:8,代码来源:ArticleController.php

示例6: post_mod

 public function post_mod()
 {
     if (Input::exists()) {
         $title = Input::get('title');
         $mode = (int) Input::get('mode');
         $article = new Article();
         $article->post_mod($title, $mode);
     }
 }
开发者ID:bekusc,项目名称:secret-box,代码行数:9,代码来源:AppController.php

示例7: update

 /**
  * Update the specified resource in storage.
  *
  * @param Article $article
  * @param ArticleRequest $request
  * @return \Illuminate\Http\Response
  */
 public function update(Article $article, ArticleRequest $request)
 {
     $article->update($request->all());
     if ($tags = $request->get('tag_list')) {
         $article->tags()->sync($tags);
     }
     flash()->success('Article has been edited!');
     return Redirect::back();
 }
开发者ID:mattvb91,项目名称:website-laravel,代码行数:16,代码来源:ArticleController.php

示例8: delete

 public function delete(Article $article, $id)
 {
     $data = $article->find($id);
     if (!$data) {
         return response()->json(['error' => 'data not found'], 404);
     }
     $data->delete();
     return response()->json(200);
 }
开发者ID:aririfani,项目名称:laravel-rest-api,代码行数:9,代码来源:ArticleController.php

示例9: actionDetail

 public function actionDetail()
 {
     $id = Yii::$app->request->get('id');
     $article = new Article();
     $detail = $article->getDetail($id);
     $comment = new Comment();
     $comments = $comment->getComments($id);
     $visitor = new Visitor();
     echo $this->render('detail', ['detail' => $detail, 'comments' => $comments, 'visitor' => $visitor]);
 }
开发者ID:tqsq2005,项目名称:blog-cms,代码行数:10,代码来源:ArticleController.php

示例10: run

 /**
  * composer require fzaninotto/faker
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create();
     Article::truncate();
     for ($i = 0; $i < 100; $i++) {
         $article = new Article();
         $article->title = $faker->sentence;
         $article->excerpt = $faker->text(200);
         $article->content = $faker->text(2000);
         $article->author = $faker->name;
         $article->category_id = $faker->numberBetween(1, count(Category::count()));
         $article->save();
     }
 }
开发者ID:bassx1,项目名称:lessons,代码行数:20,代码来源:CreateArticlesSeed.php

示例11: seedArticle

 protected function seedArticle($name, $technicalName = '', $orderColumnValue = null)
 {
     $article = new Article();
     foreach (config('app.locales') as $locale) {
         $article->translate($locale)->name = $name;
         $article->translate($locale)->text = '<p class="intro">' . $this->faker->paragraph(6) . '</p>' . '<h3>' . $this->faker->sentence(6) . '</h3>' . '<p>' . $this->faker->paragraph(9) . '</p>' . '<blockquote>' . $this->faker->paragraph(7) . '</blockquote>' . '<h3>' . $this->faker->sentence(6) . '</h3>' . '<p>' . $this->faker->paragraph(10) . '</p>' . '<p>' . $this->faker->paragraph(8) . '</p>';
     }
     $article->online = true;
     $article->technical_name = $technicalName;
     $article->draft = false;
     $article->order_column = $orderColumnValue;
     $article->push();
     $this->addImages($article);
 }
开发者ID:bjrnblm,项目名称:blender,代码行数:14,代码来源:ArticleSeeder.php

示例12: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $data['article'] = Article::find($id);
     ArticleStatus::update_view_number($id);
     $this->setCommonData();
     return view('website.article', $data);
 }
开发者ID:xinzou,项目名称:blog,代码行数:13,代码来源:ArticleController.php

示例13: run

 public function run()
 {
     DB::table('user')->delete();
     DB::table('pages')->delete();
     Article::create(array('title' => 'First post', 'slug' => 'first-post', 'body' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', 'user_id' => 1));
     Page::create(array('title' => 'About us', 'slug' => 'about-us', 'body' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', 'user_id' => 1));
 }
开发者ID:brucewu16899,项目名称:laravel-admin-panel,代码行数:7,代码来源:ContentSeeder.php

示例14: index

 public function index()
 {
     $users = User::all()->count();
     $trusts = Trusts::groupBy("registry")->get()->count();
     $articles = Article::all()->count();
     return view('admin/dashboard')->with(['users' => $users, 'trusts' => $trusts, 'articles' => $articles]);
 }
开发者ID:pjnovas,项目名称:fideicomisos2015,代码行数:7,代码来源:Admin.php

示例15: insert

 public function insert()
 {
     /** @var \app\services\GetArticle\ExtractorInterface $extractor */
     $extractor = null;
     switch ($this->provider) {
         case 'verhosvet':
             $extractor = new \app\services\GetArticle\Verhosvet($this->url);
             break;
         case 'youtube':
             $extractor = new \app\services\GetArticle\YouTube($this->url);
             break;
     }
     if (is_null($extractor)) {
         throw new Exception('Не верный extractor');
     }
     $row = $extractor->extract();
     $articleObject = Article::insert(['header' => $row['header'], 'content' => $row['content'], 'description' => $row['description'], 'source' => $this->url, 'id_string' => Str::rus2translit($row['header']), 'date_insert' => gmdate('YmdHis'), 'tree_node_id_mask' => (new BitMask($this->tree_node_id_mask))->getMask()]);
     $this->id = $articleObject->getId();
     $image = $row['image'];
     $imageContent = file_get_contents($image);
     $imageUrl = parse_url($image);
     $pathInfo = pathinfo($imageUrl['path']);
     $pathInfo['extension'];
     $fields = \cs\Widget\FileUpload2\FileUpload::save(File::content($imageContent), $pathInfo['extension'], ['image', 'Картинка', 0, 'string', 'widget' => [FileUpload::className(), ['options' => ['small' => \app\services\GsssHtml::$formatIcon]]]], $this);
     $articleObject->update($fields);
     return true;
 }
开发者ID:Makeyko,项目名称:galaxysss,代码行数:27,代码来源:ArticleFromPage.php


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