├── .env.example
├── .gitattributes
├── .gitignore
├── Procfile
├── README.md
├── app
├── Activity.php
├── Channel.php
├── Console
│ └── Kernel.php
├── Exceptions
│ └── Handler.php
├── Favoritable.php
├── Favorite.php
├── Filters
│ ├── Filters.php
│ └── ThreadFilters.php
├── Http
│ ├── Controllers
│ │ ├── Auth
│ │ │ ├── ForgotPasswordController.php
│ │ │ ├── LoginController.php
│ │ │ ├── RegisterController.php
│ │ │ └── ResetPasswordController.php
│ │ ├── Controller.php
│ │ ├── FavoritesController.php
│ │ ├── HomeController.php
│ │ ├── ProfilesController.php
│ │ ├── RepliesController.php
│ │ ├── ThreadController.php
│ │ ├── ThreadSubscriptionsController.php
│ │ └── UserNotificationsController.php
│ ├── Kernel.php
│ └── Middleware
│ │ ├── EncryptCookies.php
│ │ ├── RedirectIfAuthenticated.php
│ │ ├── TrimStrings.php
│ │ └── VerifyCsrfToken.php
├── Notifications
│ └── ThreadWasUpdated.php
├── Policies
│ ├── ReplyPolicy.php
│ └── ThreadPolicy.php
├── Providers
│ ├── AppServiceProvider.php
│ ├── AuthServiceProvider.php
│ ├── BroadcastServiceProvider.php
│ ├── EventServiceProvider.php
│ └── RouteServiceProvider.php
├── RecordsActivity.php
├── Reply.php
├── Thread.php
├── ThreadSubscription.php
└── User.php
├── artisan
├── bootstrap
├── app.php
├── autoload.php
└── cache
│ └── .gitignore
├── composer.json
├── composer.lock
├── config
├── app.php
├── auth.php
├── broadcasting.php
├── cache.php
├── database.php
├── filesystems.php
├── mail.php
├── queue.php
├── services.php
├── session.php
└── view.php
├── database
├── .gitignore
├── factories
│ └── ModelFactory.php
├── migrations
│ ├── 2014_10_12_000000_create_users_table.php
│ ├── 2014_10_12_100000_create_password_resets_table.php
│ ├── 2017_04_21_224745_create_threads_table.php
│ ├── 2017_04_21_233654_create_replies_table.php
│ ├── 2017_05_29_025659_create_channels_table.php
│ ├── 2017_06_30_195457_create_favorites_table.php
│ ├── 2017_07_05_151909_create_activities_table.php
│ ├── 2017_10_24_160355_create_thread_subscriptions_table.php
│ └── 2017_10_31_171936_create_notifications_table.php
└── seeds
│ └── DatabaseSeeder.php
├── package.json
├── phpunit.xml
├── public
├── .htaccess
├── css
│ └── app.css
├── favicon.ico
├── fonts
│ └── vendor
│ │ └── bootstrap-sass
│ │ └── bootstrap
│ │ ├── glyphicons-halflings-regular.eot
│ │ ├── glyphicons-halflings-regular.svg
│ │ ├── glyphicons-halflings-regular.ttf
│ │ ├── glyphicons-halflings-regular.woff
│ │ └── glyphicons-halflings-regular.woff2
├── index.php
├── js
│ └── app.js
├── mix-manifest.json
└── robots.txt
├── resources
├── assets
│ ├── js
│ │ ├── app.js
│ │ ├── bootstrap.js
│ │ ├── components
│ │ │ ├── Favorite.vue
│ │ │ ├── Flash.vue
│ │ │ ├── NewReply.vue
│ │ │ ├── Paginator.vue
│ │ │ ├── Replies.vue
│ │ │ ├── Reply.vue
│ │ │ ├── SubscribeButton.vue
│ │ │ └── UserNotifications.vue
│ │ ├── mixins
│ │ │ └── Collection.js
│ │ └── pages
│ │ │ └── Thread.vue
│ └── sass
│ │ ├── _variables.scss
│ │ └── app.scss
├── lang
│ └── en
│ │ ├── auth.php
│ │ ├── pagination.php
│ │ ├── passwords.php
│ │ └── validation.php
└── views
│ ├── auth
│ ├── login.blade.php
│ ├── passwords
│ │ ├── email.blade.php
│ │ └── reset.blade.php
│ └── register.blade.php
│ ├── home.blade.php
│ ├── layouts
│ ├── app.blade.php
│ └── nav.blade.php
│ ├── profiles
│ ├── activities
│ │ ├── activity.blade.php
│ │ ├── created_reply.blade.php
│ │ └── created_thread.blade.php
│ └── show.blade.php
│ ├── threads
│ ├── create.blade.php
│ ├── index.blade.php
│ ├── reply.blade.php
│ └── show.blade.php
│ └── welcome.blade.php
├── routes
├── api.php
├── channels.php
├── console.php
└── web.php
├── server.php
├── storage
├── app
│ ├── .gitignore
│ └── public
│ │ └── .gitignore
├── debugbar
│ └── .gitignore
├── framework
│ ├── .gitignore
│ ├── cache
│ │ └── .gitignore
│ ├── sessions
│ │ └── .gitignore
│ ├── testing
│ │ └── .gitignore
│ └── views
│ │ └── .gitignore
└── logs
│ └── .gitignore
├── tests
├── CreatesApplication.php
├── Feature
│ ├── CreateThreadsTest.php
│ ├── FavoritesTest.php
│ ├── NotificationsTest.php
│ ├── ParticipateInForumTest.php
│ ├── ProfilesTest.php
│ ├── ReadThreadsTest.php
│ └── SubscribeToThreadsTest.php
├── TestCase.php
├── Unit
│ ├── ActivityTest.php
│ ├── ChannelTest.php
│ ├── ReplyTest.php
│ └── ThreadTest.php
└── utilities
│ └── functions.php
├── webpack.mix.js
└── yarn.lock
/.env.example:
--------------------------------------------------------------------------------
1 | APP_NAME=Laravel
2 | APP_ENV=local
3 | APP_KEY=
4 | APP_DEBUG=true
5 | APP_LOG_LEVEL=debug
6 | APP_URL=http://localhost
7 |
8 | DB_CONNECTION=mysql
9 | DB_HOST=127.0.0.1
10 | DB_PORT=3306
11 | DB_DATABASE=forum
12 | DB_USERNAME=root
13 | DB_PASSWORD=
14 |
15 | BROADCAST_DRIVER=log
16 | CACHE_DRIVER=file
17 | SESSION_DRIVER=file
18 | QUEUE_DRIVER=sync
19 |
20 | REDIS_HOST=127.0.0.1
21 | REDIS_PASSWORD=null
22 | REDIS_PORT=6379
23 |
24 | MAIL_DRIVER=smtp
25 | MAIL_HOST=smtp.mailtrap.io
26 | MAIL_PORT=2525
27 | MAIL_USERNAME=null
28 | MAIL_PASSWORD=null
29 | MAIL_ENCRYPTION=null
30 |
31 | PUSHER_APP_ID=
32 | PUSHER_APP_KEY=
33 | PUSHER_APP_SECRET=
34 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 | *.css linguist-vendored
3 | *.scss linguist-vendored
4 | *.js linguist-vendored
5 | CHANGELOG.md export-ignore
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 | /public/hot
3 | /public/storage
4 | /storage/*.key
5 | /vendor
6 | /.idea
7 | /.vagrant
8 | Homestead.json
9 | Homestead.yaml
10 | npm-debug.log
11 | .env
12 |
--------------------------------------------------------------------------------
/Procfile:
--------------------------------------------------------------------------------
1 | web: vendor/bin/heroku-php-apache2 public/
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Laravel Forum
2 | ===
3 |
4 | I'm blogging my way through the advanced Laracast course: [Let's Build A Forum with Laravel and TDD](https://laracasts.com/series/lets-build-a-forum-with-laravel/)
5 |
6 | 
7 |
8 | ## Build an online forum with Laravel
9 |
10 | ### [Part 1](https://medium.com/@connorleech/build-an-online-forum-with-laravel-initial-setup-and-seeding-part-1-a53138d1fffc): Initial Setup and Seeding
11 |
12 | ### [Part 2](https://medium.com/@connorleech/test-driven-development-tdd-in-laravel-b5a2bf9ab65b): Create routes, views, controllers. Generate auth. Write test
13 |
14 | ### [Part 3](https://medium.com/@connorleech/build-an-online-forum-with-laravel-analyzing-the-application-part-3-9317a0f893b4): Post and Show Replies to Threads
15 |
16 | ### [Part 4](https://medium.com/@connorleech/build-an-online-forum-with-laravel-give-the-user-the-ability-to-create-threads-part-4-ccdb6badc618): Give the User the ability to create Threads
17 |
18 | ### [Part 5](https://medium.com/@connorleech/testing-helpers-in-laravel-5-4-363ac47a8504): Testing Helpers in Laravel 5.4
19 |
20 | ### Helpful commands
21 |
22 | ```
23 | # Clear cache
24 | $ php artisan cache:clear
25 |
26 | # Run tests
27 | $ phpunit
28 | // OR
29 | $ ./vendor/bin/phpunit
30 |
31 | # Clear config
32 | $ php artisan config:clear
33 |
34 | # Migrate or refresh database
35 | $ php artisan migrate:refresh
36 | $ php artisan migrate:rollback
37 |
38 | # Seed database with db seeders
39 | $ php artisan db:seed
40 |
41 | # Seed database with model factories
42 | $ php artisan tinker
43 | > factory('App\Thread', 50)->create();
44 |
45 | ```
46 |
--------------------------------------------------------------------------------
/app/Activity.php:
--------------------------------------------------------------------------------
1 | morphTo();
15 | }
16 |
17 | // Fetch activity feed for the given user
18 | public static function feed($user, $take = 50)
19 | {
20 | return static::where('user_id', $user->id)
21 | ->latest()
22 | ->with('subject')
23 | ->take($take)
24 | ->get()
25 | ->groupBy(function($activity){
26 | // group by day
27 | return $activity->created_at->format('Y-m-d');
28 | });
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/Channel.php:
--------------------------------------------------------------------------------
1 | hasMany(Thread::class);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/app/Console/Kernel.php:
--------------------------------------------------------------------------------
1 | command('inspire')
28 | // ->hourly();
29 | }
30 |
31 | /**
32 | * Register the Closure based commands for the application.
33 | *
34 | * @return void
35 | */
36 | protected function commands()
37 | {
38 | require base_path('routes/console.php');
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/Exceptions/Handler.php:
--------------------------------------------------------------------------------
1 | expectsJson()) {
60 | return response()->json(['error' => 'Unauthenticated.'], 401);
61 | }
62 |
63 | return redirect()->guest(route('login'));
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/app/Favoritable.php:
--------------------------------------------------------------------------------
1 | favorites->each->delete();
15 | });
16 | }
17 |
18 | public function favorites()
19 | {
20 | // polymorphic relation
21 | return $this->morphMany(Favorite::class, 'favorited');
22 | }
23 |
24 | public function favorite()
25 | {
26 | $attributes = ['user_id' => auth()->id()];
27 |
28 | // check that user has not already favorited the reply
29 | if(! $this->favorites()->where($attributes)->exists()){
30 | // add favorite
31 | $this->favorites()->create($attributes);
32 | }
33 | }
34 |
35 | public function unfavorite()
36 | {
37 | $attributes = ['user_id' => auth()->id()];
38 |
39 | // get favorites of reply, find the logged in user's favorite, delete it
40 | // also deletes associated activity (have to call delete on favorites instance itself)
41 | $this->favorites()->where($attributes)->get()->each->delete();
42 | }
43 |
44 | public function isFavorited()
45 | {
46 | return !! $this->favorites->where('user_id', auth()->id())->count();
47 | }
48 |
49 | public function getIsFavoritedAttribute()
50 | {
51 | return $this->isFavorited();
52 | }
53 |
54 | public function getFavoritesCountAttribute()
55 | {
56 | return $this->favorites->count();
57 | }
58 | }
--------------------------------------------------------------------------------
/app/Favorite.php:
--------------------------------------------------------------------------------
1 | request = $request;
22 | }
23 |
24 | // Apply the filters
25 | public function apply($builder)
26 | {
27 | $this->builder = $builder;
28 |
29 | foreach ($this->getFilters() as $filter => $value){
30 | if(method_exists($this, $filter)){
31 | $this->$filter($value);
32 | }
33 | }
34 |
35 | return $this->builder;
36 | }
37 |
38 | // Fetch all relevant filters from the request
39 | public function getFilters()
40 | {
41 | return $this->request->intersect($this->filters);
42 | }
43 | }
--------------------------------------------------------------------------------
/app/Filters/ThreadFilters.php:
--------------------------------------------------------------------------------
1 | firstOrFail();
16 |
17 | return $this->builder->where('user_id', $user->id);
18 | }
19 |
20 | // Filter query according to most popular threads
21 | protected function popular()
22 | {
23 | // remove orders
24 | $this->builder->getQuery()->orders = [];
25 |
26 | // order by popularity
27 | return $this->builder->orderBy('replies_count', 'desc');
28 | }
29 |
30 | protected function unanswered()
31 | {
32 | return $this->builder->where('replies_count', 0);
33 | }
34 | }
--------------------------------------------------------------------------------
/app/Http/Controllers/Auth/ForgotPasswordController.php:
--------------------------------------------------------------------------------
1 | middleware('guest');
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Auth/LoginController.php:
--------------------------------------------------------------------------------
1 | middleware('guest')->except('logout');
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Auth/RegisterController.php:
--------------------------------------------------------------------------------
1 | middleware('guest');
40 | }
41 |
42 | /**
43 | * Get a validator for an incoming registration request.
44 | *
45 | * @param array $data
46 | * @return \Illuminate\Contracts\Validation\Validator
47 | */
48 | protected function validator(array $data)
49 | {
50 | return Validator::make($data, [
51 | 'name' => 'required|string|max:255',
52 | 'email' => 'required|string|email|max:255|unique:users',
53 | 'password' => 'required|string|min:6|confirmed',
54 | ]);
55 | }
56 |
57 | /**
58 | * Create a new user instance after a valid registration.
59 | *
60 | * @param array $data
61 | * @return User
62 | */
63 | protected function create(array $data)
64 | {
65 | return User::create([
66 | 'name' => $data['name'],
67 | 'email' => $data['email'],
68 | 'password' => bcrypt($data['password']),
69 | ]);
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Auth/ResetPasswordController.php:
--------------------------------------------------------------------------------
1 | middleware('guest');
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Controller.php:
--------------------------------------------------------------------------------
1 | middleware('auth');
16 | }
17 |
18 | public function store(Reply $reply)
19 | {
20 | $reply->favorite();
21 |
22 | return back();
23 | }
24 |
25 | public function destroy(Reply $reply)
26 | {
27 | $reply->unfavorite();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/Http/Controllers/HomeController.php:
--------------------------------------------------------------------------------
1 | middleware('auth');
17 | }
18 |
19 | /**
20 | * Show the application dashboard.
21 | *
22 | * @return \Illuminate\Http\Response
23 | */
24 | public function index()
25 | {
26 | return view('home');
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/app/Http/Controllers/ProfilesController.php:
--------------------------------------------------------------------------------
1 | $user,
16 | 'activities' => Activity::feed($user)
17 | ]);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/app/Http/Controllers/RepliesController.php:
--------------------------------------------------------------------------------
1 | middleware('auth', ['except' => 'index']);
13 | }
14 |
15 | public function index($channelId, Thread $thread)
16 | {
17 | return $thread->replies()->paginate(20);
18 | }
19 |
20 | public function store($channelId, Thread $thread)
21 | {
22 | $this->validate(request(), [
23 | 'body' => 'required'
24 | ]);
25 |
26 | $reply = $thread->addReply([
27 | 'body' => request('body'),
28 | 'user_id' => auth()->id()
29 | ]);
30 |
31 | if(request()->expectsJson()){
32 | // send reply with owner data for ajax requests
33 | return $reply->load('owner');
34 | }
35 |
36 | return back()->with('flash', 'Your reply has been left');
37 | }
38 |
39 | public function update(Reply $reply)
40 | {
41 | $this->authorize('update', $reply);
42 |
43 | $this->validate(request(), ['body' => 'required']);
44 |
45 | $reply->update([
46 | 'body' => request('body')
47 | ]);
48 | }
49 |
50 | public function destroy(Reply $reply){
51 |
52 | $this->authorize('update', $reply);
53 | $reply->delete();
54 |
55 | // for ajax delete
56 | if(request()->expectsJson()){
57 | return response(['status' => 'Reply deleted']);
58 | }
59 |
60 | return back();
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/app/Http/Controllers/ThreadController.php:
--------------------------------------------------------------------------------
1 | middleware('auth')->except(['index', 'show']);
19 | }
20 |
21 | /**
22 | * Display a listing of the resource.
23 | */
24 | public function index(Channel $channel, ThreadFilters $filters)
25 | {
26 |
27 | $threads = $this->getThreads($channel, $filters);
28 |
29 | if(request()->wantsJson()){
30 | return $threads;
31 | }
32 |
33 | return view('threads.index', compact('threads'));
34 | }
35 |
36 | /**
37 | * Show the form for creating a new resource.
38 | */
39 | public function create()
40 | {
41 | return view('threads.create');
42 | }
43 |
44 | /**
45 | * Store a newly created resource in storage.
46 | */
47 | public function store(Request $request)
48 | {
49 | $this->validate($request, [
50 | 'title' => 'required',
51 | 'body' => 'required',
52 | 'channel_id' => 'required|exists:channels,id' // laravel validation helpers
53 | ]);
54 |
55 | $thread = Thread::create([
56 | 'user_id' => auth()->id(),
57 | 'channel_id' => request('channel_id'),
58 | 'title' => request('title'),
59 | 'body' => request('body')
60 | ]);
61 |
62 | return redirect($thread->path())
63 | ->with('flash', 'Your thread has been published!');
64 | }
65 |
66 | /**
67 | * Display the specified resource.
68 | */
69 | public function show($channel, Thread $thread)
70 | {
71 | return view('threads.show', compact('thread'));
72 | }
73 |
74 | /**
75 | * Show the form for editing the specified resource.
76 | */
77 | public function edit(Thread $thread)
78 | {
79 | //
80 | }
81 |
82 | /**
83 | * Update the specified resource in storage.
84 | */
85 | public function update(Request $request, Thread $thread)
86 | {
87 | //
88 | }
89 |
90 | /**
91 | * Remove the specified resource from storage.
92 | */
93 | public function destroy($channel, Thread $thread)
94 | {
95 | // check that it is signed in user's thread
96 | // https://laravel.com/docs/5.4/authorization#via-controller-helpers
97 | $this->authorize('update', $thread);
98 |
99 | $thread->delete();
100 |
101 | if(request()->wantsJson()){
102 | return response([], 204);
103 | }
104 |
105 | return redirect('/threads');
106 | }
107 |
108 | // Fetch all relevant threads
109 | public function getThreads(Channel $channel, ThreadFilters $filters)
110 | {
111 | $threads = Thread::latest()->filter($filters);
112 | if($channel->exists){
113 | $threads->where('channel_id', $channel->id);
114 | }
115 |
116 | return $threads->get();
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/app/Http/Controllers/ThreadSubscriptionsController.php:
--------------------------------------------------------------------------------
1 | subscribe();
12 | }
13 |
14 | public function destroy($channelId, Thread $thread)
15 | {
16 | $thread->unsubscribe();
17 | }
18 | }
--------------------------------------------------------------------------------
/app/Http/Controllers/UserNotificationsController.php:
--------------------------------------------------------------------------------
1 | middleware('auth');
13 | }
14 |
15 | public function index(User $user)
16 | {
17 | return auth()->user()->unreadNotifications;
18 | }
19 |
20 | public function destroy(User $user, $notificationId)
21 | {
22 | auth()->user()->notifications()->findOrFail($notificationId)->markAsRead();
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/Http/Kernel.php:
--------------------------------------------------------------------------------
1 | [
30 | \App\Http\Middleware\EncryptCookies::class,
31 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
32 | \Illuminate\Session\Middleware\StartSession::class,
33 | // \Illuminate\Session\Middleware\AuthenticateSession::class,
34 | \Illuminate\View\Middleware\ShareErrorsFromSession::class,
35 | \App\Http\Middleware\VerifyCsrfToken::class,
36 | \Illuminate\Routing\Middleware\SubstituteBindings::class,
37 | ],
38 |
39 | 'api' => [
40 | 'throttle:60,1',
41 | 'bindings',
42 | ],
43 | ];
44 |
45 | /**
46 | * The application's route middleware.
47 | *
48 | * These middleware may be assigned to groups or used individually.
49 | *
50 | * @var array
51 | */
52 | protected $routeMiddleware = [
53 | 'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
54 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
55 | 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
56 | 'can' => \Illuminate\Auth\Middleware\Authorize::class,
57 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
58 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
59 | ];
60 | }
61 |
--------------------------------------------------------------------------------
/app/Http/Middleware/EncryptCookies.php:
--------------------------------------------------------------------------------
1 | check()) {
21 | return redirect('/home');
22 | }
23 |
24 | return $next($request);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/Http/Middleware/TrimStrings.php:
--------------------------------------------------------------------------------
1 | thread = $thread;
25 | $this->reply = $reply;
26 | }
27 |
28 | /**
29 | * Get the notification's delivery channels.
30 | *
31 | * @param mixed $notifiable
32 | * @return array
33 | */
34 | public function via($notifiable)
35 | {
36 | return ['database'];
37 | }
38 |
39 | /**
40 | * Get the array representation of the notification.
41 | *
42 | * @param mixed $notifiable
43 | * @return array
44 | */
45 | public function toArray()
46 | {
47 | return [
48 | 'message' => $this->reply->owner->name . " replied to " . $this->thread->title,
49 | 'link' => $this->reply->path()
50 | ];
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/app/Policies/ReplyPolicy.php:
--------------------------------------------------------------------------------
1 | user_id == $user->id;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/app/Policies/ThreadPolicy.php:
--------------------------------------------------------------------------------
1 | user_id == $user->id;
46 | }
47 |
48 | /**
49 | * Determine whether the user can delete the thread.
50 | *
51 | * @param \App\User $user
52 | * @param \App\Thread $thread
53 | * @return mixed
54 | */
55 | public function delete(User $user, Thread $thread)
56 | {
57 | //
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/app/Providers/AppServiceProvider.php:
--------------------------------------------------------------------------------
1 | with('channels', $channels);
23 | });
24 |
25 | // For Heroku
26 | // https://laravel-news.com/laravel-5-4-key-too-long-error
27 | \Schema::defaultStringLength(191);
28 | }
29 |
30 | /**
31 | * Register any application services.
32 | *
33 | * @return void
34 | */
35 | public function register()
36 | {
37 | if($this->app->isLocal()){
38 | $this->app->register(\Barryvdh\Debugbar\ServiceProvider::class);
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/Providers/AuthServiceProvider.php:
--------------------------------------------------------------------------------
1 | 'App\Policies\ThreadPolicy',
17 | 'App\Reply' => 'App\Policies\ReplyPolicy',
18 |
19 | ];
20 |
21 | /**
22 | * Register any authentication / authorization services.
23 | *
24 | * @return void
25 | */
26 | public function boot()
27 | {
28 | $this->registerPolicies();
29 |
30 | // if return true in before method, instantly authorized
31 | // Gate::before(function($user){
32 | // if($user->name == 'Connor Leech') return true;
33 | // });
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/app/Providers/BroadcastServiceProvider.php:
--------------------------------------------------------------------------------
1 | [
17 | 'App\Listeners\EventListener',
18 | ],
19 | ];
20 |
21 | /**
22 | * Register any events for your application.
23 | *
24 | * @return void
25 | */
26 | public function boot()
27 | {
28 | parent::boot();
29 |
30 | //
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/app/Providers/RouteServiceProvider.php:
--------------------------------------------------------------------------------
1 | mapApiRoutes();
39 |
40 | $this->mapWebRoutes();
41 |
42 | //
43 | }
44 |
45 | /**
46 | * Define the "web" routes for the application.
47 | *
48 | * These routes all receive session state, CSRF protection, etc.
49 | *
50 | * @return void
51 | */
52 | protected function mapWebRoutes()
53 | {
54 | Route::middleware('web')
55 | ->namespace($this->namespace)
56 | ->group(base_path('routes/web.php'));
57 | }
58 |
59 | /**
60 | * Define the "api" routes for the application.
61 | *
62 | * These routes are typically stateless.
63 | *
64 | * @return void
65 | */
66 | protected function mapApiRoutes()
67 | {
68 | Route::prefix('api')
69 | ->middleware('api')
70 | ->namespace($this->namespace)
71 | ->group(base_path('routes/api.php'));
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/app/RecordsActivity.php:
--------------------------------------------------------------------------------
1 | guest()) return;
12 |
13 | foreach (static::getActivitiesToRecord() as $event) {
14 | static::$event(function($model) use ($event){
15 | $model->recordActivity($event);
16 | });
17 | }
18 |
19 | static::deleting(function($model){
20 | $model->activity()->delete();
21 | });
22 | }
23 |
24 | // Fetch all model events that require activity recording
25 | protected static function getActivitiesToRecord()
26 | {
27 | return ['created'];
28 | }
29 |
30 | // Record new activity for the model
31 | protected function recordActivity($event)
32 | {
33 | $this->activity()->create([
34 | 'user_id' => auth()->id(),
35 | 'type' => $this->getActivityType($event)
36 | ]);
37 | }
38 |
39 | // Fetch the activity relationship
40 | protected function activity()
41 | {
42 | // https://laravel.com/docs/5.4/eloquent-relationships#polymorphic-relations
43 | return $this->morphMany('App\Activity', 'subject');
44 | }
45 |
46 | // Determine the activity type
47 | protected function getActivityType($event)
48 | {
49 | $type = strtolower((new \ReflectionClass($this))->getShortName());
50 | return "{$event}_{$type}";
51 | }
52 | }
--------------------------------------------------------------------------------
/app/Reply.php:
--------------------------------------------------------------------------------
1 | thread->increment('replies_count');
27 | });
28 |
29 | static::deleted(function($reply){
30 | $reply->thread->decrement('replies_count');
31 | });
32 | }
33 |
34 | // A Reply has an owner
35 | public function owner()
36 | {
37 | return $this->belongsTo(User::class, 'user_id');
38 | }
39 |
40 | public function thread()
41 | {
42 | return $this->belongsTo(Thread::class);
43 | }
44 |
45 | public function path()
46 | {
47 | return $this->thread->path() . "#reply-{$this->id}";
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/app/Thread.php:
--------------------------------------------------------------------------------
1 | replies->each->delete();
30 | });
31 | }
32 |
33 | public function path()
34 | {
35 | return "/threads/{$this->channel->slug}/{$this->id}";
36 | }
37 |
38 | public function replies()
39 | {
40 | return $this->hasMany(Reply::class);
41 | }
42 |
43 | public function creator()
44 | {
45 | return $this->belongsTo(User::class, 'user_id');
46 | }
47 |
48 | public function channel()
49 | {
50 | return $this->belongsTo(Channel::class);
51 | }
52 |
53 | public function addReply($reply)
54 | {
55 | // create and save the reply
56 | $reply = $this->replies()->create($reply);
57 |
58 | $this->subscriptions
59 | // get subscribers that did not leave the reply
60 | ->where('user_id', '!=', $reply->user_id)
61 | // send each of them a notification
62 | ->each->notify($reply);
63 |
64 | return $reply;
65 | }
66 |
67 | // Apply all the relevant thread filters
68 | public function scopeFilter($query, ThreadFilters $filters)
69 | {
70 | return $filters->apply($query);
71 | }
72 |
73 | // a thread can have many subscriptions
74 | public function subscriptions()
75 | {
76 | return $this->hasMany(ThreadSubscription::class);
77 | }
78 |
79 | // Determine if current user is subscribed to a thread
80 | // 'custom eloquent accessor'
81 | public function getIsSubscribedToAttribute()
82 | {
83 | return $this->subscriptions()
84 | ->where('user_id', auth()->id())
85 | ->exists();
86 | }
87 |
88 | public function subscribe($userId = null)
89 | {
90 | $this->subscriptions()->create([
91 | 'user_id' => $userId ?: auth()->id()
92 | ]);
93 |
94 | return $this;
95 | }
96 |
97 | public function unsubscribe($userId = null)
98 | {
99 | $this->subscriptions()
100 | ->where('user_id', $userId ?: auth()->id())
101 | ->delete();
102 |
103 | return $this;
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/app/ThreadSubscription.php:
--------------------------------------------------------------------------------
1 | belongsTo(User::class);
16 | }
17 |
18 | public function thread()
19 | {
20 | return $this->belongsTo(Thread::class);
21 | }
22 |
23 | // send notification to user
24 | public function notify($reply)
25 | {
26 | $this->user->notify(new ThreadWasUpdated($this->thread, $reply));
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/app/User.php:
--------------------------------------------------------------------------------
1 | hasMany(Thread::class)->latest();
37 | }
38 |
39 | // Get route key name for Laravel
40 | public function getRouteKeyName()
41 | {
42 | return 'name';
43 | }
44 |
45 | // Get all activity for the user
46 | public function activity()
47 | {
48 | return $this->hasMany(Activity::class);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/artisan:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env php
2 | make(Illuminate\Contracts\Console\Kernel::class);
32 |
33 | $status = $kernel->handle(
34 | $input = new Symfony\Component\Console\Input\ArgvInput,
35 | new Symfony\Component\Console\Output\ConsoleOutput
36 | );
37 |
38 | /*
39 | |--------------------------------------------------------------------------
40 | | Shutdown The Application
41 | |--------------------------------------------------------------------------
42 | |
43 | | Once Artisan has finished running. We will fire off the shutdown events
44 | | so that any final work may be done by the application before we shut
45 | | down the process. This is the last thing to happen to the request.
46 | |
47 | */
48 |
49 | $kernel->terminate($input, $status);
50 |
51 | exit($status);
52 |
--------------------------------------------------------------------------------
/bootstrap/app.php:
--------------------------------------------------------------------------------
1 | singleton(
30 | Illuminate\Contracts\Http\Kernel::class,
31 | App\Http\Kernel::class
32 | );
33 |
34 | $app->singleton(
35 | Illuminate\Contracts\Console\Kernel::class,
36 | App\Console\Kernel::class
37 | );
38 |
39 | $app->singleton(
40 | Illuminate\Contracts\Debug\ExceptionHandler::class,
41 | App\Exceptions\Handler::class
42 | );
43 |
44 | /*
45 | |--------------------------------------------------------------------------
46 | | Return The Application
47 | |--------------------------------------------------------------------------
48 | |
49 | | This script returns the application instance. The instance is given to
50 | | the calling script so we can separate the building of the instances
51 | | from the actual running of the application and sending responses.
52 | |
53 | */
54 |
55 | return $app;
56 |
--------------------------------------------------------------------------------
/bootstrap/autoload.php:
--------------------------------------------------------------------------------
1 | =5.6.4",
9 | "laravel/framework": "5.4.*",
10 | "laravel/tinker": "~1.0",
11 | "rap2hpoutre/laravel-log-viewer": "^0.10.4"
12 | },
13 | "require-dev": {
14 | "fzaninotto/faker": "~1.4",
15 | "mockery/mockery": "0.9.*",
16 | "phpunit/phpunit": "~5.7"
17 | },
18 | "autoload": {
19 | "classmap": [
20 | "database"
21 | ],
22 | "psr-4": {
23 | "App\\": "app/"
24 | }
25 | },
26 | "autoload-dev": {
27 | "psr-4": {
28 | "Tests\\": "tests/"
29 | },
30 | "files": ["tests/utilities/functions.php"]
31 | },
32 | "scripts": {
33 | "post-root-package-install": [
34 | "php -r \"file_exists('.env') || copy('.env.example', '.env');\""
35 | ],
36 | "post-create-project-cmd": [
37 | "php artisan key:generate"
38 | ],
39 | "post-install-cmd": [
40 | "Illuminate\\Foundation\\ComposerScripts::postInstall",
41 | "php artisan optimize"
42 | ],
43 | "post-update-cmd": [
44 | "Illuminate\\Foundation\\ComposerScripts::postUpdate",
45 | "php artisan optimize"
46 | ]
47 | },
48 | "config": {
49 | "preferred-install": "dist",
50 | "sort-packages": true,
51 | "optimize-autoloader": true
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/config/app.php:
--------------------------------------------------------------------------------
1 | env('APP_NAME', 'Laravel Forum'),
16 |
17 | /*
18 | |--------------------------------------------------------------------------
19 | | Application Environment
20 | |--------------------------------------------------------------------------
21 | |
22 | | This value determines the "environment" your application is currently
23 | | running in. This may determine how you prefer to configure various
24 | | services your application utilizes. Set this in your ".env" file.
25 | |
26 | */
27 |
28 | 'env' => env('APP_ENV', 'production'),
29 |
30 | /*
31 | |--------------------------------------------------------------------------
32 | | Application Debug Mode
33 | |--------------------------------------------------------------------------
34 | |
35 | | When your application is in debug mode, detailed error messages with
36 | | stack traces will be shown on every error that occurs within your
37 | | application. If disabled, a simple generic error page is shown.
38 | |
39 | */
40 |
41 | 'debug' => env('APP_DEBUG', true),
42 |
43 | /*
44 | |--------------------------------------------------------------------------
45 | | Application URL
46 | |--------------------------------------------------------------------------
47 | |
48 | | This URL is used by the console to properly generate URLs when using
49 | | the Artisan command line tool. You should set this to the root of
50 | | your application so that it is used when running Artisan tasks.
51 | |
52 | */
53 |
54 | 'url' => env('APP_URL', 'http://localhost'),
55 |
56 | /*
57 | |--------------------------------------------------------------------------
58 | | Application Timezone
59 | |--------------------------------------------------------------------------
60 | |
61 | | Here you may specify the default timezone for your application, which
62 | | will be used by the PHP date and date-time functions. We have gone
63 | | ahead and set this to a sensible default for you out of the box.
64 | |
65 | */
66 |
67 | 'timezone' => 'UTC',
68 |
69 | /*
70 | |--------------------------------------------------------------------------
71 | | Application Locale Configuration
72 | |--------------------------------------------------------------------------
73 | |
74 | | The application locale determines the default locale that will be used
75 | | by the translation service provider. You are free to set this value
76 | | to any of the locales which will be supported by the application.
77 | |
78 | */
79 |
80 | 'locale' => 'en',
81 |
82 | /*
83 | |--------------------------------------------------------------------------
84 | | Application Fallback Locale
85 | |--------------------------------------------------------------------------
86 | |
87 | | The fallback locale determines the locale to use when the current one
88 | | is not available. You may change the value to correspond to any of
89 | | the language folders that are provided through your application.
90 | |
91 | */
92 |
93 | 'fallback_locale' => 'en',
94 |
95 | /*
96 | |--------------------------------------------------------------------------
97 | | Encryption Key
98 | |--------------------------------------------------------------------------
99 | |
100 | | This key is used by the Illuminate encrypter service and should be set
101 | | to a random, 32 character string, otherwise these encrypted strings
102 | | will not be safe. Please do this before deploying an application!
103 | |
104 | */
105 |
106 | 'key' => env('APP_KEY'),
107 |
108 | 'cipher' => 'AES-256-CBC',
109 |
110 | /*
111 | |--------------------------------------------------------------------------
112 | | Logging Configuration
113 | |--------------------------------------------------------------------------
114 | |
115 | | Here you may configure the log settings for your application. Out of
116 | | the box, Laravel uses the Monolog PHP logging library. This gives
117 | | you a variety of powerful log handlers / formatters to utilize.
118 | |
119 | | Available Settings: "single", "daily", "syslog", "errorlog"
120 | |
121 | */
122 |
123 | 'log' => env('APP_LOG', 'single'),
124 |
125 | 'log_level' => env('APP_LOG_LEVEL', 'debug'),
126 |
127 | /*
128 | |--------------------------------------------------------------------------
129 | | Autoloaded Service Providers
130 | |--------------------------------------------------------------------------
131 | |
132 | | The service providers listed here will be automatically loaded on the
133 | | request to your application. Feel free to add your own services to
134 | | this array to grant expanded functionality to your applications.
135 | |
136 | */
137 |
138 | 'providers' => [
139 |
140 | /*
141 | * Laravel Framework Service Providers...
142 | */
143 | Illuminate\Auth\AuthServiceProvider::class,
144 | Illuminate\Broadcasting\BroadcastServiceProvider::class,
145 | Illuminate\Bus\BusServiceProvider::class,
146 | Illuminate\Cache\CacheServiceProvider::class,
147 | Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
148 | Illuminate\Cookie\CookieServiceProvider::class,
149 | Illuminate\Database\DatabaseServiceProvider::class,
150 | Illuminate\Encryption\EncryptionServiceProvider::class,
151 | Illuminate\Filesystem\FilesystemServiceProvider::class,
152 | Illuminate\Foundation\Providers\FoundationServiceProvider::class,
153 | Illuminate\Hashing\HashServiceProvider::class,
154 | Illuminate\Mail\MailServiceProvider::class,
155 | Illuminate\Notifications\NotificationServiceProvider::class,
156 | Illuminate\Pagination\PaginationServiceProvider::class,
157 | Illuminate\Pipeline\PipelineServiceProvider::class,
158 | Illuminate\Queue\QueueServiceProvider::class,
159 | Illuminate\Redis\RedisServiceProvider::class,
160 | Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
161 | Illuminate\Session\SessionServiceProvider::class,
162 | Illuminate\Translation\TranslationServiceProvider::class,
163 | Illuminate\Validation\ValidationServiceProvider::class,
164 | Illuminate\View\ViewServiceProvider::class,
165 |
166 | /*
167 | * Package Service Providers...
168 | */
169 | Laravel\Tinker\TinkerServiceProvider::class,
170 | Rap2hpoutre\LaravelLogViewer\LaravelLogViewerServiceProvider::class,
171 |
172 | /*
173 | * Application Service Providers...
174 | */
175 | App\Providers\AppServiceProvider::class,
176 | App\Providers\AuthServiceProvider::class,
177 | // App\Providers\BroadcastServiceProvider::class,
178 | App\Providers\EventServiceProvider::class,
179 | App\Providers\RouteServiceProvider::class,
180 |
181 | ],
182 |
183 | /*
184 | |--------------------------------------------------------------------------
185 | | Class Aliases
186 | |--------------------------------------------------------------------------
187 | |
188 | | This array of class aliases will be registered when this application
189 | | is started. However, feel free to register as many as you wish as
190 | | the aliases are "lazy" loaded so they don't hinder performance.
191 | |
192 | */
193 |
194 | 'aliases' => [
195 |
196 | 'App' => Illuminate\Support\Facades\App::class,
197 | 'Artisan' => Illuminate\Support\Facades\Artisan::class,
198 | 'Auth' => Illuminate\Support\Facades\Auth::class,
199 | 'Blade' => Illuminate\Support\Facades\Blade::class,
200 | 'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
201 | 'Bus' => Illuminate\Support\Facades\Bus::class,
202 | 'Cache' => Illuminate\Support\Facades\Cache::class,
203 | 'Config' => Illuminate\Support\Facades\Config::class,
204 | 'Cookie' => Illuminate\Support\Facades\Cookie::class,
205 | 'Crypt' => Illuminate\Support\Facades\Crypt::class,
206 | 'DB' => Illuminate\Support\Facades\DB::class,
207 | 'Eloquent' => Illuminate\Database\Eloquent\Model::class,
208 | 'Event' => Illuminate\Support\Facades\Event::class,
209 | 'File' => Illuminate\Support\Facades\File::class,
210 | 'Gate' => Illuminate\Support\Facades\Gate::class,
211 | 'Hash' => Illuminate\Support\Facades\Hash::class,
212 | 'Lang' => Illuminate\Support\Facades\Lang::class,
213 | 'Log' => Illuminate\Support\Facades\Log::class,
214 | 'Mail' => Illuminate\Support\Facades\Mail::class,
215 | 'Notification' => Illuminate\Support\Facades\Notification::class,
216 | 'Password' => Illuminate\Support\Facades\Password::class,
217 | 'Queue' => Illuminate\Support\Facades\Queue::class,
218 | 'Redirect' => Illuminate\Support\Facades\Redirect::class,
219 | 'Redis' => Illuminate\Support\Facades\Redis::class,
220 | 'Request' => Illuminate\Support\Facades\Request::class,
221 | 'Response' => Illuminate\Support\Facades\Response::class,
222 | 'Route' => Illuminate\Support\Facades\Route::class,
223 | 'Schema' => Illuminate\Support\Facades\Schema::class,
224 | 'Session' => Illuminate\Support\Facades\Session::class,
225 | 'Storage' => Illuminate\Support\Facades\Storage::class,
226 | 'URL' => Illuminate\Support\Facades\URL::class,
227 | 'Validator' => Illuminate\Support\Facades\Validator::class,
228 | 'View' => Illuminate\Support\Facades\View::class,
229 |
230 | ],
231 |
232 | ];
233 |
--------------------------------------------------------------------------------
/config/auth.php:
--------------------------------------------------------------------------------
1 | [
17 | 'guard' => 'web',
18 | 'passwords' => 'users',
19 | ],
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | Authentication Guards
24 | |--------------------------------------------------------------------------
25 | |
26 | | Next, you may define every authentication guard for your application.
27 | | Of course, a great default configuration has been defined for you
28 | | here which uses session storage and the Eloquent user provider.
29 | |
30 | | All authentication drivers have a user provider. This defines how the
31 | | users are actually retrieved out of your database or other storage
32 | | mechanisms used by this application to persist your user's data.
33 | |
34 | | Supported: "session", "token"
35 | |
36 | */
37 |
38 | 'guards' => [
39 | 'web' => [
40 | 'driver' => 'session',
41 | 'provider' => 'users',
42 | ],
43 |
44 | 'api' => [
45 | 'driver' => 'token',
46 | 'provider' => 'users',
47 | ],
48 | ],
49 |
50 | /*
51 | |--------------------------------------------------------------------------
52 | | User Providers
53 | |--------------------------------------------------------------------------
54 | |
55 | | All authentication drivers have a user provider. This defines how the
56 | | users are actually retrieved out of your database or other storage
57 | | mechanisms used by this application to persist your user's data.
58 | |
59 | | If you have multiple user tables or models you may configure multiple
60 | | sources which represent each model / table. These sources may then
61 | | be assigned to any extra authentication guards you have defined.
62 | |
63 | | Supported: "database", "eloquent"
64 | |
65 | */
66 |
67 | 'providers' => [
68 | 'users' => [
69 | 'driver' => 'eloquent',
70 | 'model' => App\User::class,
71 | ],
72 |
73 | // 'users' => [
74 | // 'driver' => 'database',
75 | // 'table' => 'users',
76 | // ],
77 | ],
78 |
79 | /*
80 | |--------------------------------------------------------------------------
81 | | Resetting Passwords
82 | |--------------------------------------------------------------------------
83 | |
84 | | You may specify multiple password reset configurations if you have more
85 | | than one user table or model in the application and you want to have
86 | | separate password reset settings based on the specific user types.
87 | |
88 | | The expire time is the number of minutes that the reset token should be
89 | | considered valid. This security feature keeps tokens short-lived so
90 | | they have less time to be guessed. You may change this as needed.
91 | |
92 | */
93 |
94 | 'passwords' => [
95 | 'users' => [
96 | 'provider' => 'users',
97 | 'table' => 'password_resets',
98 | 'expire' => 60,
99 | ],
100 | ],
101 |
102 | ];
103 |
--------------------------------------------------------------------------------
/config/broadcasting.php:
--------------------------------------------------------------------------------
1 | env('BROADCAST_DRIVER', 'null'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Broadcast Connections
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may define all of the broadcast connections that will be used
26 | | to broadcast events to other systems or over websockets. Samples of
27 | | each available type of connection are provided inside this array.
28 | |
29 | */
30 |
31 | 'connections' => [
32 |
33 | 'pusher' => [
34 | 'driver' => 'pusher',
35 | 'key' => env('PUSHER_APP_KEY'),
36 | 'secret' => env('PUSHER_APP_SECRET'),
37 | 'app_id' => env('PUSHER_APP_ID'),
38 | 'options' => [
39 | //
40 | ],
41 | ],
42 |
43 | 'redis' => [
44 | 'driver' => 'redis',
45 | 'connection' => 'default',
46 | ],
47 |
48 | 'log' => [
49 | 'driver' => 'log',
50 | ],
51 |
52 | 'null' => [
53 | 'driver' => 'null',
54 | ],
55 |
56 | ],
57 |
58 | ];
59 |
--------------------------------------------------------------------------------
/config/cache.php:
--------------------------------------------------------------------------------
1 | env('CACHE_DRIVER', 'file'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Cache Stores
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may define all of the cache "stores" for your application as
26 | | well as their drivers. You may even define multiple stores for the
27 | | same cache driver to group types of items stored in your caches.
28 | |
29 | */
30 |
31 | 'stores' => [
32 |
33 | 'apc' => [
34 | 'driver' => 'apc',
35 | ],
36 |
37 | 'array' => [
38 | 'driver' => 'array',
39 | ],
40 |
41 | 'database' => [
42 | 'driver' => 'database',
43 | 'table' => 'cache',
44 | 'connection' => null,
45 | ],
46 |
47 | 'file' => [
48 | 'driver' => 'file',
49 | 'path' => storage_path('framework/cache/data'),
50 | ],
51 |
52 | 'memcached' => [
53 | 'driver' => 'memcached',
54 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
55 | 'sasl' => [
56 | env('MEMCACHED_USERNAME'),
57 | env('MEMCACHED_PASSWORD'),
58 | ],
59 | 'options' => [
60 | // Memcached::OPT_CONNECT_TIMEOUT => 2000,
61 | ],
62 | 'servers' => [
63 | [
64 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'),
65 | 'port' => env('MEMCACHED_PORT', 11211),
66 | 'weight' => 100,
67 | ],
68 | ],
69 | ],
70 |
71 | 'redis' => [
72 | 'driver' => 'redis',
73 | 'connection' => 'default',
74 | ],
75 |
76 | ],
77 |
78 | /*
79 | |--------------------------------------------------------------------------
80 | | Cache Key Prefix
81 | |--------------------------------------------------------------------------
82 | |
83 | | When utilizing a RAM based store such as APC or Memcached, there might
84 | | be other applications utilizing the same cache. So, we'll specify a
85 | | value to get prefixed to all our keys so we can avoid collisions.
86 | |
87 | */
88 |
89 | 'prefix' => 'laravel',
90 |
91 | ];
92 |
--------------------------------------------------------------------------------
/config/database.php:
--------------------------------------------------------------------------------
1 | 'mysql',
13 | 'host' => $host,
14 | 'database' => $database,
15 | 'username' => $username,
16 | 'password' => $password,
17 | 'port' => env('DB_PORT', 3306),
18 | 'charset' => 'utf8mb4',
19 | 'collation' => 'utf8mb4_unicode_ci',
20 | 'prefix' => ''
21 | ];
22 |
23 | } else {
24 |
25 | $mySqlConfig = [
26 | 'driver' => 'mysql',
27 | 'host' => env('DB_HOST', '127.0.0.1'),
28 | 'port' => env('DB_PORT', '3306'),
29 | 'database' => env('DB_DATABASE', 'forge'),
30 | 'username' => env('DB_USERNAME', 'forge'),
31 | 'password' => env('DB_PASSWORD', ''),
32 | 'unix_socket' => env('DB_SOCKET', ''),
33 | 'charset' => 'utf8mb4',
34 | 'collation' => 'utf8mb4_unicode_ci',
35 | 'prefix' => '',
36 | 'strict' => true,
37 | 'engine' => null,
38 | ];
39 | }
40 |
41 | return [
42 |
43 | /*
44 | |--------------------------------------------------------------------------
45 | | Default Database Connection Name
46 | |--------------------------------------------------------------------------
47 | |
48 | | Here you may specify which of the database connections below you wish
49 | | to use as your default connection for all database work. Of course
50 | | you may use many connections at once using the Database library.
51 | |
52 | */
53 |
54 | 'default' => env('DB_CONNECTION', 'mysql'),
55 |
56 | /*
57 | |--------------------------------------------------------------------------
58 | | Database Connections
59 | |--------------------------------------------------------------------------
60 | |
61 | | Here are each of the database connections setup for your application.
62 | | Of course, examples of configuring each database platform that is
63 | | supported by Laravel is shown below to make development simple.
64 | |
65 | |
66 | | All database work in Laravel is done through the PHP PDO facilities
67 | | so make sure you have the driver for your particular database of
68 | | choice installed on your machine before you begin development.
69 | |
70 | */
71 |
72 | 'connections' => [
73 |
74 | 'sqlite' => [
75 | 'driver' => 'sqlite',
76 | 'database' => env('DB_DATABASE', database_path('database.sqlite')),
77 | 'prefix' => '',
78 | ],
79 |
80 | 'mysql' => $mySqlConfig,
81 |
82 | 'pgsql' => [
83 | 'driver' => 'pgsql',
84 | 'host' => env('DB_HOST', '127.0.0.1'),
85 | 'port' => env('DB_PORT', '5432'),
86 | 'database' => env('DB_DATABASE', 'forge'),
87 | 'username' => env('DB_USERNAME', 'forge'),
88 | 'password' => env('DB_PASSWORD', ''),
89 | 'charset' => 'utf8',
90 | 'prefix' => '',
91 | 'schema' => 'public',
92 | 'sslmode' => 'prefer',
93 | ],
94 |
95 | ],
96 |
97 | /*
98 | |--------------------------------------------------------------------------
99 | | Migration Repository Table
100 | |--------------------------------------------------------------------------
101 | |
102 | | This table keeps track of all the migrations that have already run for
103 | | your application. Using this information, we can determine which of
104 | | the migrations on disk haven't actually been run in the database.
105 | |
106 | */
107 |
108 | 'migrations' => 'migrations',
109 |
110 | /*
111 | |--------------------------------------------------------------------------
112 | | Redis Databases
113 | |--------------------------------------------------------------------------
114 | |
115 | | Redis is an open source, fast, and advanced key-value store that also
116 | | provides a richer set of commands than a typical key-value systems
117 | | such as APC or Memcached. Laravel makes it easy to dig right in.
118 | |
119 | */
120 |
121 | 'redis' => [
122 |
123 | 'client' => 'predis',
124 |
125 | 'default' => [
126 | 'host' => env('REDIS_HOST', '127.0.0.1'),
127 | 'password' => env('REDIS_PASSWORD', null),
128 | 'port' => env('REDIS_PORT', 6379),
129 | 'database' => 0,
130 | ],
131 |
132 | ],
133 |
134 | ];
135 |
--------------------------------------------------------------------------------
/config/filesystems.php:
--------------------------------------------------------------------------------
1 | 'local',
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Default Cloud Filesystem Disk
21 | |--------------------------------------------------------------------------
22 | |
23 | | Many applications store files both locally and in the cloud. For this
24 | | reason, you may specify a default "cloud" driver here. This driver
25 | | will be bound as the Cloud disk implementation in the container.
26 | |
27 | */
28 |
29 | 'cloud' => 's3',
30 |
31 | /*
32 | |--------------------------------------------------------------------------
33 | | Filesystem Disks
34 | |--------------------------------------------------------------------------
35 | |
36 | | Here you may configure as many filesystem "disks" as you wish, and you
37 | | may even configure multiple disks of the same driver. Defaults have
38 | | been setup for each driver as an example of the required options.
39 | |
40 | | Supported Drivers: "local", "ftp", "s3", "rackspace"
41 | |
42 | */
43 |
44 | 'disks' => [
45 |
46 | 'local' => [
47 | 'driver' => 'local',
48 | 'root' => storage_path('app'),
49 | ],
50 |
51 | 'public' => [
52 | 'driver' => 'local',
53 | 'root' => storage_path('app/public'),
54 | 'url' => env('APP_URL').'/storage',
55 | 'visibility' => 'public',
56 | ],
57 |
58 | 's3' => [
59 | 'driver' => 's3',
60 | 'key' => env('AWS_KEY'),
61 | 'secret' => env('AWS_SECRET'),
62 | 'region' => env('AWS_REGION'),
63 | 'bucket' => env('AWS_BUCKET'),
64 | ],
65 |
66 | ],
67 |
68 | ];
69 |
--------------------------------------------------------------------------------
/config/mail.php:
--------------------------------------------------------------------------------
1 | env('MAIL_DRIVER', 'smtp'),
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | SMTP Host Address
24 | |--------------------------------------------------------------------------
25 | |
26 | | Here you may provide the host address of the SMTP server used by your
27 | | applications. A default option is provided that is compatible with
28 | | the Mailgun mail service which will provide reliable deliveries.
29 | |
30 | */
31 |
32 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
33 |
34 | /*
35 | |--------------------------------------------------------------------------
36 | | SMTP Host Port
37 | |--------------------------------------------------------------------------
38 | |
39 | | This is the SMTP port used by your application to deliver e-mails to
40 | | users of the application. Like the host we have set this value to
41 | | stay compatible with the Mailgun e-mail application by default.
42 | |
43 | */
44 |
45 | 'port' => env('MAIL_PORT', 587),
46 |
47 | /*
48 | |--------------------------------------------------------------------------
49 | | Global "From" Address
50 | |--------------------------------------------------------------------------
51 | |
52 | | You may wish for all e-mails sent by your application to be sent from
53 | | the same address. Here, you may specify a name and address that is
54 | | used globally for all e-mails that are sent by your application.
55 | |
56 | */
57 |
58 | 'from' => [
59 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
60 | 'name' => env('MAIL_FROM_NAME', 'Example'),
61 | ],
62 |
63 | /*
64 | |--------------------------------------------------------------------------
65 | | E-Mail Encryption Protocol
66 | |--------------------------------------------------------------------------
67 | |
68 | | Here you may specify the encryption protocol that should be used when
69 | | the application send e-mail messages. A sensible default using the
70 | | transport layer security protocol should provide great security.
71 | |
72 | */
73 |
74 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'),
75 |
76 | /*
77 | |--------------------------------------------------------------------------
78 | | SMTP Server Username
79 | |--------------------------------------------------------------------------
80 | |
81 | | If your SMTP server requires a username for authentication, you should
82 | | set it here. This will get used to authenticate with your server on
83 | | connection. You may also set the "password" value below this one.
84 | |
85 | */
86 |
87 | 'username' => env('MAIL_USERNAME'),
88 |
89 | 'password' => env('MAIL_PASSWORD'),
90 |
91 | /*
92 | |--------------------------------------------------------------------------
93 | | Sendmail System Path
94 | |--------------------------------------------------------------------------
95 | |
96 | | When using the "sendmail" driver to send e-mails, we will need to know
97 | | the path to where Sendmail lives on this server. A default path has
98 | | been provided here, which will work well on most of your systems.
99 | |
100 | */
101 |
102 | 'sendmail' => '/usr/sbin/sendmail -bs',
103 |
104 | /*
105 | |--------------------------------------------------------------------------
106 | | Markdown Mail Settings
107 | |--------------------------------------------------------------------------
108 | |
109 | | If you are using Markdown based email rendering, you may configure your
110 | | theme and component paths here, allowing you to customize the design
111 | | of the emails. Or, you may simply stick with the Laravel defaults!
112 | |
113 | */
114 |
115 | 'markdown' => [
116 | 'theme' => 'default',
117 |
118 | 'paths' => [
119 | resource_path('views/vendor/mail'),
120 | ],
121 | ],
122 |
123 | ];
124 |
--------------------------------------------------------------------------------
/config/queue.php:
--------------------------------------------------------------------------------
1 | env('QUEUE_DRIVER', 'sync'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Queue Prefix
23 | |--------------------------------------------------------------------------
24 | |
25 | | If you are running multiple sites on a single server you should consider
26 | | specifying a queue prefix. This string will be prepended to the queue
27 | | names to prevent cross-talk when using certain local queue drivers.
28 | |
29 | */
30 |
31 | 'prefix' => env('QUEUE_PREFIX', ''),
32 |
33 | /*
34 | |--------------------------------------------------------------------------
35 | | Queue Connections
36 | |--------------------------------------------------------------------------
37 | |
38 | | Here you may configure the connection information for each server that
39 | | is used by your application. A default configuration has been added
40 | | for each back-end shipped with Laravel. You are free to add more.
41 | |
42 | */
43 |
44 | 'connections' => [
45 |
46 | 'sync' => [
47 | 'driver' => 'sync',
48 | ],
49 |
50 | 'database' => [
51 | 'driver' => 'database',
52 | 'table' => 'jobs',
53 | 'queue' => 'default',
54 | 'retry_after' => 90,
55 | ],
56 |
57 | 'beanstalkd' => [
58 | 'driver' => 'beanstalkd',
59 | 'host' => 'localhost',
60 | 'queue' => 'default',
61 | 'retry_after' => 90,
62 | ],
63 |
64 | 'sqs' => [
65 | 'driver' => 'sqs',
66 | 'key' => 'your-public-key',
67 | 'secret' => 'your-secret-key',
68 | 'prefix' => 'https://sqs.us-east-1.amazonaws.com/your-account-id',
69 | 'queue' => 'your-queue-name',
70 | 'region' => 'us-east-1',
71 | ],
72 |
73 | 'redis' => [
74 | 'driver' => 'redis',
75 | 'connection' => 'default',
76 | 'queue' => 'default',
77 | 'retry_after' => 90,
78 | ],
79 |
80 | ],
81 |
82 | /*
83 | |--------------------------------------------------------------------------
84 | | Failed Queue Jobs
85 | |--------------------------------------------------------------------------
86 | |
87 | | These options configure the behavior of failed queue job logging so you
88 | | can control which database and table are used to store the jobs that
89 | | have failed. You may change them to any database / table you wish.
90 | |
91 | */
92 |
93 | 'failed' => [
94 | 'database' => env('DB_CONNECTION', 'mysql'),
95 | 'table' => 'failed_jobs',
96 | ],
97 |
98 | ];
99 |
--------------------------------------------------------------------------------
/config/services.php:
--------------------------------------------------------------------------------
1 | [
18 | 'domain' => env('MAILGUN_DOMAIN'),
19 | 'secret' => env('MAILGUN_SECRET'),
20 | ],
21 |
22 | 'ses' => [
23 | 'key' => env('SES_KEY'),
24 | 'secret' => env('SES_SECRET'),
25 | 'region' => 'us-east-1',
26 | ],
27 |
28 | 'sparkpost' => [
29 | 'secret' => env('SPARKPOST_SECRET'),
30 | ],
31 |
32 | 'stripe' => [
33 | 'model' => App\User::class,
34 | 'key' => env('STRIPE_KEY'),
35 | 'secret' => env('STRIPE_SECRET'),
36 | ],
37 |
38 | ];
39 |
--------------------------------------------------------------------------------
/config/session.php:
--------------------------------------------------------------------------------
1 | env('SESSION_DRIVER', 'file'),
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | Session Lifetime
24 | |--------------------------------------------------------------------------
25 | |
26 | | Here you may specify the number of minutes that you wish the session
27 | | to be allowed to remain idle before it expires. If you want them
28 | | to immediately expire on the browser closing, set that option.
29 | |
30 | */
31 |
32 | 'lifetime' => 120,
33 |
34 | 'expire_on_close' => false,
35 |
36 | /*
37 | |--------------------------------------------------------------------------
38 | | Session Encryption
39 | |--------------------------------------------------------------------------
40 | |
41 | | This option allows you to easily specify that all of your session data
42 | | should be encrypted before it is stored. All encryption will be run
43 | | automatically by Laravel and you can use the Session like normal.
44 | |
45 | */
46 |
47 | 'encrypt' => false,
48 |
49 | /*
50 | |--------------------------------------------------------------------------
51 | | Session File Location
52 | |--------------------------------------------------------------------------
53 | |
54 | | When using the native session driver, we need a location where session
55 | | files may be stored. A default has been set for you but a different
56 | | location may be specified. This is only needed for file sessions.
57 | |
58 | */
59 |
60 | 'files' => storage_path('framework/sessions'),
61 |
62 | /*
63 | |--------------------------------------------------------------------------
64 | | Session Database Connection
65 | |--------------------------------------------------------------------------
66 | |
67 | | When using the "database" or "redis" session drivers, you may specify a
68 | | connection that should be used to manage these sessions. This should
69 | | correspond to a connection in your database configuration options.
70 | |
71 | */
72 |
73 | 'connection' => null,
74 |
75 | /*
76 | |--------------------------------------------------------------------------
77 | | Session Database Table
78 | |--------------------------------------------------------------------------
79 | |
80 | | When using the "database" session driver, you may specify the table we
81 | | should use to manage the sessions. Of course, a sensible default is
82 | | provided for you; however, you are free to change this as needed.
83 | |
84 | */
85 |
86 | 'table' => 'sessions',
87 |
88 | /*
89 | |--------------------------------------------------------------------------
90 | | Session Cache Store
91 | |--------------------------------------------------------------------------
92 | |
93 | | When using the "apc" or "memcached" session drivers, you may specify a
94 | | cache store that should be used for these sessions. This value must
95 | | correspond with one of the application's configured cache stores.
96 | |
97 | */
98 |
99 | 'store' => null,
100 |
101 | /*
102 | |--------------------------------------------------------------------------
103 | | Session Sweeping Lottery
104 | |--------------------------------------------------------------------------
105 | |
106 | | Some session drivers must manually sweep their storage location to get
107 | | rid of old sessions from storage. Here are the chances that it will
108 | | happen on a given request. By default, the odds are 2 out of 100.
109 | |
110 | */
111 |
112 | 'lottery' => [2, 100],
113 |
114 | /*
115 | |--------------------------------------------------------------------------
116 | | Session Cookie Name
117 | |--------------------------------------------------------------------------
118 | |
119 | | Here you may change the name of the cookie used to identify a session
120 | | instance by ID. The name specified here will get used every time a
121 | | new session cookie is created by the framework for every driver.
122 | |
123 | */
124 |
125 | 'cookie' => 'laravel_session',
126 |
127 | /*
128 | |--------------------------------------------------------------------------
129 | | Session Cookie Path
130 | |--------------------------------------------------------------------------
131 | |
132 | | The session cookie path determines the path for which the cookie will
133 | | be regarded as available. Typically, this will be the root path of
134 | | your application but you are free to change this when necessary.
135 | |
136 | */
137 |
138 | 'path' => '/',
139 |
140 | /*
141 | |--------------------------------------------------------------------------
142 | | Session Cookie Domain
143 | |--------------------------------------------------------------------------
144 | |
145 | | Here you may change the domain of the cookie used to identify a session
146 | | in your application. This will determine which domains the cookie is
147 | | available to in your application. A sensible default has been set.
148 | |
149 | */
150 |
151 | 'domain' => env('SESSION_DOMAIN', null),
152 |
153 | /*
154 | |--------------------------------------------------------------------------
155 | | HTTPS Only Cookies
156 | |--------------------------------------------------------------------------
157 | |
158 | | By setting this option to true, session cookies will only be sent back
159 | | to the server if the browser has a HTTPS connection. This will keep
160 | | the cookie from being sent to you if it can not be done securely.
161 | |
162 | */
163 |
164 | 'secure' => env('SESSION_SECURE_COOKIE', false),
165 |
166 | /*
167 | |--------------------------------------------------------------------------
168 | | HTTP Access Only
169 | |--------------------------------------------------------------------------
170 | |
171 | | Setting this value to true will prevent JavaScript from accessing the
172 | | value of the cookie and the cookie will only be accessible through
173 | | the HTTP protocol. You are free to modify this option if needed.
174 | |
175 | */
176 |
177 | 'http_only' => true,
178 |
179 | ];
180 |
--------------------------------------------------------------------------------
/config/view.php:
--------------------------------------------------------------------------------
1 | [
17 | resource_path('views'),
18 | ],
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Compiled View Path
23 | |--------------------------------------------------------------------------
24 | |
25 | | This option determines where all the compiled Blade templates will be
26 | | stored for your application. Typically, this is within the storage
27 | | directory. However, as usual, you are free to change this value.
28 | |
29 | */
30 |
31 | 'compiled' => realpath(storage_path('framework/views')),
32 |
33 | ];
34 |
--------------------------------------------------------------------------------
/database/.gitignore:
--------------------------------------------------------------------------------
1 | *.sqlite
2 |
--------------------------------------------------------------------------------
/database/factories/ModelFactory.php:
--------------------------------------------------------------------------------
1 | define(App\User::class, function (Faker\Generator $faker) {
16 | static $password;
17 |
18 | return [
19 | 'name' => $faker->name,
20 | 'email' => $faker->unique()->safeEmail,
21 | 'password' => $password ?: $password = bcrypt('secret'),
22 | 'remember_token' => str_random(10),
23 | ];
24 | });
25 |
26 |
27 | // quickly create fifty threads using $ php artisan tinker, then:
28 | // factory('App\Thread', 50)->create();
29 | $factory->define(App\Thread::class, function(Faker\Generator $faker){
30 | return [
31 | 'user_id' => function(){
32 | return factory('App\User')->create()->id;
33 | },
34 | 'channel_id' => function(){
35 | return factory('App\Channel')->create()->id;
36 | },
37 | 'title' => $faker->sentence,
38 | 'body' => $faker->paragraph,
39 |
40 | ];
41 | });
42 |
43 | $factory->define(App\Reply::class, function(Faker\Generator $faker){
44 | return [
45 | 'thread_id' => function(){
46 | return factory('App\Thread')->create()->id;
47 | },
48 | 'user_id' => function(){
49 | return factory('App\User')->create()->id;
50 | },
51 | 'body' => $faker->paragraph
52 | ];
53 | });
54 |
55 | $factory->define(App\Channel::class, function(Faker\Generator $faker){
56 | $name = $faker->word;
57 |
58 | return [
59 | 'name' => $name,
60 | 'slug' => $name
61 | ];
62 | });
63 |
64 |
65 | $factory->define(Illuminate\Notifications\DatabaseNotification::class, function(Faker\Generator $faker){
66 | return [
67 | 'id' => \Ramsey\Uuid\Uuid::uuid4()->toString(), // generate unique id
68 | 'type' => 'App\Notifications\ThreadWasUpdated',
69 | 'notifiable_id' => function(){
70 | return auth()->id() ?: factory('App\User')->create()->id;
71 | },
72 | 'notifiable_type' => 'App\User',
73 | 'data' => ['foo' => 'bar']
74 | ];
75 | });
76 |
--------------------------------------------------------------------------------
/database/migrations/2014_10_12_000000_create_users_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
19 | $table->string('name');
20 | $table->string('email')->unique();
21 | $table->string('password');
22 | $table->rememberToken();
23 | $table->timestamps();
24 | });
25 | }
26 |
27 | /**
28 | * Reverse the migrations.
29 | *
30 | * @return void
31 | */
32 | public function down()
33 | {
34 | Schema::dropIfExists('users');
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/database/migrations/2014_10_12_100000_create_password_resets_table.php:
--------------------------------------------------------------------------------
1 | string('email')->index();
18 | $table->string('token');
19 | $table->timestamp('created_at')->nullable();
20 | });
21 | }
22 |
23 | /**
24 | * Reverse the migrations.
25 | *
26 | * @return void
27 | */
28 | public function down()
29 | {
30 | Schema::dropIfExists('password_resets');
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/database/migrations/2017_04_21_224745_create_threads_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
18 | $table->unsignedInteger('user_id');
19 | $table->unsignedInteger('channel_id');
20 | $table->unsignedInteger('replies_count')->default(0);
21 | $table->string('title');
22 | $table->text('body');
23 | $table->timestamps();
24 | });
25 | }
26 |
27 | /**
28 | * Reverse the migrations.
29 | *
30 | * @return void
31 | */
32 | public function down()
33 | {
34 | Schema::dropIfExists('threads');
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/database/migrations/2017_04_21_233654_create_replies_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
18 | $table->integer('thread_id');
19 | $table->integer('user_id');
20 | $table->text('body');
21 | $table->timestamps();
22 | });
23 | }
24 |
25 | /**
26 | * Reverse the migrations.
27 | *
28 | * @return void
29 | */
30 | public function down()
31 | {
32 | Schema::dropIfExists('replies');
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/database/migrations/2017_05_29_025659_create_channels_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
18 | $table->string('name', 50);
19 | $table->string('slug', 50);
20 | $table->timestamps();
21 | });
22 | }
23 |
24 | /**
25 | * Reverse the migrations.
26 | *
27 | * @return void
28 | */
29 | public function down()
30 | {
31 | Schema::dropIfExists('channels');
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/database/migrations/2017_06_30_195457_create_favorites_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
18 | $table->unsignedInteger('user_id');
19 | $table->unsignedInteger('favorited_id');
20 | $table->string('favorited_type', 50);
21 | $table->timestamps();
22 |
23 | // cannot have more than one of that combination
24 | $table->unique(['user_id', 'favorited_id', 'favorited_type']);
25 | });
26 | }
27 |
28 | /**
29 | * Reverse the migrations.
30 | *
31 | * @return void
32 | */
33 | public function down()
34 | {
35 | Schema::dropIfExists('favorites');
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/database/migrations/2017_07_05_151909_create_activities_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
19 | $table->unsignedInteger('user_id')->index();
20 | $table->unsignedInteger('subject_id')->index();
21 | $table->string('subject_type', 50);
22 | $table->string('type', 50);
23 | $table->timestamps();
24 | });
25 | }
26 |
27 | /**
28 | * Reverse the migrations.
29 | *
30 | * @return void
31 | */
32 | public function down()
33 | {
34 | Schema::dropIfExists('activities');
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/database/migrations/2017_10_24_160355_create_thread_subscriptions_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
18 | $table->unsignedInteger('user_id');
19 | $table->unsignedInteger('thread_id');
20 | $table->unique(['user_id', 'thread_id']);
21 |
22 | $table->foreign('thread_id')
23 | ->references('id')
24 | ->on('threads')
25 | ->onDelete('cascade');
26 |
27 | $table->timestamps();
28 | });
29 | }
30 |
31 | /**
32 | * Reverse the migrations.
33 | *
34 | * @return void
35 | */
36 | public function down()
37 | {
38 | Schema::dropIfExists('thread_subscriptions');
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/database/migrations/2017_10_31_171936_create_notifications_table.php:
--------------------------------------------------------------------------------
1 | uuid('id')->primary();
18 | $table->string('type');
19 | $table->morphs('notifiable');
20 | $table->text('data');
21 | $table->timestamp('read_at')->nullable();
22 | $table->timestamps();
23 | });
24 | }
25 |
26 | /**
27 | * Reverse the migrations.
28 | *
29 | * @return void
30 | */
31 | public function down()
32 | {
33 | Schema::dropIfExists('notifications');
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/database/seeds/DatabaseSeeder.php:
--------------------------------------------------------------------------------
1 | create();
16 | factory(App\Reply::class, 5)->create();
17 | }
18 |
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "scripts": {
4 | "dev": "npm run development",
5 | "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
6 | "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
7 | "watch-poll": "npm run watch -- --watch-poll",
8 | "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
9 | "prod": "npm run production",
10 | "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
11 | },
12 | "devDependencies": {
13 | "axios": "^0.15.3",
14 | "bootstrap-sass": "^3.3.7",
15 | "cross-env": "^3.2.3",
16 | "jquery": "^3.1.1",
17 | "laravel-mix": "1.2.1",
18 | "lodash": "^4.17.4",
19 | "vue": "^2.4.1"
20 | },
21 | "dependencies": {
22 | "moment": "^2.18.1"
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/phpunit.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 | Please sign in to participate in this discussion
21 |
6 |
8 | said ...
9 |
10 |
11 |
There is no activity for this user yet.
25 | @endforelse 26 |There are no threads in this category yet. Create one!
28 | @endforelse 29 |
42 |