basketin/customers

dev-main 2024-08-17 09:14 UTC

This package is auto-updated.

Last update: 2024-10-17 09:44:30 UTC


README

Source Packagist Version

Basketin Customers

The customers' module lets you register and manage customers and support Filament.

Documentation

Installation

Install via composer.

composer require basketin/customers

You need to migrate the package tables.

php artisan migrate

How to use

Create New Customer

You can create a new customer using the following code.

<?php

use Basketin\Component\Customers\Facades\Customer;

$customer = Customer::createNewCustomer(
    first_name: 'Karim',
    last_name: 'Mohamed',
    email: 'karim@mail.com',
    phone: '01234567899',
    password: 'password',
); // Return Customer Profile;

Customer Login

<?php

use Basketin\Component\Customers\Facades\Customer;

$customer = Customer::login('karim@mail.com', 'password') // Return Customer Profile;

Get Customer Via Sanctum

Using the following code, you can get a customer profile by sanctum token from $request.

$customer = $request->customerProfile();

Get Model

$customer->getModel();

Customer Update Data

$customer->updateData(
    phone: '01234567809',
);

Customer Change Password

$customer->changePassword($password, $confirmPassword);

Customer Addresses

$customer->addresses()->all();

Customer Create New Address

$customer->addresses()->create(
    $label,
    $countryCode,
    $cityId,
    $postcode,
    $streetLine1,
    $phoneNumber,
    $streetLine2 = null,
    $isMain = null
);

Filament Support

You can add customer management to the Filament panel using the following code.

use Basketin\Filament\Customers\BasketinCustomerPlugin;

...
->plugins([
    ...
    new BasketinCustomerPlugin(),
    ...
]),
...

Contributing

Thank you for considering contributing to this package! Be one of the Store team.

License

This package is an open-sourced software licensed under the MIT license.