當前位置: 首頁>>代碼示例>>PHP>>正文


PHP News::create方法代碼示例

本文整理匯總了PHP中app\models\News::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP News::create方法的具體用法?PHP News::create怎麽用?PHP News::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\models\News的用法示例。


在下文中一共展示了News::create方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: postNew

 public function postNew(Request $request)
 {
     //        dd($request);
     $this->validate($request, News::$rules);
     News::create($request->all());
     return redirect()->action('NewsController@getIndex');
 }
開發者ID:sasik-github,項目名稱:system.pro,代碼行數:7,代碼來源:NewsController.php

示例2: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $newses = [['title' => 'МИД Британии: Совет Безопасности ООН обсудит ответные меры на запуск ракеты КНДР', 'text' => 'КНДР в воскресенье запустила баллистическую ракету с космодрома "Сохэ". Глава МИД Великобритании назвал запуск "провокационным" и отметил, что Совет Безопасности ООН согласует коллективный ответ на испытания.'], ['title' => 'Китай обеспокоен возможным размещением ПРО США в Южной Корее', 'text' => 'Во внешнеполитическом ведомстве КНР подчеркнули, что позиция Китая по вопросу ПРО последовательна и ясна. Там отметили, что все страны, стремясь обеспечить свою безопасность, должны иметь в виду интересы в сфере безопасности других стран.']];
     foreach ($newses as $news) {
         \App\Models\News::create($news);
     }
 }
開發者ID:sasik-github,項目名稱:system.pro,代碼行數:12,代碼來源:NewsTableSeeder.php

示例3: create

 /**
  * 創建
  *
  * @param array $input
  * @return News
  * @throws GeneralException
  */
 public function create(array $input)
 {
     if ($id = News::create($input)) {
         return $id;
     }
     throw new GeneralException('There was a problem creating this news. Please try again.');
 }
開發者ID:qloog,項目名稱:laravel5-backend,代碼行數:14,代碼來源:NewsRepositoryEloquent.php

示例4: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('news')->delete();
     for ($i = 0; $i < 100; $i++) {
         News::create(['title' => 'Title ' . $i, 'meta_description' => 'meta desc ' . $i, 'views' => '1000', 'content' => 'Body ' . $i, 'user_id' => 1]);
     }
 }
開發者ID:aysenli,項目名稱:laravel5-backend,代碼行數:12,代碼來源:NewsTableSeeder.php

示例5: store

 /**
  * Store a newly created News in storage.
  *
  * @param CreateNewsRequest $request
  *
  * @return Response
  */
 public function store(CreateNewsRequest $request)
 {
     $input = $request->all();
     $news = News::create($input);
     Flash::message('News saved successfully.');
     return redirect(route('news.index'));
 }
開發者ID:alexlondon07,項目名稱:pms_laravel5,代碼行數:14,代碼來源:NewsController.php

示例6: run

 public function run()
 {
     // clear table
     News::truncate();
     News::create(['title' => 'Entry 1 Title', 'date' => Carbon::now(), 'published' => 1, 'text' => 'Entry 1 Text', 'photo' => '']);
     News::create(['title' => 'Entry 2 Title', 'date' => Carbon::now(), 'published' => 1, 'text' => 'Entry 2 Text', 'photo' => '']);
     News::create(['title' => 'Entry 3 Title', 'date' => Carbon::now(), 'published' => 1, 'text' => 'Entry 3 Text', 'photo' => '']);
     News::create(['title' => 'Entry 4 Title', 'date' => Carbon::now(), 'published' => 1, 'text' => 'Entry 4 Text', 'photo' => '']);
 }
開發者ID:nvchernov,項目名稱:tsargrad,代碼行數:9,代碼來源:NewsTableSeeder.php

示例7: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $newsFields = $this->doValidation($request, News::getValidatorRules());
     $newsFields["Story_Date"] = Carbon::parse($newsFields["Story_Date"]);
     $newsFields['Date_Created'] = Carbon::now();
     $newsModel = News::create($newsFields);
     $this->saveObjectRelation($request, $newsModel);
     return redirect(route('admin.news.index'))->with('flash', 'The News was created');
 }
開發者ID:ghosthels,項目名稱:ftproject,代碼行數:15,代碼來源:NewsController.php

示例8: run

 public function run()
 {
     News::truncate();
     $faker = Faker\Factory::create();
     $authorIds = User::lists('id');
     for ($i = 0; $i < 10; $i++) {
         News::create(['title' => $faker->word, 'desc' => $faker->sentence, 'image_url' => $faker->imageUrl($width = 640, $height = 480), 'share_url' => $faker->url, 'status' => $faker->randomElement(array(0, 1)), 'author_id' => $faker->randomElement($authorIds)]);
     }
 }
開發者ID:ShuvarthiDhar,項目名稱:tobacco,代碼行數:9,代碼來源:NewsTableSeeder.php

示例9: actionCreate

 public function actionCreate()
 {
     $model = new News();
     $login = new login();
     $imgLoad = new imgLoad();
     if (Yii::$app->user->identity->level > 1) {
         if ($model->load(Yii::$app->request->post()) && $model->create()) {
             if ($imgLoad->load(Yii::$app->request->post())) {
                 if ($imgLoad->file = UploadedFile::getInstance($imgLoad, 'file')) {
                     $imgLoad->img_load($model->id);
                     $model->save_id_img($imgLoad->id);
                 }
             }
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
             return $this->render('create', ['login' => $login, 'model' => $model, 'imgLoad' => $imgLoad]);
         }
     }
 }
開發者ID:Baron-fon-Kolt,項目名稱:yii2_black,代碼行數:19,代碼來源:NewsController.php

示例10: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $formdata = $request->all();
     $validator = Validator::make($formdata, News::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $absolute_path = public_path() . '/uploads/news';
     $folderPath = '/uploads/news/';
     if (!file_exists($absolute_path)) {
         try {
             if (!mkdir($absolute_path)) {
                 die('could not create folder');
             }
         } catch (Exception $e) {
             die('could not create folder');
         }
     }
     if (!is_null($request->file('filename'))) {
         $photofile = $request->file('filename');
         $filename = time() . '-' . $photofile->getClientOriginalName();
         $photofile->move(public_path() . '/uploads/news/', $filename);
         $photo = Image::make(public_path() . '/uploads/news/' . $filename);
         // $photo = Image::make($photofile);
         $photo->backup();
         $photo->fit(150, 100, function ($constraint) {
             $constraint->aspectRatio();
             $constraint->upsize();
         });
         $thumb = public_path() . '/uploads/news/small-' . $filename;
         $photo->save($thumb);
         $photo->reset();
         $photo->fit(550, 300, function ($constraint) {
             $constraint->aspectRatio();
             $constraint->upsize();
         });
         $thumb = public_path() . '/uploads/news/medium-' . $filename;
         $photo->save($thumb);
         $photo->reset();
         //replacing original
         $photo->fit(880, 450, function ($constraint) {
             $constraint->aspectRatio();
             // $constraint->upsize();
         });
         $photo->save(public_path() . '/uploads/news/' . $filename);
         $formdata['filename'] = $filename;
         $formdata['filepath'] = "/uploads/news/";
     }
     News::create($formdata);
     return Redirect::route('news.admin');
 }
開發者ID:danielchikaka,項目名稱:osh,代碼行數:56,代碼來源:NewsController.php

示例11: run

    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        DB::table('news')->delete();
        News::create(['author_id' => 1, 'app_id' => 'koala', 'content' => '歡迎訪問西郵Linux興趣小組內部交流平台Koala(考拉)。目前係統處於內測階段,上線的功能有:應用,消息,管理。
歡迎大家積極參與測試,我們期待你的反饋。', 'topic' => 'Koala']);
    }
開發者ID:xiyou-linuxer,項目名稱:cs-restful-api,代碼行數:11,代碼來源:NewsTableSeeder.php

示例12: store

 /**
  * Store a newly created News in storage.
  *
  * @param  NewsRequest  $request
  * @return Response
  */
 public function store(NewsRequest $request)
 {
     News::create(['title' => $request->title, 'published_at' => $request->published_at, 'description' => e($this->htmlEditor->parseHtml($request->description))]);
     Flash::success('News created successfully.');
     return redirect('/admin/news');
 }
開發者ID:TawsifKarim,項目名稱:ict-mbstu,代碼行數:12,代碼來源:NewsController.php


注:本文中的app\models\News::create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。