2017 © Pedro Peláez
 

library publish-dates

A simple Laravel package to handle published date scopes.

image

developerswarehouse/publish-dates

A simple Laravel package to handle published date scopes.

  • Sunday, January 21, 2018
  • by simonhughes
  • Repository
  • 0 Watchers
  • 0 Stars
  • 37 Installations
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 37 % Grown

The README.md

Publish Dates for your eloquent models

I have found with my recent projects, that I'm using the same functionality for publishing content. So, I made a package., (*1)

Installation

composer require developerswarehouse/publish-dates

How it works

Say, you're working with an Article model, we might want to use publishing dates to manage the displaying of the content., (*2)

On your models, you'll want to add two fields for storing the publish dates., (*3)

publish_from(timestamp:nullable)
publish_to(timestamp:nullable)

If you want to change the name of the fields you can change the property in your model., (*4)

protected $publishFields = [
    'publish_from',
    'publish_to',
];

Or; overwrite the functions for getPublishedFrom and getPublishedOn with the field name alternatives., (*5)

Usage

On your Laravel models, add the trait for publish dates., (*6)

use DevelopersWarehouse\PublishDates\PublishDates;

class Article extends Model
{
    use PublishDates;
}

Then, in your controller you can filter the Articles by:, (*7)

public function index() {
    $articles = Article::published()->get();

    return view('articles.index', compact("articles"));
}

If you want to fetch Articles that are yet to be published, you can use., (*8)

$articles = Article::unpublished()->get();

Further Developments

I will be looking to extend the functionality to make this more versatile and something you might want to use., (*9)

The Versions

21/01 2018

dev-master

9999999-dev https://developerswarehouse.co.uk

A simple Laravel package to handle published date scopes.

  Sources   Download

MIT

The Requires

 

by Simon Hughes

laravel package dates publishing

21/01 2018

1.0.3

1.0.3.0 https://developerswarehouse.co.uk

A simple Laravel package to handle published date scopes.

  Sources   Download

MIT

The Requires

 

by Simon Hughes

laravel package dates publishing

14/01 2018

1.0.2

1.0.2.0 https://developerswarehouse.co.uk

A simple Laravel package to handle published date scopes.

  Sources   Download

MIT

The Requires

 

by Simon Hughes

laravel package dates publishing

22/12 2017

dev-develop

dev-develop https://onpoint.studio

A simple Laravel package to handle published date scopes.

  Sources   Download

MIT

The Requires

 

by Simon Hughes

laravel package dates publishing

13/12 2017

1.0.1

1.0.1.0 https://bitbucket.org/developerswarehouse/publish-dates

A simple Laravel package to handle published date scopes.

  Sources   Download

MIT

The Requires

 

by Simon Hughes

12/12 2017

1.0

1.0.0.0 https://bitbucket.org/developerswarehouse/publish-dates

A simple Laravel package to handle published date scopes.

  Sources   Download

MIT

The Requires

 

by Simon Hughes