當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。