PHP code example of drkwolf / laravel-user
1. Go to this page and download the library: Download drkwolf/laravel-user library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
drkwolf / laravel-user example snippets
Schema::create('users', function(Blueprint $table) {
$table->increments('id');
$table->string('username')->unique()->nullable();
$table->string('phone')->unique()->nullable();
$table->string('email')->unique()->nullable();
$table->string('password')->nullable();
$table->tinyInteger('active')->default(0);
$table->string('first_name')->nullable();
$table->string('last_name')->nullable();
$table->enum('sex', ['M', 'F'])->nullable();
$table->json('options')->nullable();
$table->json('contacts')->nullable();
$table->timestamps();
$table->softDeletes();
});
Schema::create('tutor_user', function(Blueprint $table) {
$table->integer('user_id');
$table->integer('tutor_id');
$table->json('options')->nullable();
$table->timestamps();
});
'model' => [
// field name ($request)
'avatar_field' => 'avatar',
// filesystem disk where default pic is
// public disk should have url attribute !
'avatar_disk' => 'public',
'avatar_collection' => 'avatars',
'avatar_default' => 'defaults/avatar-102.png',
// validation rules
'rules' => [
'default' => [
'first_name' => '
'model' => [
//...
'rules' => [
'default' => function ($user_model) {
return [
// ...
'email' => 'nullable|email|unique:users,email' . ",{$user_model->id}"
]
}
],
]
]
use drkwolf\Package\Presenter\DefaultPresenter as Presenter;
// creating
$presenter = new Presenter();
$action = 'create'
$response = UserHandler::resolve(
$action, $params = [],
$presenter, $request->data, 'admin');
// updating
$presenter = new UserPresenter();
$action = 'update'
$response = UserHandler::resolve(
$action, $params = [],
$presenter, $request->data, 'admin');
bash
php artisan vendor:publish --provider="drkwolf\Larauser\LarauserServiceProvider" --tag="config"