Skip to content

Commit

Permalink
Added friendshipStatus helper
Browse files Browse the repository at this point in the history
  • Loading branch information
gregoryduckworth committed Sep 14, 2015
1 parent 4bac26a commit c9a780c
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 28 deletions.
15 changes: 0 additions & 15 deletions .editorconfig

This file was deleted.

6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@

All Notable changes to `Friendable` will be documented in this file

### Added
### 0.2
- Added fiendshipStatus helper
- Changed enum values to strings to access friendshipStatus

### 0.1
- Initial commit
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The MIT License (MIT)

Copyright (c) 2015 Gregory Duckworth <gregoryduckworth@googlemail.com>
Copyright (c) 2015 Gregory Duckworth <gregoryduckworth@users.noreply.github.com>

> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Friendable v0.1
[![Build Status](https://api.travis-ci.org/gregoryduckworth/friendable.png?branch=master)](https://api.travis-ci.org/gregoryduckworth/friendable)
[![PHP version](https://badge.fury.io/ph/gregoryduckworth%2Ffriendable.svg)](http://badge.fury.io/ph/gregoryduckworth%2Ffriendable)
# Friendable

[![Latest Stable Version](https://poser.pugx.org/gregoryduckworth/friendable/v/stable)](https://packagist.org/packages/gregoryduckworth/friendable) [![Total Downloads](https://poser.pugx.org/gregoryduckworth/friendable/downloads)](https://packagist.org/packages/gregoryduckworth/friendable) [![Build Status](https://api.travis-ci.org/gregoryduckworth/friendable.png?branch=master)](https://api.travis-ci.org/gregoryduckworth/friendable) [![License](https://poser.pugx.org/gregoryduckworth/friendable/license)](https://packagist.org/packages/gregoryduckworth/friendable)

Add the possibility of friends quickly with the use of this trait.

Expand Down
8 changes: 5 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gregoryduckworth/friendable",
"description": "Add the possibility of friends quickly with the use of this trait.",
"version": "0.1",
"version": "0.2",
"keywords": [
"laravel",
"friends",
Expand All @@ -12,7 +12,7 @@
"authors": [
{
"name": "Gregory Duckworth",
"email": "gregoryduckworth@googlemail.com",
"email": "gregoryduckworth@users.noreply.github.com",
"role": "Developer"
}
],
Expand All @@ -22,7 +22,9 @@
},
"require-dev": {
"phpunit/phpunit" : "4.*",
"scrutinizer/ocular": "~1.1"
"scrutinizer/ocular": "~1.1",
"mockery/mockery": "dev-master",
"illuminate/database": "~5.1"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion database/migrations/create_friends_users_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Schema::create('friends_users', function (Blueprint $table) {
$table->integer('friend_id')->unsigned();
$table->integer('user_id')->unsigned();
$table->integer('status')->default(0);
$table->string('status');

$table->foreign('user_id')->references('id')->on('users');
$table->foreign('friend_id')->references('id')->on('users');
Expand Down
8 changes: 4 additions & 4 deletions src/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
*/
class Status
{
const PENDING = 0;
const CONFIRMED = 1;
const AWAITING_APPROVAL = 2;
const BLOCKED = 3;
const PENDING = 'Pending';
const CONFIRMED = 'Confirmed';
const AWAITING_APPROVAL = 'Awaiting Approval';
const BLOCKED = 'Blocked';
}
10 changes: 10 additions & 0 deletions src/Traits/Friendable.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,14 @@ public function removal(Model $friend)
$this->friends()->detach($friend->id);
}

/**
* Method to check the status of a friendship
*
* @param Model $friend
*/
public function friendshipStatus(Model $friend)
{
return $this->friends()->where('friend_id', $friend->id)->select('status')->first();
}

}

0 comments on commit c9a780c

Please sign in to comment.