-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
22 changed files
with
162 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
use michaelbelgium\profileviews\listeners; | ||
|
||
use Illuminate\Contracts\Events\Dispatcher; | ||
use Flarum\Api\Serializer\UserSerializer; | ||
use Flarum\Api\Event\Serializing; | ||
use Flarum\Extend\Locales; | ||
use Flarum\Extend\Frontend; | ||
|
||
return [ | ||
(new Frontend('forum')) | ||
->js(__DIR__. '/js/dist/forum.js'), | ||
|
||
new Locales(__DIR__ . '/locale'), | ||
|
||
function (Dispatcher $events) { | ||
$events->subscribe(listeners\AddProfileViewHandler::class); | ||
$events->subscribe(listeners\AddUserProfileViewsRelationship::class); | ||
|
||
$events->listen(Serializing::class, function (Serializing $event) { | ||
if ($event->isSerializer(UserSerializer::class)) { | ||
$event->attributes['views'] = $event->model->profileViews()->count(); | ||
} | ||
}); | ||
} | ||
]; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './src/forum'; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"private": true, | ||
"name": "@michaelbelgium/flarum-profile-views", | ||
"dependencies": { | ||
"flarum-webpack-config": "0.1.0-beta.10", | ||
"webpack": "^4.0.0", | ||
"webpack-cli": "^3.0.7" | ||
}, | ||
"scripts": { | ||
"dev": "webpack --mode development --watch", | ||
"build": "webpack --mode production" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const config = require('flarum-webpack-config'); | ||
|
||
module.exports = config(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,7 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Schema\Builder; | ||
use Flarum\Database\Migration; | ||
|
||
return [ | ||
'up' => function (Builder $schema) { | ||
$schema->table('users', function (Blueprint $table) { | ||
$table->integer('views')->default(0); | ||
}); | ||
}, | ||
|
||
'down' => function (Builder $schema) { | ||
$schema->table('users', function (Blueprint $table) { | ||
$table->dropColumn('views'); | ||
}); | ||
} | ||
]; | ||
return Migration::addColumns("users", [ | ||
"views" => ["integer", "default" => 0] | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,12 @@ | ||
<?php | ||
|
||
use Flarum\Database\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Schema\Builder; | ||
|
||
return [ | ||
'up' => function (Builder $schema) { | ||
$schema->create('users_profile_views', function (Blueprint $table) { | ||
$table->increments('id'); | ||
$table->string("ip"); | ||
$table->integer("user_id")->unsigned(); | ||
return Migration::createTable('users_profile_views', function (Blueprint $table) { | ||
$table->increments('id'); | ||
$table->string("ip"); | ||
$table->integer("user_id")->unsigned(); | ||
|
||
$table->foreign("user_id")->references("id")->on("users")->onDelete("CASCADE")->onUpdate("CASCADE"); | ||
}); | ||
}, | ||
|
||
'down' => function (Builder $schema) { | ||
$schema->drop('users_profile_views'); | ||
} | ||
]; | ||
$table->foreign("user_id")->references("id")->on("users")->onDelete("CASCADE")->onUpdate("CASCADE"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
use Flarum\Database\Migration; | ||
|
||
return Migration::renameTable('users_profile_views', 'user_profile_views'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Schema\Builder; | ||
|
||
return [ | ||
'up' => function (Builder $schema) { | ||
$schema->table('users', function (Blueprint $table) { | ||
$table->dropColumn('views'); | ||
}); | ||
|
||
$schema->table('user_profile_views', function (Blueprint $table) { | ||
$table->renameColumn('user_id', 'viewed_user_id'); | ||
}); | ||
}, | ||
|
||
'down' => function (Builder $schema) { | ||
$schema->table('user_profile_views', function (Blueprint $table) { | ||
$table->renameColumn('viewed_user_id', 'user_id'); | ||
}); | ||
} | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Schema\Builder; | ||
use Illuminate\Database\Schema\Blueprint; | ||
|
||
return [ | ||
'up' => function (Builder $schema) { | ||
$schema->table('user_profile_views', function (Blueprint $table) { | ||
$table->integer("viewer_id")->unsigned()->nullable(); | ||
|
||
$table->foreign("viewer_id")->references("id")->on("users")->onDelete("CASCADE")->onUpdate("CASCADE"); | ||
}); | ||
}, | ||
|
||
'down' => function (Builder $schema) { | ||
$schema->table('user_profile_views', function (Blueprint $table) { | ||
$table->dropForeign(['viewer_id']); | ||
$table->dropColumn('viewer_id'); | ||
}); | ||
} | ||
]; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.