Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

A Laravel package for interacting with the Struct PIM API.

Notifications You must be signed in to change notification settings

signifly/laravel-struct-archived

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚠️ WIP - Work in Progress

This package is a work in progress. Please do not use it in production yet. The features are not stable and the API might change.


Laravel Logo

Build Status Total Downloads Latest Stable Version License

Laravel Struct

This package provides a way to interact with the Struct PIM API in your Laravel application using a fluent interface.

A more complete documentation can be found here.

Installation

Requires PHP 8.1+

Install the package via composer:

composer require signifly/laravel-struct

The package will be registered automatically.

Publishing files

You can publish the config file with:

php artisan vendor:publish --tag="config"

Environment variables

Don't forget to add the following environment variables to your .env file:

STRUCT_URL=
STRUCT_TOKEN=

Usage

This package was developed with simplicity in mind. It provides a fluent interface to interact with the Struct API, in the most Laravelish style.

It is plug-and-play, and does not require any additional configuration.

Here is the example of a controller that uses the package:

use Signifly\Struct\Api\Products\Product as StructProduct;

...

// Get all products
public function index()
{
    return StructProduct::all(limit: 100);
}

// Get a single product
public function show(int $id)
{
    return StructProduct::show(id: $id);
}

public function store()
{
    return StructProduct::create(
        productStructureUid: Str::uuid(),
        variationDefinitionUid: Str::uuid(),
        primaryCategoryId: 1,
        categoryIds: ['1', '2'],
        values: ProductValueSchema::make(
            name: [
                ProductNameSchema::make(
                    content: 'The best Samsung TV ever produced',
                ),
                ProductNameSchema::make(
                    content: 'Det allerbedste TV Samsung har at byde på',
                    code: 'da-DK',
                ),
                ProductNameSchema::make(
                    content: 'A melhor TV Samsung já produzida',
                    code: 'pt-BR',
                ),
                ProductNameSchema::make(
                    content: 'La mejor TV Samsung que se ha producido',
                    code: 'es-ES',
                ),
                ProductNameSchema::make(
                    content: 'La migliore TV Samsung mai prodotta',
                    code: 'it-IT',
                ),
                ProductNameSchema::make(
                    content: 'De beste Samsung TV ooit geproduceerd',
                    code: 'nl-NL',
                ),
                ProductNameSchema::make(
                    content: 'La meilleure TV Samsung jamais produite',
                    code: 'fr-FR',
                ),
            ],
            primaryImage: 3013,
            extraImage: [2566, 5155, 5664],
        ),
    );
}

** Note that you can rename the package if it conflicts with an existing Laravel Model.

Entities

These are the following entities available in this package:

  • Product
  • Category
  • Languages