예제 #1
0
 public function postEdit()
 {
     $postData = $this->request()->postVariables();
     $newCategory = new Video();
     $newCategory->hydrateFromUnserialized($postData);
     $newCategory->saveChanges();
     $msg = new \stdClass();
     $msg->type = 'success';
     $msg->text = 'Video was successfully updated';
     Redirect::to('/' . $this->baseUri())->with('msg', $msg)->now();
 }
예제 #2
0
파일: Populate.php 프로젝트: qubes/support
 /**
  * Add videos
  *
  * @return $this
  */
 protected function _addVideos()
 {
     echo 'Adding Videos: ';
     $count = 0;
     $captionCount = 0;
     /** @var Category[] $categories */
     $categories = Category::collection();
     foreach ($categories as $category) {
         if (rand(1, 3)) {
             $videoTitles = $this->_getTitleArray('Video', rand(1, 3));
             foreach ($videoTitles as $videoTitle) {
                 $video = new Video();
                 $video->title = $videoTitle;
                 $video->slug = Strings::urlize($videoTitle);
                 $video->subTitle = $this->_getExampleContent(rand(3, 15));
                 $video->categoryId = $category->id();
                 $video->url = 'http://content.bitsontherun.com/videos/lWMJeVvV-364767.mp4';
                 $video->saveChanges();
                 // Add Annotations
                 $videoCaptionCount = rand(20, 30);
                 $i = 1;
                 $lastSecond = 0;
                 do {
                     $caption = new VideoCaption();
                     $caption->videoId = $video->id();
                     $caption->text = $this->_getExampleContent(rand(2, 6));
                     $caption->startSecond = $lastSecond;
                     $lastSecond += rand(3, 6);
                     $caption->endSecond = $lastSecond;
                     $caption->saveChanges();
                     $captionCount++;
                     $i++;
                 } while ($i <= $videoCaptionCount);
                 $count++;
             }
         }
     }
     echo sprintf('%d (%d Total Captions)%s', $count, $captionCount, PHP_EOL);
     return $this;
 }