Reddit clone built with Laravel 5
Switch branches/tags
Nothing to show
Clone or download
Latest commit b616da3 Dec 5, 2016

README.md

laravel-reddit

Reddit clone built with Laravel 5

Demo: http://maghnatis.com

Packages Used

  1. "intervention/image"
  2. "oscarotero/Embed"
  3. "mohankumaranna/comment"

Features

  1. Login/Register
  2. Subreddits
  3. Posts (link and text)
  4. Moderators
  5. Search
  6. Threaded Comments with inline editing
  7. Upvote/Downvote
  8. User Profiles

To-Do

  1. Sorting

Installation

  1. git clone https://github.com/Halnex/laravel-reddit projectname
  2. composer install
  3. php artisan migrate

Open AuthServiceProvider.php and import the following classes.

use Illuminate\Auth\Access\Gate;
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;

Now add the following method to the class

public function boot(GateContract $gate)
{
    parent::registerPolicies($gate);

    $gate->define('update-post', function ($user, $post, $isModerator) {
        if ($user->id === $post->subreddit->user->id) {
            return true;
        }

        if ($user->id === $post->user_id) {
            return true;
        }

        if ($isModerator) {
            return true;
        }

        return false;
    });

    $gate->define('update-sub', function($user, $subreddit) {
        if($user->id === $subreddit->user->id) {
            return true;
        }

        return false;
    });

    $gate->define('update-comment', function($user, $comment, $isModerator) {
        if($user->id === $comment->user_id) {
            return true;
        }

        if ($isModerator) {
            return true;
        }
    });
}