Skip to content

Commit

Permalink
update to readme file and minor bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
UnrulyNatives committed Sep 15, 2016
1 parent 19c6c03 commit 0fd48fb
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 8 deletions.
46 changes: 40 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,26 @@ Three different values available for storing likes and upvotes

2. register the service provider in `config/app.php`.



3. Update your `User.php` model with this package's trait. (currently in non-working condition!)

Add these two functions (this package's trait is still not developed, contributors welcome!)


```
public function importances() {
return $this->hasMany(\App\Models\Userattitude::class, 'creator_id');
}
public function attitudes() {
return $this->hasMany(\App\Models\Userattitude::class, 'creator_id');
}
```

Add these functions to your model, in which you wish to use voting system (this package's trait is still not developed, contributors welcome!)
```
public function importances() {
Expand All @@ -58,11 +75,11 @@ Add these two functions (this package's trait is still not developed, contributo

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

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

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

5. Update your models with this package's trait.
5. (unfinished) Update your models with this package's trait.

The trait is under development. For now just paste the below functions to your models:

Expand All @@ -87,9 +104,26 @@ The trait is under development. For now just paste the below functions to your m
```
6. Routes (optional)

Properly working routes necessary to service voting are locatad within ths package:

```
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']);
```

You can put them in your location of choice

7. Attach the js and css files to your template. Mind the file paths if you decide to place them somewhere else than they are published to.

```
<link href="{{URL::to('css/unrulynatives_attitudes.css')}}" rel="stylesheet">
<script type="text/javascript" src="{{URL::to('js/minitool_attitudes.js')}}"></script>
```

7. Include the below view files in your `foreach` loop. Note that the looped variable should be changed accordingly. Here I use `$o->`.
8. Include the below view files in your `foreach` loop. Note that the looped variable should be changed accordingly. Here I use `$o->`.

```
$itemkind = 'features'; // features is a name of your model
Expand All @@ -107,9 +141,9 @@ Do it in `app\Providers\AppServiceProvider.php`. Use the instructions in https:/



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

9. Working demo.
10. Working demo.

If you installed this package correctly, point your browser to `attitudes-demo`.
- You should be logged in
Expand Down
4 changes: 2 additions & 2 deletions src/attitudes_views/_setattitude.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
@endunless


@include('abstracted._userattitudes_attitude_toggle_abstracted', ['itemkind' => $itemkind,'o' => $object, 'attitude' => (($cua = $o->user_approach(Auth::user())) ? $cua->attitude : NULL)])
@include('userattitudes._userattitudes_attitude_toggle_abstracted', ['itemkind' => $itemkind,'o' => $object, 'attitude' => (($cua = $o->user_approach(Auth::user())) ? $cua->attitude : NULL)])

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

@if(isset($header3))
<h4>{{$header3}}</h4>
Expand Down

0 comments on commit 0fd48fb

Please sign in to comment.