Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V1 docs #1881

Draft
wants to merge 11 commits into
base: 1.x
Choose a base branch
from
Draft

V1 docs #1881

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/.vitepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export default defineConfig({
dark: '/icon-dark.svg',
},

'outline': [2, 3],

nav: [
{text: 'Core', link: '/core/overview', activeMatch: '/core/'},
{text: 'Admin Panel', link: '/admin/overview', activeMatch: '/admin/'},
Expand Down Expand Up @@ -70,7 +72,6 @@ export default defineConfig({
{text: 'Installation', link: '/core/installation'},
{text: 'Starter Kits', link: '/core/starter-kits'},
{text: 'Configuration', link: '/core/configuration'},
{text: 'Initial Set-Up', link: '/core/set-up'},
{text: 'Upgrade Guide', link: '/core/upgrading'},
{text: 'Release Schedule', link: '/core/release-schedule'},
{text: 'Security', link: '/core/securing-your-site'},
Expand Down
72 changes: 41 additions & 31 deletions docs/core/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,54 +10,59 @@ as you see fit.
php artisan vendor:publish --tag=lunar
```

### Database Table Prefix

`lunar/database.php`
## Cart
`config/lunar/cart.php`

| Setting | Description |
|:---------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| lunar.cart.session_key | This value is used to store the cart information in the Laravel session. If for any reason you already have a session entry with the same name, you can change it here. |
| lunar.cart.fingerprint_generator | The fingerprint generator class is specified here, which provides methods to check if a cart has changed or not. |
| lunar.cart.auto_create | Whether Lunar should automatically create a cart when one doesn't exist. Generally best left as `false`. |
| lunar.cart.auth_policy | When a user logs in the auth policy determines what should happen to the cart if the user had a previous cart when logged in. Can either be 'merge' or 'override'. |
| lunar.cart.pipelines | The code that run when the cart is calculating. You can make your own actions to customise how the cart calculations work. |
| lunar.cart.actions | The action that is used by the cart when adding, updating, etc. If you need to tweak some cart logic, it can be done by switching out these classes. |
| lunar.cart.validators | Allows you to customise the cart validation rules. |
| lunar.cart.eager_load | Determines the eager loading applied when the cart loads. We set a suitable default and you can customise for your own app's performance. |

## Database
`config/lunar/database.php`

| Setting | Description |
|:----------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| lunar.database.connection | By default, the package uses the default database connection. If you change connection, be sure to also set `ACTIVITY_LOGGER_DB_CONNECTION=` in your ENV file so that Spatie ActivityLog continues to function. |
| lunar.database.table_prefix | So that Lunar tables do not conflict with your existing application database tables, you can specify a prefix to use. If you change this after installation, you are on your own - happy renaming! |
| lunar.database.users_id_type | |
| lunar.database.disable_migrations | |

So that Lunar tables do not conflict with your existing application database tables, you can specify a prefix to use. If you change this after installation, you are on your own - happy renaming!

```php
'table_prefix' => 'lunar_',
```
## Discounts

### Database Connection
## Media

`lunar/database.php`
## Orders
`config/lunar/orders.php`

By default, the package uses the default database connection defined in Laravel. Here specify a custom database connection for Lunar.
| Setting | Description |
|:---------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------|
| lunar.orders.reference_generator | Defines a class which is responsible for generating order references. |
| lunar.orders.statuses | Here you can set up the statuses you wish to use for your orders. See the [Orders](reference/orders.html#order-notifications) section for more information. |
| lunar.orders.pipelines | The code that run when the order is processing. You can make your own code to customise how the order processing works. |

## Payments

```php
'connection' => 'some_custom_connection',
```

If you are using a custom database connection that is not the default connection in your Laravel configuration, you need to specify it in the .env file as well.
## Search

```
ACTIVITY_LOGGER_DB_CONNECTION=some_custom_connection
```

In our package, we utilize Spatie's [laravel-activitylog](https://spatie.be/docs/laravel-activitylog) for logging. The mentioned configuration allows the activity logger to use a different database connection instead of the default database connection.

### Orders

`lunar/orders.php`

Here you can set up the statuses you wish to use for your orders.

```php
'draft_status' => 'awaiting-payment',
'statuses' => [
'awaiting-payment' => [
'label' => 'Awaiting Payment',
'color' => '#848a8c',
],
'payment-received' => [
'label' => 'Payment Received',
'color' => '#6a67ce',
],
],
```

### Media

`lunar/media.php`
Expand Down Expand Up @@ -107,11 +112,16 @@ Transformations for all uploaded images.
```

### Pricing

`lunar/pricing.php`

If you want to store pricing inclusive of tax then set this config value to `true`.

```php
'stored_inclusive_of_tax' => false,
```

## Shipping

## Taxes

## URLs
5 changes: 3 additions & 2 deletions docs/core/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class User extends Authenticatable
### Publish Configuration
Before you run the Lunar installer command, you may wish to customise some of the set-up.


```sh
php artisan vendor:publish --tag=lunar
```
Expand All @@ -55,15 +54,17 @@ Lunar works best with [Laravel Scout](https://laravel.com/docs/master/scout) and

### If you do NOT have a search engine configured
Add the following to your `.env` file.

```
SCOUT_DRIVER=null
```

And set the config value in `panel.php` as follows.

```php
'scout_enabled' => false,
```


## Register the admin panel

The admin panel needs registering in your app service provider before you can use it.
Expand Down
18 changes: 11 additions & 7 deletions docs/core/overview.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Welcome to Lunar!
# Welcome To Lunar!

::: danger Alpha Release
Although many Lunar sites have been launched using v1.x, you may not consider this version production-ready for your own
Expand All @@ -7,20 +7,24 @@ use and should exercise the same amount of caution as you would with any softwar

We are delighted you are considering Lunar for your project. We've spent a lot of time developing this package to bring headless e-commerce functionality to Laravel.

## What is Lunar?
## What Is Lunar?

Lunar is a [Laravel e-commerce package](https://lunarphp.io/) which brings functionality akin to Shopify and other e-commerce platforms to Laravel. You have complete freedom to create your own storefront(s), but we've already done the hard work for you in the backend.
Lunar is a [Laravel e-commerce package](https://lunarphp.io/) which brings functionality akin to Shopify and other
e-commerce platforms to Laravel. You have complete freedom to create your own storefront(s), but we have already done
the hard work for you in the backend.

## Tech Stack

Lunar is comprised of two packages; `lunarphp/core` which provides the e-commerce functionality and `lunarphp/admin` which provides an admin hub built upon Laravel Livewire.
Lunar is comprised of two packages; `lunarphp/core` which provides the e-commerce functionality and `lunarphp/admin`
which provides an admin hub built upon Laravel Livewire.

Although the admin hub uses Laravel Livewire, there is no requirement for your app to use Livewire itself.

## What are the future plans?
## What Are The Future Plans?

Lunar as a company has grand plans to continue developing new functionality to help you build awesome e-commerce websites. We want Lunar to be a true alternative to the likes of Magento, Shopify, WooCommerce, etc.
Lunar as a company has grand plans to continue developing new functionality to help you build awesome e-commerce
websites. We want Lunar to be a true alternative to the likes of Magento, Shopify, WooCommerce, etc.

## Get started
## Get Started

Enough waffle! Let's help you [install Lunar...](/core/installation)
32 changes: 27 additions & 5 deletions docs/core/reference/activity-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,34 @@

## Overview

We've made a design choice to have activity logging throughout Lunar when it comes to changes happening on Eloquent models. We believe it's important to keep track of what updates are happening and who is making them. It allows us to provide you with an invaluable insight into what's happening in your store.
We made a design choice to include activity logging throughout Lunar to record changes made on Eloquent models. We
believe it is important to keep track of what updates are occurring and who is making them. It allows us to provide you
with an invaluable insight into what is happening in your store.

## How it works
## How It Works

For the actual logging, we have opted to use the incredible package by Spatie, [laravel-activitylog](https://spatie.be/docs/laravel-activitylog). This allows Lunar to keep track changes throughout the system so you can have a full history of what's going on.
For the actual logging, we opted to use the incredible package by Spatie,
[laravel-activitylog](https://spatie.be/docs/laravel-activitylog). This allows Lunar to track changes throughout
the system so you can have a full history of what's going on.

## Enabling on your own models
## Enabled Models
The following models have activity logging enabled by default in Lunar.

If you want to enable logging on your own models you can simply [follow the guides on their website](https://spatie.be/docs/laravel-activitylog)
- `\Lunar\Models\Channel`
- `\Lunar\Models\Brand`
- `\Lunar\Models\Cart`
- `\Lunar\Models\CartAddress`
- `\Lunar\Models\CartLine`
- `\Lunar\Models\Currency`
- `\Lunar\Models\Order`
- `\Lunar\Models\OrderAddress`
- `\Lunar\Models\OrderLine`
- `\Lunar\Models\Product`
- `\Lunar\Models\ProductVariant`
- `\Lunar\Models\Transaction`


## Enabling On Your Own Models

If you want to enable logging on your own models you can simply
[follow the guides on their website](https://spatie.be/docs/laravel-activitylog).
146 changes: 85 additions & 61 deletions docs/core/reference/addresses.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,82 +2,106 @@

## Overview

Customers may save addresses to make checking-out easier and quicker.
When a registered customer looks to checkout it is helpful for them to be able to save their preferred shipping
addresses. Lunar provides the `Address` Eloquent model which allows a developer to store addresses against a `Customer`
record for this very purpose.

## Addresses
It is worth noting that the `Address` model is **not** related to carts and orders. It is simply a facility to save address
information for reuse.

```php
Lunar\Models\Address
::: info
Carts and Orders have their own address models [`\Lunar\Models\CartAddress`](carts.html) and
[`\Lunar\Models\OrderAddress`](orders.html) which you can learn more about in those sections.
:::

## Eloquent Models

The primary model for this facility is the `Address` model. We also have the `Country` and
`State` models which come pre-populated with data when installing Lunar.

| Eloquent Model | Description | |
|:-----------------------|:---------------------------------------|:-----------------------------------------------------------------------------------------|
| `Lunar\Models\Address` | Stores customer addresses. |[view api](https://lunar-api-docs.staging-03.neondigital.co.uk/Lunar/Models/Address.html)|
| `Lunar\Models\Country` | Lookup for all countries in the world. |[view api](https://lunar-api-docs.staging-03.neondigital.co.uk/Lunar/Models/Country.html)|
| `Lunar\Models\State` | Lookup for states per country. |[view api](https://lunar-api-docs.staging-03.neondigital.co.uk/Lunar/Models/State.html) |

## Address Data

Data for Countries and States is provided by https://github.com/dr5hn/countries-states-cities-database.

Although Lunar adds the address data automatically for you on installation, you may use the following command to import
countries and states if required.

```sh
php artisan lunar:import:address-data
```
## Example Usage

|Field|Description|
|:-|:-|
|`id`||
|`customer_id`||
|`title`|nullable|
|`first_name`||
|`last_name`||
|`company_name`|nullable|
|`line_one`||
|`line_two`|nullable|
|`line_three`|nullable|
|`city`||
|`state`|nullable|
|`postcode`|nullable|
|`country_id`||
|`delivery_instructions`||
|`contact_email`||
|`contact_phone`||
|`last_used_at`|Timestamp for when the address was last used in an order.|
|`meta`|JSON|
|`shipping_default`|Boolean|
|`billing_default`|Boolean|
|`created_at`||
|`updated_at`||

## Countries
### Creating An Address

```php
Lunar\Models\Country
use Lunar\Models\Address;
use Lunar\Models\Country;
use Lunar\Models\State;

$country = Country::where('iso', 'GB')->first(); // E.g. United Kingdom
$state = State::find(4496); // E.g. Essex

$address = Address::create([
'customer_id' => $customer->id,
'title' => 'Mr',
'first_name' => 'John',
'last_name' => 'Smith',
'company_name' => 'My Company Ltd', // optional
'line_one' => '10 Example Street',
'line_two' => 'My Village',
'line_three' => '',
'city' => 'Chelmsford',
'state' => $state->name,
'postcode' => 'CM1 2AB',
'country_id' => $country->id,
'delivery_instructions' => 'Leave by the side gate',
'contact_email' => '[email protected]',
'contact_phone' => '07123 123456',
'last_used_at' => null,
'meta' => [
'business' => true, // meta data is optional
],
'shipping_default' => true,
'billing_default' => false,
'created_at' => now(),
'updated_at' => now(),
]);
```

|Field|Description|
|:-|:-|
|`id`||
|`name`||
|`iso3`||
|`iso2`||
|`phonecode`||
|`capital`||
|`currency`||
|`native`||
|`emoji`|Flag|
|`emoji_u`|Flag|
|`created_at`||
|`updated_at`||

### Getting Customer Addresses

## States
The example below assumes the authenticated user has been associated to a customer record.

```php
Lunar\Models\State
$customer = Auth::user()->latestCustomer();

foreach ($customer->addresses as $address) {
//
}
```

|Field|Description|
|:-|:-|
|`id`||
|`country_id`||
|`name`||
|`code`||
|`created_at`||
|`updated_at`||
### Listing Countries

## Address Data
Lunar supplies country data, which includes ISO code, native country names and Emoji graphics :uk:.

Data for Countries and States is provided by https://github.com/dr5hn/countries-states-cities-database.
```php
@foreach (Country::all() as $country)
<option value="{{ $country->id }}">{{ $country->emoji }} {{ $country->native }}</option>
@endforeach
```

You can use the following command to import countries and states.
### Listing States

```sh
php artisan lunar:import:address-data
States relate to countries. You can easily load them via a country model using its relationship.

```php
@foreach ($country->states as $state)
<option value="{{ $state->id }}">{{ $state->name }}</option>
@endforeach
```
Loading
Loading