lopatin96/laravel-cashier-shop

Laravel cashier shop

1.0.81 2024-12-18 11:37 UTC

README

Create app/View/Components/ShopLayout.php.

<?php

namespace App\View\Components;

use Illuminate\View\Component;
use Illuminate\View\View;

class ShopLayout extends Component
{
    public function render(): View
    {
        return view('layouts.shop');
    }
}

Create resources/views/layouts/shop.blade.php.

Trait

Add HasOrders trait and cast to User model.

use Atin\LaravelCashierShop\Traits\HasOrders;

class User extends Authenticatable
{
    use HasOrders;

    protected $casts = [
        …
        'shop_visited_at' => 'datetime',
    ];
 

Products

Create app/Products directory and TestProduct class:

<?php

namespace App\Products;

use App\Models\User;
use Atin\LaravelCashierShop\Interfaces\Product;
use Atin\LaravelCashierShop\Models\Order;

class TestProduct implements Product
{

    public function process(Order $order): void
    {
        // TODO: Implement process() method.
    }

    public function isListed(User $user): bool
    {
        // TODO: Implement isListed() method.
    }

    public function isPurchasable(User $user): bool
    {
        // TODO: Implement isPurchasable() method.
    }
}

Console

Add DeleteTooOldIncompleteOrders to app/Console/Kernel.php

use Atin\LaravelCashierShop\Console\DeleteTooOldIncompleteOrders;

class Kernel extends ConsoleKernel
{
    protected function schedule(Schedule $schedule): void
    {
        $schedule->call(new DeleteTooOldIncompleteOrders)->daily();

Publishing

Localization

php artisan vendor:publish --tag="laravel-cashier-shop-lang"

Views

php artisan vendor:publish --tag="laravel-cashier-shop-views"

Config

php artisan vendor:publish --tag="laravel-cashier-shop-config"

Migrations

php artisan vendor:publish --tag="laravel-cashier-shop-migrations"