Buffalo Eats Online API Documentation

MenuItem extends Model
in package

Menu item model for individual food/drink items.

Tags
author

J.J. Johnson visionquest716@gmail.com

copyright

2026 VisionQuestServices LLC

Table of Contents

Properties

$db  : PDO
$fillable  : array<string|int, mixed>
$primaryKey  : string
$table  : string

Methods

__construct()  : mixed
Initialize model with database connection.
all()  : array<string|int, mixed>
Get all records from the table.
bulkCreate()  : int
Bulk create menu items from a spreadsheet import.
clearAllSpecials()  : int
Clear all specials for a business.
count()  : int
Count records matching optional conditions.
create()  : int
Create a new record.
delete()  : bool
Delete a record by primary key.
filterByTags()  : array<string|int, mixed>
Filter menu items by tag slugs for a business.
find()  : array<string|int, mixed>|null
Find a record by primary key.
findBy()  : array<string|int, mixed>|null
Find a record by a specific field value.
findBySlug()  : array<string|int, mixed>|null
Find a menu item by its slug within a business.
generateSlug()  : string
Generate a URL-friendly slug from an item name, unique per business.
getDailySpecials()  : array<string|int, mixed>
Get daily specials for a business.
getDb()  : PDO
Get the underlying PDO connection.
getForBusiness()  : array<string|int, mixed>
Get all menu items for a business.
getForCategory()  : array<string|int, mixed>
Get menu items for a specific category.
getMenuGroupedByCategory()  : array<string|int, mixed>
Get the full menu grouped by category for storefront display.
paginate()  : array<string|int, mixed>
Paginate records matching conditions.
query()  : PDOStatement
Execute a raw SQL query with parameter binding.
searchByName()  : array<string|int, mixed>
Search menu items by name for a business.
setSpecialForAll()  : int
Set daily special status for all items in the business.
setSpecialForCategory()  : int
Set daily special status for all items in a category.
toggleAvailability()  : bool
Toggle the availability of a menu item.
toggleDailySpecial()  : bool
Toggle the daily special flag of a menu item.
update()  : bool
Update a record by primary key.
updateSortOrder()  : void
Update sort order for multiple items.
where()  : array<string|int, mixed>
Find records matching conditions.
filterFillable()  : array<string|int, mixed>
Filter data to only include fillable fields.

Properties

$db

protected PDO $db

Database connection

$fillable

protected array<string|int, mixed> $fillable = ['business_id', 'category_id', 'name', 'slug', 'description', 'special_notes', 'price', 'availability', 'spice_level', 'prep_time', 'is_available', 'is_daily_special', 'in_store', 'sort_order']

Mass-assignable fields

$primaryKey

protected string $primaryKey = 'id'

Primary key column

$table

protected string $table = 'menu_items'

Database table name

Methods

__construct()

Initialize model with database connection.

public __construct() : mixed

all()

Get all records from the table.

public all([string $orderBy = 'id' ][, string $direction = 'ASC' ]) : array<string|int, mixed>
Parameters
$orderBy : string = 'id'

Column to order by

$direction : string = 'ASC'

Sort direction (ASC or DESC)

Return values
array<string|int, mixed>

bulkCreate()

Bulk create menu items from a spreadsheet import.

public bulkCreate(int $businessId, array<string|int, mixed> $items) : int
Parameters
$businessId : int

Business ID

$items : array<string|int, mixed>

Array of item data arrays

Return values
int

Number of items created

clearAllSpecials()

Clear all specials for a business.

public clearAllSpecials(int $businessId) : int
Parameters
$businessId : int
Return values
int

count()

Count records matching optional conditions.

public count([array<string|int, mixed> $conditions = [] ]) : int
Parameters
$conditions : array<string|int, mixed> = []

Associative array of field => value pairs

Return values
int

create()

Create a new record.

public create(array<string|int, mixed> $data) : int
Parameters
$data : array<string|int, mixed>

Associative array of field => value pairs

Return values
int

The ID of the newly created record

delete()

Delete a record by primary key.

public delete(int $id) : bool
Parameters
$id : int

Primary key value

Return values
bool

filterByTags()

Filter menu items by tag slugs for a business.

public filterByTags(int $businessId, array<string|int, mixed> $tagSlugs) : array<string|int, mixed>
Parameters
$businessId : int

Business ID

$tagSlugs : array<string|int, mixed>

Array of tag slugs

Return values
array<string|int, mixed>

find()

Find a record by primary key.

public find(int $id) : array<string|int, mixed>|null
Parameters
$id : int

Primary key value

Return values
array<string|int, mixed>|null

findBy()

Find a record by a specific field value.

public findBy(string $field, mixed $value) : array<string|int, mixed>|null
Parameters
$field : string

Column name

$value : mixed

Value to match

Return values
array<string|int, mixed>|null

findBySlug()

Find a menu item by its slug within a business.

public findBySlug(int $businessId, string $slug) : array<string|int, mixed>|null
Parameters
$businessId : int

Business ID

$slug : string

Item slug

Return values
array<string|int, mixed>|null

generateSlug()

Generate a URL-friendly slug from an item name, unique per business.

public generateSlug(string $name, int $businessId[, int|null $excludeId = null ]) : string
Parameters
$name : string

Item name

$businessId : int

Business ID

$excludeId : int|null = null

Item ID to exclude (for updates)

Return values
string

getDailySpecials()

Get daily specials for a business.

public getDailySpecials(int $businessId) : array<string|int, mixed>
Parameters
$businessId : int

Business ID

Return values
array<string|int, mixed>

getDb()

Get the underlying PDO connection.

public getDb() : PDO
Return values
PDO

getForBusiness()

Get all menu items for a business.

public getForBusiness(int $businessId[, string|null $orderBy = null ][, int $limit = 0 ][, int $offset = 0 ]) : array<string|int, mixed>
Parameters
$businessId : int

Business ID

$orderBy : string|null = null

Column to order by

$limit : int = 0
$offset : int = 0
Return values
array<string|int, mixed>

getForCategory()

Get menu items for a specific category.

public getForCategory(int $categoryId) : array<string|int, mixed>
Parameters
$categoryId : int

Category ID

Return values
array<string|int, mixed>

getMenuGroupedByCategory()

Get the full menu grouped by category for storefront display.

public getMenuGroupedByCategory(int $businessId) : array<string|int, mixed>
Parameters
$businessId : int

Business ID

Return values
array<string|int, mixed>

Associative array keyed by category name

paginate()

Paginate records matching conditions.

public paginate(array<string|int, mixed> $conditions, int $page, int $perPage[, string $orderBy = 'id' ][, string $direction = 'ASC' ]) : array<string|int, mixed>
Parameters
$conditions : array<string|int, mixed>

Associative array of field => value pairs

$page : int

Current page number (1-based)

$perPage : int

Records per page

$orderBy : string = 'id'

Column to order by

$direction : string = 'ASC'

Sort direction (ASC or DESC)

Return values
array<string|int, mixed>

Pagination result with data, total, page, per_page, total_pages

query()

Execute a raw SQL query with parameter binding.

public query(string $sql[, array<string|int, mixed> $params = [] ]) : PDOStatement
Parameters
$sql : string

SQL query string

$params : array<string|int, mixed> = []

Bound parameters

Return values
PDOStatement

searchByName()

Search menu items by name for a business.

public searchByName(int $businessId, string $query) : array<string|int, mixed>
Parameters
$businessId : int

Business ID

$query : string

Search query

Return values
array<string|int, mixed>

setSpecialForAll()

Set daily special status for all items in the business.

public setSpecialForAll(int $businessId, bool $isSpecial) : int
Parameters
$businessId : int
$isSpecial : bool
Return values
int

Number of affected rows

setSpecialForCategory()

Set daily special status for all items in a category.

public setSpecialForCategory(int $businessId, int $categoryId, bool $isSpecial) : int
Parameters
$businessId : int
$categoryId : int
$isSpecial : bool
Return values
int

Number of affected rows

toggleAvailability()

Toggle the availability of a menu item.

public toggleAvailability(int $id) : bool
Parameters
$id : int

Menu item ID

Return values
bool

toggleDailySpecial()

Toggle the daily special flag of a menu item.

public toggleDailySpecial(int $id) : bool
Parameters
$id : int

Menu item ID

Return values
bool

update()

Update a record by primary key.

public update(int $id, array<string|int, mixed> $data) : bool
Parameters
$id : int

Primary key value

$data : array<string|int, mixed>

Associative array of field => value pairs

Return values
bool

updateSortOrder()

Update sort order for multiple items.

public updateSortOrder(array<string|int, mixed> $order) : void
Parameters
$order : array<string|int, mixed>

Associative array of item_id => sort_order

where()

Find records matching conditions.

public where(array<string|int, mixed> $conditions[, string $orderBy = 'id' ][, string $direction = 'ASC' ]) : array<string|int, mixed>
Parameters
$conditions : array<string|int, mixed>

Associative array of field => value pairs

$orderBy : string = 'id'

Column to order by

$direction : string = 'ASC'

Sort direction

Return values
array<string|int, mixed>

filterFillable()

Filter data to only include fillable fields.

protected filterFillable(array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
$data : array<string|int, mixed>

Input data

Return values
array<string|int, mixed>

Filtered data


        
On this page

Search results