Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Propel Publishable Behavior Laravel Package

willdurand/propel-publishable-behavior

Propel behavior that adds publish/unpublish support to your models and queries. Provides isPublished(), publish()/unpublish(), optional publication timeframes (start/end), and query filters to include/exclude unpublished records or fetch currently active publications.

View on GitHub
Deep Wiki
Context7

PublishableBehavior

Build Status

The PublishableBehavior is designed to quickly add publish/unpublish features to your model.

Installation

Install the behavior in your project, the recommended way is to use Composer:

{
    "require": {
        "willdurand/propel-publishable-behavior": "dev-master"
    }
}

Add the following line to your propel.ini or build.properties configuration file:

propel.behavior.publishable.class = vendor.willdurand.propel-publishable-behavior.src.PublishableBehavior

Note: vendor.willdurand.propel-publishable-behavior.src is the path of the behavior in dot-path notation.

Usage

ActiveRecord API

Returns true if the object is published, false otherwise:

isPublished()

Mark an object as published:

publish(PropelPDO $con = null)

Mark an object as not published:

unpublish(PropelPDO $con = null)

Has publication frame started ?

hasPublicationEnded()

Has publication frame started ?

hasPublicationStarted()

ActiveQuery API

Include unpublished objects in the results set:

includeUnpublished()

Filter by objects not published exclusively:

filterUnpublished()

Filter by objects published exclusively:

filterPublished()

Filter by publication active

filterByPublicationActive($date = 'now')

Mark an object as published:

publish(PropelPDO $con = null)

Mark an object as not published:

unpublish(PropelPDO $con = null)

Parameters

<behavior name="publishable">
    <parameter name="is_published_column" value="is_published" />
    <parameter name="published_by_default" value="false" />
    <parameter name="include_unpublished" value="false" />
    <!-- timeframe support -->
    <parameter name="with_timeframe" value="false" />
    <parameter name="published_at_column" value="published_at" />
    <parameter name="published_until_column" value="published_until" />
    <!-- start and end value can be null -->
    <parameter name="require_start" value="false" />
    <parameter name="require_end" value="false" />
</behavior>

Note: Parameter include_unpublished allows you to exclude unpublished object from each query. It is setup to false by default. If you don't want to exclude unpublished items, you have to set it to true

Running tests

First of all, copy the phpunit.xml.dist to phpunit.xml.

If you did not install propel with composer, change PROPEL_DIR and PHING_DIR values to customize the include path. Customize autoloader by changing AUTOLOAD property.

then simply launch

$ vendor/bin/phpunit -c phpunit.xml

All green?

Credits

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui