Skip to content

Commit

Permalink
Merge pull request #35 from nosuchagency/develop
Browse files Browse the repository at this point in the history
Merge develop into master
  • Loading branch information
Victor-emil authored Feb 20, 2017
2 parents 3771904 + fc2cb51 commit 262a8b1
Show file tree
Hide file tree
Showing 82 changed files with 3,715 additions and 1,463 deletions.
37 changes: 37 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST=
DB_PORT=
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_KEY=
PUSHER_SECRET=

KONTAKT_KEY=
KONTAKT_VERSION=

TEAM_CAPACITY=
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Homestead.yaml
Homestead.json
.env
public/uploads
public/storage/images/*
storage/app/files/findables/*
storage/framework/messages
.env.example
.DS_Store
/.idea
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ The API (V1) documentation can be found [here](https://documenter.getpostman.com

Our good friends [Mustache](http://mustache.dk/) has created an iOS app using Beacon Bacon, and put it on GitHub. It's not a SDK, but it's a very good start. Find it [here](https://github.com/mustachedk/beacon-bacon-ios).

## Findables custom plug-ins

For people interested in integrating 3rd party services or rearranging data internally, Beacon Bacon comes with an extendable structure. When a user creates a Findable the user has the option of uploading a .php-file as well. This .php-file has to follow a very strict structure in order to function. However, if the core structure has been implemented, the possibilities are endless. The major structure rules are as follow:

* The Namespace MUST be namespace BB\{YOURNAME}Plugin
* The class HAS to {YOURNAME}Plugin
* One public function called Findable()
* The public function has to return an array or a json object
* The rest is up to you.

An example of such a file can be found in storage/app/files/findables/TestPlugin.php. Whenever **place/{{id}}/find** is called with a payload corresponding to the Identifier chosen when creating the Findable, the new functionality will be invoked.

## Security Vulnerabilities

If you discover a security vulnerability within Beacon Bacon, please send an e-mail to us at [email protected]. All security vulnerabilities will be promptly addressed.
Expand Down
16 changes: 12 additions & 4 deletions app/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,23 @@ class Block extends Model
protected static $logAttributes = ['name', 'image'];

/**
* Return full path to image.
* Return full virtual path to icon.
*
* @param string $value
* @return string
*/
public function getVirtualIconPath()
{
return !$this->image ? '' : url('/blocks/' . $this->id . '/image');
}

/**
* Return full physical path to icon.
*
* @return string
*/
public function getImageAttribute($value)
public function getPhysicalIconPath()
{
return !$value ? '' : asset('uploads/blocks/'.$this->id.'/'.$value);
return !$this->image ? '' : storage_path() . '/app/images/blocks/' . $this->id . '/' . $this->image;
}


Expand Down
14 changes: 7 additions & 7 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@ protected function renderExceptionWithWhoops($request, Exception $e)
* Convert an authentication exception into an unauthenticated response.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Auth\AuthenticationException $e
* @return \Symfony\Component\HttpFoundation\Response
* @param \Illuminate\Auth\AuthenticationException $exception
* @return \Illuminate\Http\Response
*/
protected function unauthenticated($request, AuthenticationException $e)
protected function unauthenticated($request, AuthenticationException $exception)
{
if ($request->ajax() || $request->wantsJson()) {
return response(['error' => 'Unauthorized.'], 401);
} else {
return redirect()->guest('login');
if ($request->expectsJson()) {
return response()->json(['error' => 'Unauthenticated.'], 401);
}

return redirect()->guest('login');
}
}
2 changes: 1 addition & 1 deletion app/Findable.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Findable extends Model
*
* @var array
*/
protected $fillable = ['name', 'identifier', 'parameter_one_name', 'parameter_two_name', 'parameter_three_name', 'parameter_four_name', 'parameter_five_name'];
protected $fillable = ['name', 'identifier', 'parameter_one_name', 'parameter_two_name', 'parameter_three_name', 'parameter_four_name', 'parameter_five_name', 'custom_file', 'type'];

/**
* The attributes that should be mutated to dates.
Expand Down
24 changes: 22 additions & 2 deletions app/Floor.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,29 @@ public function locations()
*
* @return string
*/
public function getImageAttribute($value)
public function getPublicImage()
{
return !$value ? '' : asset('uploads/floors/'.$this->id.'/'.$value);
return !$this->image ? '' : asset('storage/images/floors/' . $this->id . '/' . $this->image);
}

/**
* Return full virtual path to icon.
*
* @return string
*/
public function getVirtualIconPath()
{
return !$this->image ? '' : url('/floors/' . $this->id . '/image');
}

/**
* Return full physical path to icon.
*
* @return string
*/
public function getPhysicalIconPath()
{
return !$this->image ? '' : storage_path() . '/app/images/floors/' . $this->id . '/' . $this->image;
}

/**
Expand Down
15 changes: 8 additions & 7 deletions app/Http/Controllers/API/V1/BeaconController.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ public function store(Request $request)
*/
public function show(Request $request, $id)
{
$place = Beacon::findOrFail($id);
$beacon = Beacon::findOrFail($id);

return $this->attachResources($request, $place);
return $this->attachResources($request, $beacon);
}

/**
Expand All @@ -61,13 +61,14 @@ public function show(Request $request, $id)
public function update(Request $request, $id)
{
$this->validate($request, [
'name' => 'max:255',
'name' => 'required|max:255',
]);

$model = Beacon::findOrFail($id);
$model->update($request->all());
$beacon = Beacon::findOrFail($id);

$beacon->update($request->all());

return $model;
return $beacon;
}

/**
Expand All @@ -79,7 +80,7 @@ public function update(Request $request, $id)
*/
public function destroy($id)
{
Beacon::findOrFail($id)->delete();
$beacon = Beacon::findOrFail($id)->delete();

return response('', 204);
}
Expand Down
32 changes: 23 additions & 9 deletions app/Http/Controllers/API/V1/FloorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,18 @@ class FloorController extends Controller
*/
public function index(Request $request)
{
return $this->filteredAndOrdered($request, new Floor())->paginate($this->pageSize);

$floors = $this->filteredAndOrdered($request, new Floor())->paginate($this->pageSize);

foreach ($floors->items() as $floor) {
if ($floor->image) {
$floor->image = $floor->getPublicImage();
} else {
$floor->image = null;
}
}

return $floors;
}

/**
Expand Down Expand Up @@ -46,9 +57,11 @@ public function store(Request $request)
*/
public function show(Request $request, $id)
{
$place = Floor::findOrFail($id);
$floor = Floor::findOrFail($id);

$floor->image = $floor->getPublicImage();

return $this->attachResources($request, $place);
return $this->attachResources($request, $floor);
}

/**
Expand All @@ -62,14 +75,15 @@ public function show(Request $request, $id)
public function update(Request $request, $id)
{
$this->validate($request, [
'name' => 'max:255',
'image' => 'image',
'name' => 'required|max:255',
'image' => 'required|image',
]);

$model = Floor::findOrFail($id);
$model->update($request->all());
$floor = Floor::findOrFail($id);

$floor->update($request->all());

return $model;
return $floor;
}

/**
Expand All @@ -81,7 +95,7 @@ public function update(Request $request, $id)
*/
public function destroy($id)
{
Floor::findOrFail($id)->delete();
$floor = Floor::findOrFail($id)->delete();

return response('', 204);
}
Expand Down
15 changes: 8 additions & 7 deletions app/Http/Controllers/API/V1/LocationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ public function store(Request $request)
*/
public function show(Request $request, $id)
{
$place = Location::findOrFail($id);
$location = Location::findOrFail($id);

return $this->attachResources($request, $place);
return $this->attachResources($request, $location);
}

/**
Expand All @@ -61,13 +61,14 @@ public function show(Request $request, $id)
public function update(Request $request, $id)
{
$this->validate($request, [
'name' => 'max:255',
'name' => 'required|max:255',
]);

$model = Location::findOrFail($id);
$model->update($request->all());
$location = Location::findOrFail($id);

$location->update($request->all());

return $model;
return $location;
}

/**
Expand All @@ -79,7 +80,7 @@ public function update(Request $request, $id)
*/
public function destroy($id)
{
Location::findOrFail($id)->delete();
$location = Location::findOrFail($id)->delete();

return response('', 204);
}
Expand Down
Loading

0 comments on commit 262a8b1

Please sign in to comment.