/** * Composer for updating a course * @param View $view */ public function compose(View $view) { $course = $view->getData()['course']; $empty_link = new Link(['link' => "", 'name' => ""]); $empty_link->id = 0; $links = \Link::getAllLinks($course); $length = count($links) > 0 ? $links[count($links) - 1]->id + 1 : 1; \JavaScript::put(['links' => $length]); $view->with('empty_link', $empty_link); $view->with('images', \Image::listImages($course)); $view->with('videos', \Video::listVideos($course)); $view->with('ebooks', \Ebook::listEbooks($course)); $view->with('links', $links); $view->with('body', \Resource::getCourseBody($course)); }
/** * Composer for showing a course * @param View $view */ public function compose(View $view) { $course = $view->getData()['course']; $view->with('course_categories', \Category::getCourseCategories($course)); $view->with('images', \Image::listImagesWithCleanPath($course)); $view->with('videos', \Video::listVideosWithCleanPath($course)); $view->with('ebooks', \Ebook::listEbooksWithCleanPath($course)); $view->with('links', \Link::listLinksWithNames($course)); $view->with('created_at', \MyCarbon::format($course->created_at->diffForHumans())); $view->with('course_user', $course->user); $view->with('count_likes', \Course::countLikes($course)); $view->with('count_dislikes', \Course::countDislikes($course)); if (Auth::check()) { \JavaScript::put(['star_index' => \Course::getLikeRating($course, Auth::user())]); } }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Ebook::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
/** * Delete a e-book from the server that has been added * as a content to a specified course * * @param Course $course * @param DeleteResourceRequest $request * @return \Illuminate\Http\JsonResponse */ public function deleteCourseEbook(Course $course, DeleteResourceRequest $request) { \Ebook::deleteEbooks($course, $request->input('resources')); return response()->json(['result' => true]); }
<?php require_once './src/book.php'; require_once './src/ebook.php'; $book1 = new Book("Tytul", "Autor", 54.66, 54345654); $book2 = new Book("Tytul2", "Autor2", 58.66, 54945654); $book1->printBookInfo(); $book2->printBookInfo(); $book1 = new Ebook("Tytul", "Autor", 54.66, 54345654, 300); $book1->printBookInfo();
function requireDefaultRecords() { parent::requireDefaultRecords(); $ebook = DataObject::get_one('Ebook', "\"Title\" = 'Silhouetted against the moon'"); if (!($ebook && $ebook->exists())) { $ebook = new Ebook(); $ebook->Title = 'Silhouetted against the moon'; $ebook->Summary = <<<HTML \t\t\t<p>A frightful product that will keep you on the edge of your seat!</p> \t\t\t<p>Cover <a href="http://www.sxc.hu/photo/991793">image</a> courtesy of <a href="http://www.sxc.hu/profile/nazreth" target="_blank">nazreth</a> on <a href="http://www.sxc.hu/" target="_blank">sxc.hu</a></p> HTML; $coverPhoto = DataObject::get_one('CoverPhoto', "\"Name\" = 'silhouetted-against-the-moon.png'"); if (!($coverPhoto && $coverPhoto->exists())) { $uploadfolder = Folder::findOrMake("Uploads"); $command = "cp ../payment-test/templates/Images/silhouetted-against-the-moon.png ../" . $uploadfolder->Filename; `{$command}`; $coverPhoto = new CoverPhoto(array('ClassName' => 'CoverPhoto')); $coverPhoto->Name = 'silhouetted-against-the-moon.png'; $coverPhoto->Title = 'silhouetted-against-the-moon'; $coverPhoto->Filename = 'assets/Uploads/silhouetted-against-the-moon.png'; $coverPhoto->ParentID = $uploadfolder->ID; $coverPhoto->OwnerID = Member::currentUserID(); $coverPhoto->write(); } $file = DataObject::get_one('EbookFile', "\"Name\" = 'silhouetted-against-th-moon.pdf'"); if (!($file && $file->exists())) { $uploadfolder = Folder::findOrMake("Uploads"); $command = "cp ../payment-test/templates/Images/silhouetted-against-th-moon.pdf ../" . $uploadfolder->Filename; `{$command}`; $file = new EbookFile(array('ClassName' => 'EbookFile')); $file->Name = 'silhouetted-against-th-moon.pdf'; $file->Title = 'silhouetted-against-th-moon'; $file->Filename = 'assets/Uploads/silhouetted-against-th-moon.pdf'; $file->ParentID = $uploadfolder->ID; $file->OwnerID = Member::currentUserID(); $file->write(); } $ebook->CoverPhotoID = $coverPhoto->ID; $ebook->FileID = $file->ID; $ebook->Amount->Amount = '5.99'; $ebook->Amount->Currency = 'USD'; $ebook->write(); $author = DataObject::get_one('Author', "\"Name\" = 'Michael Lorenzo'"); if (!($author && $author->exists())) { $author = new Author(array('ClassName' => 'Author')); $author->Name = 'Michael Lorenzo'; $author->Introduction = <<<HTML <p>Hi everyone! =) Thank you for viewing my gallery. My images are for free and I would love to see your projects or send me a link to your website so that I can see where you used nazreth's photos. It's a pleasure to see your artworks and it would inspire me to come up with more useful images. =)<br /><br />Thanks again and enjoy viewing my gallery! =)</p> HTML; $author->write(); } $ebook->Authors()->add($author); DB::alteration_message('payable Ebook example \'Silhouetted against the moon\'', 'created'); } }
/** * Add a new resources for the course. * * @param Course $course * @param array $parametars */ private function checkForResources(Course $course, array $parametars) { if (isset($parametars['images'])) { \Image::addImages($course, $parametars['images']); } if (isset($parametars['videos'])) { \Video::addVideos($course, $parametars['videos']); } if (isset($parametars['ebooks'])) { \Ebook::addEbooks($course, $parametars['ebooks']); } if (isset($parametars['links'])) { \Link::syncLinks($course, $parametars['links']); } }