2017 © Pedro Peláez
 

library posttype-management

Add or remove a simple posttype configuration to your Laravel application.

image

ngiraud/posttype-management

Add or remove a simple posttype configuration to your Laravel application.

  • Friday, July 20, 2018
  • by ngiraud
  • Repository
  • 2 Watchers
  • 1 Stars
  • 11 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 38 % Grown

The README.md

PostType Management

This package allows you to add or remove a simple "posttype" configuration to your Laravel application., (*1)

Installation

Prerequisites

  • This package can be used in Laravel 5.4 or higher

Step 1

You can install the package via composer:, (*2)

composer require ngiraud/posttype-management

Step 2

In Laravel 5.5 the service provider will automatically get registered. In older versions just add the service provider in the config/app.php file:, (*3)

'providers' => [
    // ...
    NGiraud\PostType\PostTypeServiceProvider::class,
];

Usage

Create a post type

This command will create a model, resource controller, migration and factory into your Laravel project., (*4)

It will also add a route in the routes/web.php file., (*5)

php artisan posttype:create MYPOSTTYPE [-m|--migrate] [--ctrl-folder=MYFOLDER]

If you want to specify a custom path to your Controller directory inside the App/Http, you can use:, (*6)

php artisan posttype:create MYPOSTTYPE --ctrl-folder=MYFOLDER

The route will be namespaced with the folder name., (*7)

If you want to migrate the generated migration instantly:, (*8)

php artisan posttype:create MYPOSTTYPE -m

Remove a post type

This command will remove the model, resource controller, migration and factory from your Laravel project., (*9)

php artisan posttype:remove MYPOSTTYPE

!!! The associated route will not be removed !!!, (*10)

Columns

The default columns added to a post type are:, (*11)

$table->increments('id');
$table->unsignedInteger('user_id');
$table->unsignedInteger('parent_id')->nullable();
$table->string('name');
$table->string('slug');
$table->unsignedTinyInteger('status');
$table->text('excerpt')->nullable();
$table->longText('content')->nullable();
$table->timestamp('published_at')->nullable();
$table->timestamps();
$table->softDeletes();

The package uses softDeletes columns., (*12)

The user_id column is automatically saved in the model boot event saving with the authenticated user id., (*13)

The published_at column is automatically saved as well as the user_id if the status is published., (*14)

Default comportment

Post types queries have a global scope to only fetch published data., (*15)

A relationship exists between a user and the posttype called owner(). Two relationships exist between a posttype parent and a posttype children : * The first one is parent(); * The second one is children();, (*16)

A public function "rules" exists, you can override it if you want., (*17)

To add another status you just have to add a constant in the model called STATUS_MYNEWSTATUS :, (*18)

Credits

  • Nicolas Giraud

The Versions

12/02 2018

1.0.3

1.0.3.0 https://github.com/ngiraud/posttype-management

Add or remove a simple posttype configuration to your Laravel application.

  Sources   Download

MIT

The Requires

 

by Nicolas Giraud

wordpress laravel posttype ngiraud

12/02 2018

1.0.2

1.0.2.0 https://github.com/ngiraud/posttype-management

Add or remove a simple posttype configuration to your Laravel application.

  Sources   Download

MIT

The Requires

 

by Nicolas Giraud

wordpress laravel posttype ngiraud