tjventurini/articles

Articles for my blog.

This package's canonical repository appears to be gone and the package has been frozen as a result.

v0.1.10 2018-11-24 18:22 UTC

README

This package provides article functionality for my laravel based blog. It requires Backpack for Laravel so you will need to install it.

Installation

This package is available through packagist. Install it with the following command.

composer require tjventurini/articles

Migrations

You will need to run the migrations for the articles tables.

php artisan migrate

Config

You will need to publish the package configuraton.

php artisan vendor:publish --provider="Tjventurini\Articles\ArticlesServiceProvider" --tag=config

Views (optional)

The views are available through articles::view-name even though you don't publish them.

php artisan vendor:publish --provider="Tjventurini\Articles\ArticlesServiceProvider" --tag=views

Translations (optional)

The translations are available through articles::articles.key even though you don't publish them.

php artisan vendor:publish --provider="Tjventurini\Articles\ArticlesServiceProvider" --tag=lang

Seeding (optional)

The package provides seeding for the articles table.

artisan db:seed --class="Tjventurini\Articles\Database\Seeds\ArticlesSeeder"

Backpack

By now you should be ready to update the backpack admin panel. Open resources/views/vendor/backpack/base/inc/sidebar_content.blade.php and add the following line.

<li><a href="{{ backpack_url('article') }}"><i class="fa fa-file-text"></i> <span>{{ trans('articles::articles.menu_item') }}</span></a></li>

Articles makes use of tjventurini/tags package for tagging. To use it in backpack admin panel you also need to add the following line to sidebar_content.blade.php. Visit the tjventurini/tags repository for more information about tags.

<li><a href="{{ backpack_url('tag') }}"><i class="fa fa-tag"></i> <span>{{ trans('tags::tags.menu_item') }}</span></a></li>

The last thing to do is to publish the buttons needed for the backpack crud.

php artisan vendor:publish --provider="Tjventurini\Articles\ArticlesServiceProvider" --tag=backpack

Backpack Admin Panel

Configuration

Routes

/*
 |--------------------------------------------------------------------------
 | Tjventurini\Articles Routes
 |--------------------------------------------------------------------------
 |
 | In this file you will find all routes needed for this package to work in
 | in the backpack backend as well as the frontend.
 |
 */

Route::group([
    'prefix'     => config('backpack.base.route_prefix', 'admin'),
    'middleware' => ['web', config('backpack.base.middleware_key', 'admin')],
    'namespace'  => 'Tjventurini\Articles\App\Http\Controllers\Admin',
], function () {

    CRUD::resource('article', 'ArticleCrudController');

});

Route::group([
    'prefix' => config('articles.route_prefix', 'articles'),
    'middleware' => ['web'],
    'namespace'  => 'Tjventurini\Articles\App\Http\Controllers',
], function () {

    // show articles
    Route::get('/', 'ArticleController@index')->name('articles');

    // show article
    Route::get('/{slug}', 'ArticleController@article')->name('articles.article');

});

Route Prefix

/*
 |--------------------------------------------------------------------------
 | Route Prefix
 |--------------------------------------------------------------------------
 |
 | In this section you can define the route prefix of this package.
 |
 */

'route_prefix' => 'articles',

Views

/*
 |--------------------------------------------------------------------------
 | Views
 |--------------------------------------------------------------------------
 |
 | In this section you can define the views to show when the routes are 
 | called.
 |
 */

// view to show all articles
'view_articles' => 'articles::articles',

// view to show single article
'view_article' => 'articles::article',

Validation

/*
 |--------------------------------------------------------------------------
 | Validaton
 |--------------------------------------------------------------------------
 |
 | In this section you can change the validation rules for articles.
 |
 */

'rules' => [
    'name' => 'required|min:5|max:255',
    'slug' => 'unique:articles,slug',
    'image' => 'required|string',
    'intro' => 'required|min:50|max:255',
    'content' => 'required|min:255',
    'tags' => 'required',
],

Date Format

/*
 |--------------------------------------------------------------------------
 | Date Format
 |--------------------------------------------------------------------------
 |
 | In this section you can define the date format used for portfolios.
 |
 */

'date_format' => 'd.m.Y',

Editor / Content Type

/*
 |--------------------------------------------------------------------------
 | Editor / Content Type
 |--------------------------------------------------------------------------
 |
 | In this section you can select the editor to use in articles crud and
 | therefore some how define which type of content you want to use.
 | 
 | E.g you could decide to use simplemde editor and therefore change your
 | content type from html to markdown.
 |
 | Visit https://backpackforlaravel.com/docs/3.4/crud-fields for more 
 | information.
 |
 */

'editor' => 'wysiwyg',