⚡
Laravel Haystack
View Code On GithubEdit Docs
  • 🎯Getting Started
    • Introduction
    • How It Works
    • Installation
    • Usage
    • Configuration
    • Callback Events
  • 🛰️Cool Features
    • Shared Data
    • Shared Models
    • Long Delays & Pauses
    • Appending & Prepending Jobs
    • Chunking Jobs
  • 🗺️Next Up
    • Allowing Failed Jobs
    • Global Middleware
    • Connection, Queue & Delay
    • Naming Haystacks
    • Before Saving Hook
    • Custom Options
  • 🧼Cleanup
    • Deleting Stale Haystacks
    • Deleting Specific Haystacks
    • Clearing All Haystacks
  • 🛣️Finish
    • Support
    • Star On Github
    • Edit Documentation
Powered by GitBook
On this page
  1. Next Up

Custom Options

Every Haystack has a HaystackOptions class stored against it. This class is serialized and stored in the database and contains various configuration variables used when processing jobs. You may wish to specify a new custom option by using the setOption method when building Haystacks.

<?php

Haystack::build()
    ->addJob(new RecordPodcast)
    ->setOption('someCustomOption', 'option-value')
    ->dispatch();

Since the options are serialized into one column, it's recommended that you only store small amounts of data inside this class, and make sure what you are storing can be serialized.

Inside your jobs, you can use the getHaystackOptions or getHaystackOption method to retrieve the options.

<?php

$this->getHaystackOptions(); // HaystackOptions.php

$this->getHaystackOption('someCustomOption'); // "option-value"
PreviousBefore Saving HookNextDeleting Stale Haystacks

Last updated 2 years ago

🗺️