2017 © Pedro Peláez
 

library laravel-publishable

Toggle the published state of your Eloquent models easily

image

pawelmysior/laravel-publishable

Toggle the published state of your Eloquent models easily

  • Tuesday, June 26, 2018
  • by PawelMysior
  • Repository
  • 1 Watchers
  • 4 Stars
  • 64 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 56 % Grown

The README.md

Publishable

Toggle the published state of your Eloquent models easily., (*1)

Installation

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

composer require pawelmysior/laravel-publishable

Preparation

To start you need to add a published_at nullable timestamp column to your table., (*3)

Put this in your table migration:, (*4)

$table->timestamp('published_at')->nullable();

Now use the trait on the model, (*5)

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use PawelMysior\Publishable\Publishable;

class Post extends Model
{
    use Publishable;
}

Usage

You can now use those features:, (*6)

// Get only published posts
Post::published()->get();

// Get only unpublished posts
Post::unpublished()->get();

// Check if the post is published
$post->isPublished();

// Check if the post is unpublished
$post->isUnpublished();

// Publish the post
$post->publish();

// Unpublish the post
$post->unpublish();

A post is considered published when the published_at is not null and in the past., (*7)

A post is considered unpublished when the published_at is null or in the future., (*8)

License

The MIT License (MIT). Please see License File for more information., (*9)

The Versions

26/06 2018

dev-master

9999999-dev

Toggle the published state of your Eloquent models easily

  Sources   Download

MIT

The Requires

 

The Development Requires

by Pawel Mysior

laravel eloquent trait

07/11 2017

1.1.1

1.1.1.0

Toggle the published state of your Eloquent models easily

  Sources   Download

MIT

The Requires

 

The Development Requires

by Pawel Mysior

laravel eloquent trait

07/11 2017

1.1.0

1.1.0.0

Toggle the published state of your Eloquent models easily

  Sources   Download

MIT

The Requires

 

The Development Requires

by Pawel Mysior

laravel eloquent trait

30/07 2017

1.0.0

1.0.0.0

Toggle the published state of your Eloquent models easily

  Sources   Download

MIT

The Requires

 

The Development Requires

by Pawel Mysior

laravel eloquent trait