feed added
This commit is contained in:
parent
9b1435134c
commit
194439f93e
|
|
@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
|||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Models\FeedPost;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
|
|
@ -33,7 +34,37 @@ class HomeController extends Controller
|
|||
public function home()
|
||||
{
|
||||
$friends = Auth::user()->getFriends($perPage = 3);
|
||||
$posts = FeedPost::where(function ($query) {
|
||||
$userFriends = Auth::user()->getFriends();
|
||||
$friendIds = array();
|
||||
|
||||
return view('home')->with('friends', $friends);
|
||||
foreach ($userFriends as $uF) {
|
||||
array_push($friendIds, $uF->id);
|
||||
}
|
||||
|
||||
$query->whereIn('user_id', $friendIds)
|
||||
->orWhere('user_id', '=', Auth::id());
|
||||
})->orderBy('id', 'desc')->paginate(10);
|
||||
|
||||
$data = [
|
||||
'friends' => $friends,
|
||||
'posts' => $posts,
|
||||
];
|
||||
|
||||
return view('home')->with('data', $data);
|
||||
}
|
||||
|
||||
public function feed_post(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'status' => 'required|min:3|max:100'
|
||||
]);
|
||||
|
||||
$post = new FeedPost;
|
||||
$post->user_id = Auth::id();
|
||||
$post->status = $request->status;
|
||||
$post->save();
|
||||
|
||||
return redirect()->back()->with('success', 'Posted!');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class FeedPost extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'feed_posts';
|
||||
public $primaryKey = 'id';
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'status',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('App\Models\User');
|
||||
}
|
||||
}
|
||||
|
|
@ -9,6 +9,10 @@ class InviteKey extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'invite_keys';
|
||||
public $primaryKey = 'id';
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -14,6 +14,10 @@ class User extends Authenticatable
|
|||
{
|
||||
use HasApiTokens, HasFactory, Notifiable, Friendable;
|
||||
|
||||
protected $table = 'users';
|
||||
public $primaryKey = 'id';
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
|
|
@ -56,4 +60,9 @@ class User extends Authenticatable
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function feedposts()
|
||||
{
|
||||
return $this->hasMany('App\Models\FeedPost');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,8 +56,11 @@ class RouteServiceProvider extends ServiceProvider
|
|||
*/
|
||||
protected function configureRateLimiting()
|
||||
{
|
||||
RateLimiter::for('api', function (Request $request) {
|
||||
/*RateLimiter::for('api', function (Request $request) {
|
||||
return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
|
||||
});*/
|
||||
RateLimiter::for('feed_post', function (Request $request) {
|
||||
return Limit::perMinute(1)->by(optional($request->user())->id);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateFeedPostsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('feed_posts', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('user_id');
|
||||
$table->string('status');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('feed_posts');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
*
|
||||
{
|
||||
font-size: 12px;
|
||||
font-family: 'Comic Sans MS', Verdana, Arial, Helvetica, sans-serif;
|
||||
}
|
||||
H1
|
||||
{
|
||||
font-weight: bold;
|
||||
font-size: larger;
|
||||
}
|
||||
|
||||
/*
|
||||
FILE ARCHIVED ON 17:06:51 Feb 02, 2007 AND RETRIEVED FROM THE
|
||||
INTERNET ARCHIVE ON 13:32:02 May 30, 2022.
|
||||
JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE.
|
||||
|
||||
ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C.
|
||||
SECTION 108(a)(3)).
|
||||
*/
|
||||
/*
|
||||
playback timings (ms):
|
||||
captures_list: 543.356
|
||||
exclusion.robots: 0.115
|
||||
exclusion.robots.policy: 0.106
|
||||
cdx.remote: 0.078
|
||||
esindex: 0.011
|
||||
LoadShardBlock: 514.942 (3)
|
||||
PetaboxLoader3.datanode: 196.729 (4)
|
||||
CDXLines.iter: 17.173 (3)
|
||||
PetaboxLoader3.resolve: 383.648 (2)
|
||||
load_resource: 175.393
|
||||
*/
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head>
|
||||
<title>
|
||||
ROBLOX Help
|
||||
</title><link href="/CSS/RobloxOld.css" type="text/css" rel="stylesheet"><link rel="stylesheet" type="text/css"></head>
|
||||
<body>
|
||||
<form name="Form1" method="post" action="roblox.com/Game/Help.aspx" id="Form1">
|
||||
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTEzMDU5NjU4NjhkZIKJzjfFEOdRA2+w7aT1UMPiON7a">
|
||||
|
||||
<p>Besides using simple blocks, you can insert Things that other people have built
|
||||
into your Place. Use the Insert... menu in the game to browse.</p>
|
||||
<table id="Table1" class="Help">
|
||||
<tbody><tr style="FONT-WEIGHT: bold">
|
||||
<td>Action</td>
|
||||
<td>Primary</td>
|
||||
<td>Alternate</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Move Character</td>
|
||||
<td>Arrow keys</td>
|
||||
<td>ASDW keys</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Move Character (no tool selected)</td>
|
||||
<td>Click location with green disk</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Jump</td>
|
||||
<td>Space Bar</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Look up/down/left/right</td>
|
||||
<td>Right-click and drag mouse</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Look side to side</td>
|
||||
<td>Move mouse to the far right or far left
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Zoom in/out and up/down</td>
|
||||
<td>Mouse wheel</td>
|
||||
<td>I (in) and O (out) keys</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Change Tool / Toggle tool on off</td>
|
||||
<td>Number keys 1, 2, 3, ...</td>
|
||||
<td>Click on the tool</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Drop Tool</td>
|
||||
<td>Backspace key</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Drop Hat</td>
|
||||
<td>Equal (=) key</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Regenerate dead or stuck character</td>
|
||||
<td>Character regenerates automatically</td>
|
||||
<td>Exit and then return to the Place</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>First Person Mode</td>
|
||||
<td>Zoom all the way in</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
</form>
|
||||
|
||||
|
||||
</body></html>
|
||||
|
|
@ -16,24 +16,43 @@
|
|||
<div id="feed">
|
||||
<h2>My Feed</h2>
|
||||
<br>
|
||||
<p style="display: flex;">
|
||||
<input id="FeedBox" type="text" placeholder="Say something..." style="width: 80%;">
|
||||
<button style="width: 20%;height: 28px;margin-left: 10px;" class="greybutton" id="FeedButton">Post it!</button>
|
||||
</p>
|
||||
<form action="{{ route('feed_post') }}" method="POST">
|
||||
@csrf
|
||||
<p style="display: flex;">
|
||||
<input id="FeedBox" type="text" name="status" placeholder="Say something..." style="width: 80%;"
|
||||
value="{{ old('status') }}">
|
||||
<button style="width: 20%;height: 28px;margin-left: 10px;" class="greybutton" id="FeedButton"
|
||||
type="submit" onClick="this.form.submit();this.disabled=true;this.innerText='Posting…';">Post
|
||||
it!</button>
|
||||
</p>
|
||||
@if ($errors->any())
|
||||
<span class="warningtext">{{ $errors->first() }}</span>
|
||||
@endif
|
||||
@if (session()->has('success'))
|
||||
<span style="color:green">{{ session()->get('success') }}</span>
|
||||
@endif
|
||||
</form>
|
||||
<br>
|
||||
<div id="FeedContainer">
|
||||
<div class="FeedContainerBox" id="FeedContainerBox1">
|
||||
<div class="FeedContainerBoxImageContainer" id="FeedContainerBox1ImageContainer">
|
||||
<a href="#"><img alt="Profile Image" src="{{ asset('img/reviewpending.png') }}"
|
||||
width="60px" height="100%"></a>
|
||||
@foreach ($data['posts'] as $post)
|
||||
<div class="FeedContainerBox" id="FeedContainerBox1">
|
||||
<div class="FeedContainerBoxImageContainer" id="FeedContainerBox1ImageContainer">
|
||||
<a href="{{ route('profile', $post->user->id) }}"><img alt="Profile Image"
|
||||
src="{{ asset('img/iosload.gif') }}" width="60px" height="100%"></a>
|
||||
</div>
|
||||
<div class="FeedContainerBoxTextContainer" id="FeedContainerBox1TextContainer">
|
||||
<a href="{{ route('profile', $post->user->id) }}"
|
||||
id="FeedContainerBox1Username">{{ $post->user->name }}</a>
|
||||
<p id="FeedContainerBox1Text">"{{ $post->status }}"</p>
|
||||
<p id="FeedContainerBox1Timestamp">{{ $post->created_at->format('F d, Y H:i A') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="FeedContainerBoxTextContainer" id="FeedContainerBox1TextContainer">
|
||||
<a href="#" id="FeedContainerBox1Username">Placeholder</a>
|
||||
<p id="FeedContainerBox1Text">"This is a placeholder for future My Feed posts."</p>
|
||||
<p id="FeedContainerBox1Timestamp">July 13, 2022 01:42 AM</p>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
@if ($data['posts']->isEmpty())
|
||||
<p>Your feed is empty.</p>
|
||||
@endif
|
||||
</div>
|
||||
{{ $data['posts']->links() }}
|
||||
</div>
|
||||
<div id="gamesframe">
|
||||
<div class="content_special" style="justify-content: center;">
|
||||
|
|
@ -50,7 +69,7 @@
|
|||
@if (Auth::user()->getFriendsCount() > 0)
|
||||
<div id="profilefriendcontainer" class="content_special"
|
||||
style="flex-wrap: nowrap;justify-content: space-evenly;flex-direction: row;display: inline-flex;align-content: center;align-items: center;">
|
||||
@foreach ($friends as $friend)
|
||||
@foreach ($data['friends'] as $friend)
|
||||
<div class="profilefriend">
|
||||
<a href="{{ route('profile', $friend->id) }}"><img alt="Profile Image"
|
||||
src="{{ asset('img/iosload.gif') }}" width="150px" height="110px"></a>
|
||||
|
|
@ -63,7 +82,7 @@
|
|||
</div>
|
||||
@else
|
||||
<p>You don't have any friends yet!</p>
|
||||
@endif
|
||||
@endif
|
||||
<br>
|
||||
<h2>Recently Played</h2>
|
||||
<br>
|
||||
|
|
|
|||
|
|
@ -45,7 +45,11 @@
|
|||
</div>
|
||||
<div class="content_special">
|
||||
<div id="profileleftcontainer">
|
||||
<p id="status">"I'm new to ARCHBLOX!"</p>
|
||||
@if (!empty($data['user']->feedposts->last()->status))
|
||||
<address id="status">"{{ $data['user']->feedposts->last()->status }}"</address>
|
||||
@else
|
||||
<address id="status">"I'm new to ARCHBLOX!"</address>
|
||||
@endif
|
||||
<img alt="profile image" src="{{ asset('img/iosload.gif') }}" width="75%">
|
||||
<div id="bio"
|
||||
style="min-width:350px;max-width:350px;text-align:center;margin:0 auto;max-height:275px;overflow-y: auto;">
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<title>Users - {{ env('APP_NAME') }}</title>
|
||||
@endsection
|
||||
@section('titlediscord')
|
||||
<meta content="Users - {{env('APP_NAME')}}" property="og:title" />
|
||||
<meta content="Users - {{ env('APP_NAME') }}" property="og:title" />
|
||||
@endsection
|
||||
@section('descdiscord')
|
||||
<meta content="ARCHBLOX is a work in progress revival." property="og:description" />
|
||||
|
|
@ -18,7 +18,8 @@
|
|||
<h1 id="usernameframe">Users</h1>
|
||||
@endif
|
||||
<form method="GET" action="{{ route('users') }}">
|
||||
<p><input type="text" id="q" name="q" placeholder="Enter a Username..." value="{{ request()->q }}">
|
||||
<p><input type="text" id="q" name="q" placeholder="Enter a Username..."
|
||||
value="{{ request()->q }}">
|
||||
<button class="greybutton" type="submit">Search</button>
|
||||
</p>
|
||||
</form>
|
||||
|
|
@ -32,11 +33,24 @@
|
|||
</div>
|
||||
<div id="ProfileContainerBox1TextContainer">
|
||||
<a href="{{ route('profile', $user->id) }}" id="FeedContainerBox1Username">{{ $user->name }}</a>
|
||||
<p>"I'm new to ARCHBLOX!"</p>
|
||||
@if (!request()->has('q'))
|
||||
@if (!empty($user->feedposts->last()->status))
|
||||
<p>"{{ $user->feedposts->last()->status }}"</p>
|
||||
@else
|
||||
<p>"I'm new to ARCHBLOX!"</p>
|
||||
@endif
|
||||
@else
|
||||
@if (!empty(App\Models\FeedPost::where('user_id', $user->id)->first()->status))
|
||||
<p>"{{ App\Models\FeedPost::where('user_id', $user->id)->orderBy('id', 'desc')->first()->status }}"</p>
|
||||
@else
|
||||
<p>"I'm new to ARCHBLOX!"</p>
|
||||
@endif
|
||||
@endif
|
||||
@if (Cache::has('is_online_' . $user->id))
|
||||
<strong id="onlinestatus" class="onlinestatus_website">Website</strong>
|
||||
@else
|
||||
<strong id="onlinestatus" class="onlinestatus_offline">Offline - Last Online {{ Carbon\Carbon::parse($user->last_seen)->diffForHumans() }}</strong>
|
||||
<strong id="onlinestatus" class="onlinestatus_offline">Offline - Last Online
|
||||
{{ Carbon\Carbon::parse($user->last_seen)->diffForHumans() }}</strong>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -26,6 +26,12 @@ Route::get('/user/{id}/friends', [App\Http\Controllers\PageController::class, 'p
|
|||
// Must be logged in
|
||||
Route::middleware(['auth'])->group(function () {
|
||||
Route::get('/home', [App\Http\Controllers\HomeController::class, 'home'])->name('home');
|
||||
|
||||
// Rate limit + auth
|
||||
Route::middleware(['throttle:feed_post'])->group(function () {
|
||||
Route::post('/home', [App\Http\Controllers\HomeController::class, 'feed_post'])->name('feed_post');
|
||||
});
|
||||
|
||||
Route::get('/users', [App\Http\Controllers\PageController::class, 'users'])->name('users');
|
||||
Route::post('/users', [App\Http\Controllers\PageController::class, 'users'])->name('users');
|
||||
Route::get('/my/settings', [App\Http\Controllers\PageController::class, 'settings'])->name('settings');
|
||||
|
|
|
|||
Loading…
Reference in New Issue