2017 © Pedro Peláez
 

library larablog

Larablog is simple but yet powerful Blog package for the Laravel 5.6 and up.

image

gorankrgovic/larablog

Larablog is simple but yet powerful Blog package for the Laravel 5.6 and up.

  • Tuesday, June 26, 2018
  • by gorankrgovic
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Larablog

A package for easier maintenance of the blog (or news) articles., (*1)

Installation, Configuration and Usage

Via Composer:, (*2)

$ composer require gorankrgovic/larablog

Configuration

Once you install the package, it should be automatically discovered by the Laravel. To check this, in your terminal simply run the:, (*3)

$ php artisan

Once you run the command, you shoul dbe able to find all larablog commands available., (*4)

First step is to publish the vendor files. In this case only the config file., (*5)

$ php artisan vendor:publish --tag="larablog"

After you inspect the configuration file, it depends on your skills :). I recommend running the:, (*6)

$ php artisan larablog:setup

The above command will install models, make the migration file and add a trait to your User model., (*7)

After the setup please run the migration command, (*8)

$ php artisan migrate

Which will create the tables for this package: articles and categories. (you can change the names in your config file)., (*9)

Once the tables are ready, please make sure to seed the initial category., (*10)

$ php artisan larablog:seeder

The above command will create a seeder class. After you created a seeder, please run the, (*11)

$ composer du

And then run the seeder, (*12)

$ php artisan db:seed --class=LarablogSeeder

Thats. basically it., (*13)

Usage

Create your controller resource or whatever and then simply:, (*14)

$article = new Article([
            'title' => 'This is my title',
            'slug' => 'this-is-my-slug',
            'excerpt' => 'This is my excerpt',
            'content' => 'This is my content',
            'is_featured' => false,
            'status' => 'publish',
            'publish_at' => Carbon::now()
]);

// associate the user
$article->associateUser(1);
// save the article
$article->save();

// attach the category
$article->attachCategory('uncategorized'); // name or the ID

// or multiple categories
$article->attachCategories([1, 2, 3]); // names or ID's

To get the article you can, for example:, (*15)

$article = Article::find(1);

// get the categories (cacheable)
$article->getCategories();

Or you can fetch all articles from a user, (*16)

$user = User::find(1);

$articles = $user->getArticles();

// or
$articles = $user->getArticlesPaginated(20);

// or
$articles = $user->articles()->get();

Also you can use provided scopes, (*17)


$articles = Article::whereCategoriesAre([1, 2, 3])->get(); // pass an array of IDs // or $articles = Article::whereCategoryIs(1)->get(); // pass an id

Facade

Larablog provides you with convenient helpers to make your life easier, (*18)

use Gorankrgovic\Larablog\Facades\Larablog;

// ... and then in your methods...

// to generate a unique slug which will append number at the end of the slug if the same slug exists
$slug = Larablog::slug($title);

// to convert string to paragraph delimited text
$text = Larablog::autop($content);

// to generate the excerpt
$excerpt = Larablog::excerpt($content);

// to just sanitize the title and to get a slug
$slug = Larablog::sanitize_title($title);

Basically thats it..., (*19)

The Versions

26/06 2018

dev-master

9999999-dev https://github.com/gorankrgovic/larablog

Larablog is simple but yet powerful Blog package for the Laravel 5.6 and up.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel blog larablog

26/06 2018

v1.0.1

1.0.1.0 https://github.com/gorankrgovic/larablog

Larablog is simple but yet powerful Blog package for the Laravel 5.6 and up.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel blog larablog