Listings

You can create, edit, publish, un-publish or delete listings from the dashboard.

The Listing Object

The listing object that is accessed via Eloquent queries provides a variety of useful methods for inspecting the listing's attributes and relationships:

// Access the listings's author...
$listing->author : \App\Models\User

// Get all of the listing's tags...
$listing->tags : \Illuminate\Database\Eloquent\Collection

// Get all of the listing's conversations...
$listing->conversations : \Illuminate\Database\Eloquent\Collection

// Filter listings by published...
$listing->published() : \Illuminate\Database\Eloquent\Builder

// Filter listings by a given tag slug...
$listing->tag($tag) : \Illuminate\Database\Eloquent\Builder

// Mark the listing as published...
$listing->markAsPublished() : void

// Mark the listing as unpublished...
$listing->markAsUnPublished() : void

// Determine if the listing is published...
$listing->isPublished() : bool

// Determine if the listing is a draft...
$listing->isDraft() : bool

Inspecting User Listings

Information about a user's listings may be accessed via the methods provided by the Marketplaceful\Traits\MarketplacefulAuthenticatable trait. This trait provides a variety of helpful methods that allow you to inspect a user's listings:

// Access all of a user's authored listings...
$user->listings : Illuminate\Database\Eloquent\Collection

Actions

The logic executed to satisfy listing management requests can be found within action classes.

Listing Creation

The Marketplaceful\Actions\CreateListing action class is responsible for validating the input and creating the listing. This action receives the currently authenticated $user and an array of $input containing all input from the incoming request.

// Validate and create a new listing...
$listing = (new Marketplaceful\Actions\CreateListing)->create($user, $input);

Listing Update

The Marketplaceful\Actions\UpdateListing action class is responsible for validating the input and updating the listing. This action receives the currently authenticated $user, an array of $input containing all input from the incoming request, and a Marketplaceful\Models\Listing instance.

// Validate and update the given listing...
(new Marketplaceful\Actions\UpdateListing)->update($user, $listing, $input);

Listing Deletion

The Marketplaceful\Actions\DeleteListing action class is responsible for validating the input and deleting the listing. This action receives the currently authenticated $user and a Marketplaceful\Models\Listing instance.

// Delete the given listing...
(new Marketplaceful\Actions\DeleteListing)->delete($user, $listing);

Listing Publish

The Marketplaceful\Actions\PublishListing action class is responsible for validating the input and publishing the listing. This action receives the currently authenticated $user and a Marketplaceful\Models\Listing instance.

// Publish the given listing...
(new Marketplaceful\Actions\PublishListing)->publish($user, $listing);

Listing Un-publish

The Marketplaceful\Actions\UnPublishListing action class is responsible for validating the input and un-publishing the listing. This action receives the currently authenticated $user and a Marketplaceful\Models\Listing instance.

// Un-publish the given listing...
(new Marketplaceful\Actions\UnPublishListing)->unpublish($user, $listing);