Setup database and models
Create the shop migrations
Run php artisan vendor:publish
. Adjust the published migration if required, then run php artisan migrate
.
Create the Shop model
// app/Shop.php
<?php
use Esc\Shopify\Models\Shop as ShopBase;
class Shop extends ShopBase {
protected $table = 'shops';
}
Methods included in the Shop class include the user
relation, and login()
, and logout()
, findByDomain($myshopifyDomain)
.
The Shop Model automatically deletes it's associated user
on deletion.
Add relationships and methods to your user model
// app/User.php
<?php
...
class User ... {
...
public function shop() {
return $this->hasOne(Esc\Shopify\Models\Shop::class, 'user_id');
}
}