1. Go to this page and download the library: Download drecon/confide 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/ */
drecon / confide example snippets
use Zizaco\Confide\ConfideUser;
class User extends ConfideUser {
}
`ConfideUser` class will take care of some behaviors of the user model.
### Dump the default accessors
Lastly, you can dump a default controller and the default routes for Confide.
$ php artisan confide:controller
$ php artisan confide:routes
Don't forget to dump composer autoload
$ composer dump-autoload
**And you are ready to go.**
Access `http://yourapp/user/create` to create your first user. Check the `app/routes.php` to see the available routes.
## Usage in detail
**Basic setup:**
1. Database connection in `config/database.php` running properly.
2. Correct model and table names in `config/auth.php`. They will be used by Confide all the time.
3. `from` configuration in `config/mail.php`.
**Configuration:**
1. `ConfideServiceProvider` and `ConfideFacade` entry in `config/app.php` `'providers'` and `'aliases'` respectively.
2. User model (with the same name as in `config/auth.php`) should extend `ConfideUser` class. This will cause to methods like `resetPassword()`, `confirm()` and a overloaded `save()` to be available.
**Optional steps:**
1. Use `Confide` facade to dump login and signup forms easly with `makeLoginForm()` and `makeSignupForm()`. You can render the forms within your views by doing `{{ Confide::makeLoginForm()->render() }}`.
2. Generate a controller with the template contained in Confide throught the artisan command `$ php artisan confide:controller`. If a controller with the same name exists it will **NOT** be overwritten.
3. Generate routes matching the controller template throught the artisan command `$ php artisan confide:routes`. Your `routes.php` will **NOT** be overwritten.
### Advanced
#### Using custom table / model name
You can change the model name that will be authenticated in the `config/auth.php` file.
Confide uses the values present in that configuration file.
To change the controller name when dumping the default controller template you can use the --name option.
$ php artisan confide:controller --name Employee
Will result in `EmployeeController`
Then, when dumping the routes, you should use the --controller option to match the existing controller.
$ php artisan confide:routes --controller Employee
#### Using custom form or emails
First, publish the config files:
$ php artisan config:publish zizaco/confide
Then edit the view names in `app/config/packages/zizaco/confide/config.php`.
#### Update an User
To update an user already in the database you'll Need to make sure your ruleset is using the unique validator within the User model.
use Zizaco\Confide\ConfideUser;
class User extends ConfideUser {
public static $rules = array(
'username' => 'unique:users,username',
'email' => 'email'
);
class UserController extends Controller {
public function postCreate() {
// In real usage you'll need to find the user that is being modified.
// 1 is set just as an example.
$user = User::find(1);
// Update a user attribute from a form.
// Using email as an example.
$user->email = Input::get('email');
// Save
// This was previously update, but Ardent changed.
$user->updateUniques();
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.