PHP code example of unicodeveloper / laravel-leanpub

1. Go to this page and download the library: Download unicodeveloper/laravel-leanpub library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

unicodeveloper / laravel-leanpub example snippets


// Laravel 5: config/app.php

'providers' => [
    ...
    Unicodeveloper\Leanpub\LeanpubServiceProvider::class,
    ...
];

// Laravel 5: config/app.php

'aliases' => [
    ...
    'Leanpub' => Unicodeveloper\Leanpub\Facades\Leanpub::class,
    ...
]

/**
 *  Config file that a developer can insert the api key from Leanpub
 */
return [
    'API_KEY' => ''
];

use Unicodeveloper\Leanpub\Facades\Leanpub;
// or you can alias this in config/app.php like I mentioned initially above

Book Summary Data

Leanpub::getBook($book_slug)->id;
// e.g sample $book_slug is phptherightway returns 11146

Leanpub::getBook($book_slug)->about_the_book;
// e.g sample $book_slug is phptherightway returns

 <p><em>There is no canonical way to use PHP</em>. This website aims to introduce new PHP developers to some topics which they may not discover until it is too late, and aims to give seasoned pros some fresh ideas on those topics they’ve been doing for years without ever reconsidering. This ebook will also not tell you which tools to use, but instead offer suggestions for multiple options, when possible explaining the differences in approach and use-case.</p>\r\n
 <p>This is a living document and will continue to be updated with more helpful information and examples as they become available.</p>

Leanpub::getBook($book_slug)->title;
// e.g sample $book_slug is phptherightway returns PHP: The "Right" Way

Leanpub::getBook($book_slug)->total_copies_sold;
// e.g sample $book_slug is phptherightway returns 12056

Leanpub::getBook($book_slug)->word_count_published;
// e.g sample $book_slug is phptherightway returns 15849

Leanpub::getBook($book_slug)->author_string;
// e.g sample $book_slug is phptherightway returns "Phil Sturgeon and Josh Lockhart"

Leanpub::getBook($book_slug)->url;
// e.g sample $book_slug is phptherightway returns "http://leanpub.com/phptherightway"

Leanpub::getBook($book_slug)->title_page_url;
// e.g sample $book_slug is phptherightway returns "https://s3.amazonaws.com/titlepages.leanpub.com/phptherightway/original?1425544606"

Leanpub::getBook($book_slug)->minimum_price;
// e.g sample $book_slug is phptherightway returns 0.0

Leanpub::getBook($book_slug)->suggested_price;
// e.g sample $book_slug is phptherightway returns 0.0

Leanpub::getBook($book_slug)->image;
// e.g sample $book_slug is phptherightway returns "https://s3.amazonaws.com/titlepages.leanpub.com/phptherightway/medium?1425544606"

Leanpub::getBook($book_slug)->isFree;
// e.g sample $book_slug is phptherightway returns true

Leanpub::getBook($book_slug)->last_published_at;
// e.g sample $book_slug is phptherightway returns "2015-01-05T16:37:01Z"

Leanpub::getBook($book_slug)->meta_description;
// e.g sample $book_slug is phptherightway returns null

Leanpub::getBook($book_slug)->page_count_published;
// e.g sample $book_slug is phptherightway returns 70

Leanpub::getBook($book_slug)->subtitle;
// e.g sample $book_slug is phptherightway returns "Your guide to PHP best practices, coding standards,  and authoritative tutorials."

Leanpub::getBook($book_slug)->total_revenue;
// e.g sample $book_slug is phptherightway returns the price in revenue if the book is not free. For a book that is free like this, there is no `total_revenue` attribute

Leanpub::getBook($book_slug)->possible_reader_count;
// e.g sample $book_slug is phptherightway returns 12052

Sales Summary Data

Leanpub::getSalesInfo($book_slug)->book
Leanpub::getSalesInfo($book_slug)->url
Leanpub::getSalesInfo($book_slug)->total_author_royalties
Leanpub::getSalesInfo($book_slug)->total_book_royalties
Leanpub::getSalesInfo($book_slug)->num_happy_readers
Leanpub::getSalesInfo($book_slug)->num_happy_paid_purchases
Leanpub::getSalesInfo($book_slug)->num_refunded_purchases
Leanpub::getSalesInfo($book_slug)->unpaid_royalties
Leanpub::getSalesInfo($book_slug)->royalties_currently_due
Leanpub::getSalesInfo($book_slug)->royalties_due_on_first_of_next_month
Leanpub::getSalesInfo($book_slug)->paid_royalties

bash
php artisan vendor:publish