Download the PHP package unrulynatives/attitudes without Composer

On this page you can find all versions of the php package unrulynatives/attitudes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package attitudes

What it is

This is a complete upvote and downvote solution for Laravel >= 5.3.

Contributors welcome. Any feature suggestions? Submit an issue.

Current version:

Latest Stable Version Total Downloads

List of all features

This package delivers several solutions working in the same DB table. Pick one or use all to get functionality you need. Three values available for storing likes and upvotes are up to you: binary, negative value or null.

To do

Conntributing

While the package does the job perfectly now, please give me some time to make the code look more professional. Contributors welcome!

Installation

  1. Add this line to your 'composer.json`

"unrulynatives/attitudes": "^1.0"

  1. register the service provider in config/app.php.

    Unrulynatives\Attitudes\AttitudesServiceProvider::class,

  2. In your User.php model register this trait.

The trait will make these two functions available. (As an alternative, you can implement them directly in the model file.)

  1. Register trait in your models

To all models you want to enable the voting ystem, register this trait:

The trait will make the below three functions available. (As an alternative, you can implement them directly in the model file.)

  1. Publish assets Publish migrations, views, controller and other assets from this package into your Laravel app:

php artisan vendor:publish --provider="Unrulynatives\Attitudes\AttitudesServiceProvider" --force

  1. Run migrations Now run the migrations with command php artisan migrate. Verify that the table userattitudes was created.

Note: make sure to make your adjustments on copies, as newer version of this package might overwrite your changes (note the --force option in the publish command.)

  1. (optional) Setup the demo feature

While the DB in demonstration page will be seeded by controller function, you can also seed the DB here.

in your \database\seeds\DatabaseSeeder.php run() function declare this seed file: \database\seeds\UnAQuotationsTableSeeder.php and run php artisan db:seed.

Route::any('{itemkind}/{id}/set_user_attitude', ['as' => 'attitudes.set_user_attitude', 'uses' => 'AttitudesController@set_user_attitude']); Route::any('{itemkind}/{id}/set_user_importance', ['as' => 'attitudes.set_user_importance', 'uses' => 'AttitudesController@set_user_importance']);

 // features is a name of your model
@include('userattitudes._userattitudes_attitude_toggle_abstracted', ['itemkind' => $itemkind,'o' => $o, 'attitude' => (($cua = $o->user_approach(Auth::user())) ? $cua->attitude : NULL)])

@include('userattitudes._userattitudes_importance_toggle_abstracted', ['itemkind' => $itemkind,'o' => $o, 'importance' => (($cua = $o->user_approach(Auth::user())) ? $cua->importance : NULL)])

use Illuminate\Database\Eloquent\Relations\Relation;

// ...

public function boot()
{

    Relation::morphMap([
        'user' => User::class,
        'quotation' => \App\Models\UnAQuotation::class,
    ]);
}


12. Define a csrf token
Be sure that the head of your page contains the below declaration, otherwise you will meet with unexpected behavior of the script:
`<meta name="csrf-token" content="{{ csrf_token() }}" />`

### That's it! Now  user choices should be stored in the database table `userattitudes`.

## Working demo. 

If you installed this package correctly, point your browser to `attitudes-demo`.
- You should be logged in
- you sould have the `app\Models\Feature` model defined and at least one record in your database present. You can just simply use your own model for your test run - it's up to you.

An online demo is available at http://dev.unrulynatives.com/attitudes-demo

## Data migration from other packages

Added feature to migrate data from rtconner's package. See url `attitudes-migrate-likeable`

## Usage & Examples

### Count total votes of an object

`$this->countallvotes` - prints total number of votes cast by all users
`$this->countdownvotes`- prints total number of DOWN-votes cast by all users
`$this->countupvotes`- prints total number of UP-votes cast by all users

### collections
- `Quotation::whereUpvotedBy(Auth::id())->get();` // collection of Quotations upvoted by the user
- `Quotation::whereDownvotedBy(Auth::id())->get();` // collection of Quotations downvoted by the user
- `Quotation::whereVotedBy(Auth::id())->get();` // collection of Quotations voted in any way by the user (mind that the function counts records existing in DB, so it includes `null` and `0`)

### backend

IMPORTANT NOTE: In this package the assumed convention for model names is singular with capitalized first letter.
Mind the variable `itemkind`. It MUST be plural form of your model name.
If you have another system, you must rework the backend solutions of this package.

### Frontend

After publishing the views, in your app's `resources/views/` folder you will find a folder `userattitudes`. Inside you will find several files. In files included by the below templates you can define classes for your voting buttons and model affected by them. 
To have everything work well, start with including

`@include('userattitudes.set_attitudes_2')` 
(works with Bootstrap 4 and font Awesome (for thumbs up & down icons))

Other frontend solutions
`@include('userattitudes.set_attitudes_1')` will work nice with 
(works well with the UnrulyNatives Starter Kit package - need extra icon fonts installed)

## Help and documentation

point your browser to `attitudes-docs` to see instructions. If you cannot see the docs, then you have a problem to solve. Good luck!
After you use the `publish` command, the file will be located at `resources/views/userattitudes/features/index.blade.php`

All versions of attitudes with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.4
illuminate/support Version >=5.4.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package unrulynatives/attitudes contains the following files

Loading the files please wait ....