Preface
Introduction
A Platform 4 extension to manage users across your application.
Have a read through the Installation Guide.
Features
- Admin can create & manage users.
- Admin can set first name & last name of users.
- Admin can set email of user.
- Admin can activate / deactivate user.
- Admin can update password.
- Admin can assign roles to user.
- Admin can set user permissions.
- Admin can add attributes to user.
- Developer can enable social logins.
- User can login.
- User can recover/reset password.
- User can update profile.
Examples
The $users
variable used below is a reference to the UserRepository.
$users = app('platform.users');
Retrieve all users
$allUsers = $users->findAll();
Dynamically create a new user.
$users->create([
'email' => 'foo@example.com',
'password' => 'secret',
]);
Setup
Installation
The best and easiest way to install the Users extension is with Composer.
Preparation
Open your composer.json
file and add the following to the require
array:
"platform/users": "3.0.*"
Add the following lines after the require
array on your composer.json
file:
"repositories": [
{
"type": "composer",
"url": "https://packages.cartalyst.com"
}
]
Note: Make sure that after the required changes your
composer.json
file is valid by runningcomposer validate
.
Install the dependencies
Run Composer to install or update the new requirement.
php composer install
or
php composer update
Now you are able to install the extension through Platform's admin.
Usage
In this section we'll show how you can manage your application's users.
Repository
IoC Binding
The user repository is bound to platform.users
and can be resolved out of the IoC Container using that offset.
$users = app('platform.users');
Methods
The repository contains several methods that are used throughout the extension, most common methods are listed below.
For an exhaustive list of available methods, checkout the UserRepositoryInterface
- findAll();
Returns a collection of all users.
- find($id);
Returns a user object based on the given id.
- findByEmail($email);
Returns a user object based on the given email.
- create(array $data);
Creates a new user.
- update($id, array $data);
Updates an existing user.
- delete($id);
Deletes a user.