Skip to content

Commit

Permalink
Graphs everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
ConsoleTVs committed Jun 11, 2016
1 parent 817d183 commit e3ee6ef
Show file tree
Hide file tree
Showing 28 changed files with 12,406 additions and 222 deletions.
5 changes: 4 additions & 1 deletion app/Http/Controllers/Admin/Data/Data.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

<?php
/*
+---------------------------------------------------------------------------+
Expand Down Expand Up @@ -92,7 +93,7 @@
],
'edit' => [
'hidden' => ['id', 'su', 'created_at', 'updated_at'],
'su_hidden' => ['color', 'name'],
'su_hidden' => ['name'],
'empty' => [],
'default_random' => [],
'confirmed' => [],
Expand Down Expand Up @@ -155,6 +156,7 @@
'wysiwyg' => ['body'],
'validator' => [
'title' => 'required|max:255|unique:posts',
'body' => 'required',
],
],
'edit' => [
Expand All @@ -169,6 +171,7 @@
'wysiwyg' => ['body'],
'validator' => [
'title' => 'sometimes|required|max:255|unique:posts,title,'.$row->id,
'body' => 'required',
],
],
],
Expand Down
14 changes: 7 additions & 7 deletions app/Http/Controllers/Admin/PermissionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function edit($id)

# Check if it's su
if($perm->su) {
return redirect('/admin/permissions')->with('info', "For security reaseons you can't modify this");
return redirect('/admin/permissions')->with('info', "For security reasons you can't modify this");
}

# Get all types
Expand All @@ -117,7 +117,7 @@ public function update($id, Request $request)

# Check if it's su
if($perm->su) {
return redirect('/admin/permissions')->with('info', "For security reaseons you can't modify this");
return redirect('/admin/permissions')->with('info', "For security reasons you can't modify this");
}

# Validate Request
Expand Down Expand Up @@ -151,7 +151,7 @@ public function destroy($id)

# Check if it's su
if($perm->su) {
return redirect('/admin/permissions')->with('info', "For security reaseons you can't delete this");
return redirect('/admin/permissions')->with('info', "For security reasons you can't delete this");
}

# Delete relationships
Expand Down Expand Up @@ -211,7 +211,7 @@ public function editType($id)

# Check if it's su
if($type->su) {
return redirect('/admin/permissions')->with('info', "For security reaseons you can't modify this");
return redirect('/admin/permissions')->with('info', "For security reasons you can't modify this");
}

# Retrun the form
Expand All @@ -230,7 +230,7 @@ public function updateType($id, Request $request)

# Check if it's su
if($type->su) {
return redirect('/admin/permissions')->with('info', "For security reaseons you can't modify this");
return redirect('/admin/permissions')->with('info', "For security reasons you can't modify this");
}

# Validate the request
Expand Down Expand Up @@ -258,7 +258,7 @@ public function destroyType($id)

# Check if it's su
if($type->su) {
return redirect('/admin/permissions')->with('info', "For security reaseons you can't delete this");
return redirect('/admin/permissions')->with('info', "For security reasons you can't delete this");
}

# Set to 'Other' all the permissions that had that type
Expand All @@ -267,7 +267,7 @@ public function destroyType($id)
$rel->type_id = 0;
$rel->save();
}

# Delete the type
$type->delete();

Expand Down
14 changes: 14 additions & 0 deletions app/Http/Controllers/Admin/PostsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,23 @@ public function index($id)
}

$post = Post::findOrFail($id);

$post->addView();

return view('admin/blogs/posts/index', ['post' => $post]);
}

public function graphics($id){
# Check permissions
if(!Auth::user()->has('admin.posts.graphics')) {
return redirect('/admin')->with('warning', "You are not allowed to perform this action")->send();
}

$post = Post::findOrFail($id);

return view('admin/blogs/posts/graphics', ['post' => $post]);
}

public function create($id)
{

Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/Admin/RolesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,12 @@ public function destroy($id)

# Check if it's su
if($role->su) {
return redirect('/admin/roles')->with('info', "For security reaseons you can't delete this");
return redirect('/admin/roles')->with('info', "For security reasons you can't delete this");
}

# Check if it's the default role
if($role->id == Users_Settings::first()->default_role) {
return redirect('/admin/roles')->with('info', "For security reaseons you can't delete the default user role");
return redirect('/admin/roles')->with('info', "For security reasons you can't delete the default user role");
}

# Delete all relationships
Expand Down
30 changes: 1 addition & 29 deletions app/Http/Controllers/Admin/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,34 +27,6 @@ public function __construct()
}
}

public function fields($columns, $hidden)
{
# Gets the fields available to edit / update
$final_columns = [];
foreach($columns as $column) {
$add = true;
foreach($hidden as $hide) {
if($column == $hide) {
$add = false;
}
}
if($add) {
array_push($final_columns, $column);
}
}
return $final_columns;
}

public function addSuHidden($hidden, $su_hidden)
{
# Add the su_hidden fields to the hiden variable
foreach($su_hidden as $su_hid) {
array_push($hidden, $su_hid);
}

return $hidden;
}

public function index()
{
# Get all users
Expand Down Expand Up @@ -335,7 +307,7 @@ public function destroy($id)

# Check if it's su
if($user->su) {
return redirect('/admin/users')->with('info', "For security reaseons you can't delete this");
return redirect('/admin/users')->with('info', "For security reasons you can't delete this");
}

# Check before deleting
Expand Down
32 changes: 17 additions & 15 deletions app/Http/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,29 +165,31 @@
Route::post('/permissions/types/{id}/delete', 'PermissionsController@destroyType');

# Blogs Routes
Route::get('blogs', 'BlogsController@index');
Route::get('/blogs', 'BlogsController@index');

Route::get('blogs/create', 'BlogsController@create');
Route::post('blogs/create', 'BlogsController@store');
Route::get('/blogs/create', 'BlogsController@create');
Route::post('/blogs/create', 'BlogsController@store');

Route::get('blogs/{id}', 'BlogsController@posts');
Route::get('/blogs/{id}', 'BlogsController@posts');

Route::get('blogs/{id}/edit', 'BlogsController@edit');
Route::post('blogs/{id}/edit', 'BlogsController@update');
Route::get('/blogs/{id}/edit', 'BlogsController@edit');
Route::post('/blogs/{id}/edit', 'BlogsController@update');

Route::get('blogs/{id}/delete', 'SecurityController@confirm');
Route::post('blogs/{id}/delete', 'BlogsController@destroy');
Route::get('/blogs/{id}/delete', 'SecurityController@confirm');
Route::post('/blogs/{id}/delete', 'BlogsController@destroy');

# Posts Routes
Route::get('posts/{id}', 'PostsController@index');
Route::get('/posts/{id}', 'PostsController@index');

Route::get('posts/create/{id}', 'PostsController@create');
Route::post('posts/create/{id}', 'PostsController@store');
Route::get('/posts/create/{id}', 'PostsController@create');
Route::post('/posts/create/{id}', 'PostsController@store');

Route::get('posts/{id}/edit', 'PostsController@edit');
Route::post('posts/{id}/edit', 'PostsController@update');
Route::get('/posts/{id}/edit', 'PostsController@edit');
Route::post('/posts/{id}/edit', 'PostsController@update');

Route::get('posts/{id}/delete', 'SecurityController@confirm');
Route::post('posts/{id}/delete', 'PostsController@destroy');
Route::get('/posts/{id}/graphics', 'PostsController@graphics');

Route::get('/posts/{id}/delete', 'SecurityController@confirm');
Route::post('/posts/{id}/delete', 'PostsController@destroy');

});
23 changes: 23 additions & 0 deletions app/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
namespace App;

use Illuminate\Database\Eloquent\Model;
use App\Post_View;
use Request;
use URL;
use Location;

class Post extends Model
{
Expand All @@ -17,4 +21,23 @@ public function author()
{
return $this->belongsTo('App\User', 'user_id');
}

public function views()
{
return $this->hasMany('App\Post_View');
}

public function addView()
{
$view = new Post_View;

$view->post_id = $this->id;
$view->ip = Request::ip();
$view->url = Request::url();
$view->ref = URL::previous();
$view->country_code = Location::get($view->ip)->countryCode;
$view->save();

return True;
}
}
15 changes: 15 additions & 0 deletions app/Post_View.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Post_View extends Model
{
protected $table = 'post_views';

public function post()
{
return $this->hasOne('App\Post');
}
}
10 changes: 10 additions & 0 deletions app/Settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Settings extends Model
{
protected $table = "settings";
}
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"php": ">=5.5.9",
"laravel/framework": "5.2.*",
"graham-campbell/exceptions": "^8.3",
"doctrine/dbal": "^2.5"
"doctrine/dbal": "^2.5",
"stevebauman/location": "^1.3"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
Expand Down
3 changes: 3 additions & 0 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@

GrahamCampbell\Exceptions\ExceptionsServiceProvider::class,

Stevebauman\Location\LocationServiceProvider::class,

],

/*
Expand Down Expand Up @@ -203,6 +205,7 @@
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
'Location' => Stevebauman\Location\Facades\Location::class,

],

Expand Down
Loading

0 comments on commit e3ee6ef

Please sign in to comment.