-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
75 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,105 @@ | ||
# :package_name | ||
# GuestPass for Laravel | ||
|
||
[![Latest Version on Packagist][ico-version]][link-packagist] | ||
[![Software License][ico-license]](LICENSE.md) | ||
[![Build Status][ico-travis]][link-travis] | ||
[![Coverage Status][ico-scrutinizer]][link-scrutinizer] | ||
[![Quality Score][ico-code-quality]][link-code-quality] | ||
[![Total Downloads][ico-downloads]][link-downloads] | ||
|
||
**Note:** Replace ```:author_name``` ```:author_username``` ```:author_website``` ```:author_email``` ```:vendor``` ```:package_name``` ```:package_description``` with their correct values in [README.md](README.md), [CHANGELOG.md](CHANGELOG.md), [CONTRIBUTING.md](CONTRIBUTING.md), [LICENSE.md](LICENSE.md) and [composer.json](composer.json) files, then delete this line. You can run `$ php prefill.php` in the command line to make all replacements at once. Delete the file prefill.php as well. | ||
## Installation | ||
|
||
This is where your description should go. Try and limit it to a paragraph or two, and maybe throw in a mention of what | ||
PSRs you support to avoid any confusion with users and contributors. | ||
Via Composer | ||
|
||
## Structure | ||
``` bash | ||
$ composer require jeroen-g/guestpass | ||
``` | ||
|
||
If any of the following are applicable to your project, then the directory structure should follow industry best practises by being named the following. | ||
If you run Laravel 5.5, the service provider and facade are autodiscovered. If not then add them manually: | ||
|
||
```php | ||
JeroenG\GuestPass\GuestPassServiceProvider::class, | ||
// ... | ||
'GuestPass' => JeroenG\GuestPass\GuestPassFacade::class, | ||
``` | ||
bin/ | ||
config/ | ||
src/ | ||
tests/ | ||
vendor/ | ||
|
||
## Usage | ||
|
||
To use Guest Passes, you will need two models: one that is the owner granting guest access (typically a user) and another that is the object to which access is being granted. In the examples below, a photo is used for this. | ||
|
||
### Creating new Guest Passes | ||
|
||
Requires the owner and object models. | ||
```php | ||
GuestPass::create($user, $photo); | ||
``` | ||
Returns true if successfull, false otherwise. | ||
|
||
### Retrieving Guest Pass data | ||
|
||
## Install | ||
A Guest Pass contains the following data: `owner_model`, `owner,id`; `object_model`, `object_id`; `key` (unique); `view` (nullable). | ||
|
||
Via Composer | ||
#### Getting all keys of the owner | ||
Requires the owner model. | ||
```php | ||
GuestPass::getKeysOf($user); | ||
``` | ||
Returns a collection of all Guest Pass keys and their corresponding data is attached as well. | ||
|
||
``` bash | ||
$ composer require :vendor/:package_name | ||
#### Finding a Guest Pass for corresponding owner and object | ||
Requires the owner and object model. | ||
```php | ||
GuestPass::findGuestPass($user, $photo); | ||
``` | ||
Returns an Eloquent model (or throws an exception). | ||
|
||
## Usage | ||
#### Get one specific Guest Pass by its key | ||
Requires the key (string). | ||
```php | ||
GuestPass::getGuestPass($key); | ||
``` | ||
Returns an Eloquent model (or throws an exception). | ||
|
||
``` php | ||
$skeleton = new League\Skeleton(); | ||
echo $skeleton->echoPhrase('Hello, League!'); | ||
### Checking ownership | ||
Requires the owner and Guest Pass models. | ||
```php | ||
GuestPass::isOwner($user, $guestpass); | ||
``` | ||
Returns true or false. | ||
|
||
## Change log | ||
### Access controller | ||
|
||
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. | ||
The package ships with a controller that checks for the `/gp/{owner id}/{key}` route and when valid it returns the view (404 otherwise). Each view is passed the object and the Guest Pass models. | ||
The views will be sought in the `resources/views/guests/` directory. | ||
|
||
## Testing | ||
### Custom views | ||
|
||
``` bash | ||
$ composer test | ||
When creating a Guest Pass it is possible to pass a custom view as the third parameter | ||
```php | ||
GuestPass::create($user, $photo, 'album'); | ||
``` | ||
In this case, the access controller will not use `photo.blade.php` (which would be the default) but `album.blade.php` but the directory remains the same and it is not necessary to add the file extension. | ||
|
||
## Contributing | ||
## Changelog | ||
|
||
Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details. | ||
Please see [changelog.md](changelog.md) for what has changed recently. | ||
|
||
## Security | ||
## Contributing | ||
|
||
If you discover any security related issues, please email :author_email instead of using the issue tracker. | ||
Please see [contributing.md](contributing.md) for details. | ||
|
||
## Credits | ||
|
||
- [:author_name][link-author] | ||
- [JeroenG][link-author] | ||
- [All Contributors][link-contributors] | ||
|
||
## License | ||
|
||
The MIT License (MIT). Please see [License File](LICENSE.md) for more information. | ||
The EU Public License. Please see [license.md](license.md) for more information. | ||
|
||
[ico-version]: https://img.shields.io/packagist/v/:vendor/:package_name.svg?style=flat-square | ||
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square | ||
[ico-travis]: https://img.shields.io/travis/:vendor/:package_name/master.svg?style=flat-square | ||
[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/:vendor/:package_name.svg?style=flat-square | ||
[ico-code-quality]: https://img.shields.io/scrutinizer/g/:vendor/:package_name.svg?style=flat-square | ||
[ico-downloads]: https://img.shields.io/packagist/dt/:vendor/:package_name.svg?style=flat-square | ||
[ico-version]: https://img.shields.io/packagist/v/Jeroen-G/GuestPass.svg?style=flat-square | ||
[ico-travis]: https://img.shields.io/travis/Jeroen-G/GuestPass/master.svg?style=flat-square | ||
[ico-code-quality]: https://img.shields.io/scrutinizer/g/Jeroen-G/GuestPass.svg?style=flat-square | ||
|
||
[link-packagist]: https://packagist.org/packages/:vendor/:package_name | ||
[link-travis]: https://travis-ci.org/:vendor/:package_name | ||
[link-scrutinizer]: https://scrutinizer-ci.com/g/:vendor/:package_name/code-structure | ||
[link-code-quality]: https://scrutinizer-ci.com/g/:vendor/:package_name | ||
[link-downloads]: https://packagist.org/packages/:vendor/:package_name | ||
[link-packagist]: https://packagist.org/packages/Jeroen-G/GuestPass | ||
[link-travis]: https://travis-ci.org/Jeroen-G/GuestPass | ||
[link-code-quality]: https://scrutinizer-ci.com/g/Jeroen-G/GuestPass | ||
[link-author]: https://github.com/:author_username | ||
[link-contributors]: ../../contributors | ||
[link-contributors]: ../../contributors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters