sohead/core

A core package for Sohead with laravel 5.8

This package's canonical repository appears to be gone and the package has been frozen as a result.


README

Install

composer require sohead/core

Configuration

Setup middle cors for api

Add to $middleware in Kernel

protected $middleware = [
  ...
  \Sohead\Core\Http\Middleware\Cors::class,
]

Publish config file

php artisan vendor:publish --provider="Sohead\Core\SoheadProvider"

Add database configuration

Add to config database

'connections' => [
    ...
    'sohead_core' => [
        'driver' => 'pgsql',
        'url' => env('DATABASE_URL'),
        'host' => env('DB_CORE_HOST', '127.0.0.1'),
        'port' => env('DB_CORE_PORT', '5432'),
        'database' => env('DB_CORE_DATABASE', 'forge'),
        'username' => env('DB_CORE_USERNAME', 'forge'),
        'password' => env('DB_CORE_PASSWORD', ''),
        'charset' => 'utf8',
        'prefix' => '',
        'prefix_indexes' => true,
        'schema' => 'public',
        'sslmode' => 'prefer',
    ],
]

Add to env

APP_ID=
FRONTEND_URL=
DB_CORE_HOST=
DB_CORE_PORT=
DB_CORE_DATABASE=
DB_CORE_USERNAME=
DB_CORE_PASSWORD=

SPF_API_KEY=
SPF_SECRET_KEY=

FACEBOOK_KEY=
FACEBOOK_SECRET=

GOOGLE_KEY=
GOOGLE_SECRET=

Add to function schedule in Kernel

$schedule->command('shopify:sync_collection_product')->everyFiveMinutes();

How to use

Route has been identified

Method URI Action Middleware
GET api/app/user Sohead\Core\Http\Controllers\Api\AppController@userInfo sohead.auth
GET api/shopify/auth_handle Sohead\Core\Http\Controllers\Api\ShopifyController@auth
POST api/shopify/charge Sohead\Core\Http\Controllers\Api\ShopifyController@charge sohead.auth
GET api/shopify/charge_handle Sohead\Core\Http\Controllers\Api\ShopifyController@chargeHandle
POST api/shopify/generate_url Sohead\Core\Http\Controllers\Api\ShopifyController@getAuthUrl
POST api/shopify/webhook Sohead\Core\Http\Controllers\Api\ShopifyController@webhook shopify.webhook
POST api/social/account Sohead\Core\Http\Controllers\Api\SocialController@saveAccount sohead.auth
GET api/social/auth_handle Sohead\Core\Http\Controllers\Api\SocialController@authHandle sohead.redirect
POST api/social/generate_url Sohead\Core\Http\Controllers\Api\SocialController@getAuthUrl sohead.auth
GET api/social/previewMetaData Sohead\Core\Http\Controllers\Api\SocialController@previewMetaData
POST api/social/re-auth Sohead\Core\Http\Controllers\Api\SocialController@reconnect sohead.auth

Social Support

  • Facebook
  • Twitter
  • Google

Middleware

  • sohead.auth : check Authorization
  • shopify.webhook : Shopify Authenticate Hook

Queue

  • AddWebhook (init_app)
  • SyncProducts (shopify_sync_products)
  • SyncCollections (shopify_sync_collections)
  • SyncCollectionProducts (shopify_sync_collection_product)

How to customize

App install Shopify handle auth

Add singleton to function boot in AppServiceProvider

$this->app->singleton(
    \Sohead\Core\Services\Contracts\AppService::class,
    \App\Services\AppService::class
);

File AppService need extend class core

\Sohead\Core\Services\AppService

Then you can customize logic function

Charge Handle

Create listener Charge Handle document

php artisan make:listener ChargeHandle

Add to $listen in EventServiceProvider

protected $listen = [
    ...
    \Sohead\Core\Events\ChargeHandle::class => [
        \App\Listeners\ChargeHandle::class,
    ],
];

Then you can customize logic Charge Handle

Shopify hook

Create listener ShopifyHook document

php artisan make:listener ShopifyHook

Add to $listen in EventServiceProvider

protected $listen = [
    ...
    \Sohead\Core\Events\ShopifyHook::class => [
        \App\Listeners\ShopifyHook::class,
    ],
];

Then you can customize logic wehhook

Api Social

Add singleton to function boot in AppServiceProvider

$this->app->singleton(
    \Sohead\Core\Services\Contracts\SocialService::class,
    \App\Services\SocialService::class
);

File SocialService need extend class core

\Sohead\Core\Services\SocialService

Then you can customize logic function