Giter Site home page Giter Site logo

freshy969 / laravel-reddit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from geosem42/laravel-reddit

0.0 2.0 0.0 1.44 MB

Reddit clone built with Laravel 5

Home Page: http://maghnatis.com

License: GNU General Public License v3.0

PHP 41.03% JavaScript 53.20% HTML 5.76% CSS 0.01%

laravel-reddit's Introduction

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;
        }
    });
}

laravel-reddit's People

Contributors

halnex avatar opheliadesign avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.