Committing because I haven't in quite a while

pull/1/head
Braydon Kains 6 years ago
parent 8916522793
commit f440039cf2

@ -3,6 +3,7 @@
namespace App\Http\Controllers;
use App\Post;
use App\PostCollection;
use Illuminate\Http\Request;
class PostController extends Controller
@ -10,9 +11,10 @@ class PostController extends Controller
/**
* Display a listing of the resource.
*
* @param integer $thread_id
* @return \Illuminate\Http\Response
*/
public function index()
public function index(Thread $thread)
{
//
}
@ -22,9 +24,9 @@ class PostController extends Controller
*
* @return \Illuminate\Http\Response
*/
public function create()
public function create(Thread $thread)
{
//
return view("create_post")->withThread($thread);
}
/**
@ -35,18 +37,13 @@ class PostController extends Controller
*/
public function store(Request $request)
{
//
}
$post = new Post;
/**
* Display the specified resource.
*
* @param \App\Post $post
* @return \Illuminate\Http\Response
*/
public function show(Post $post)
{
//
$post->poster_id = $request->user_id;
$post->content = $request->content;
$post->thread_id = $request->thread_id;
$post->save();
}
/**
@ -57,7 +54,7 @@ class PostController extends Controller
*/
public function edit(Post $post)
{
//
return view("edit_post")->withPost($post);
}
/**
@ -69,7 +66,9 @@ class PostController extends Controller
*/
public function update(Request $request, Post $post)
{
//
$post->content = $request->content;
$post->save();
}
/**

@ -24,7 +24,7 @@ class TagController extends Controller
*/
public function create()
{
//
}
/**

@ -48,11 +48,13 @@ class ThreadController extends Controller
/**
* Display the specified resource.
*
* @param \App\Thread $thread
* @param integer $id
* - A thread ID
* @return \Illuminate\Http\Response
*/
public function show(Thread $thread)
public function show(integer $id)
{
$thread = ThreadsCollection(Thread::find($id)->with("posts")->get());
return view("thread_view")->withThread($thread);
}
@ -64,7 +66,7 @@ class ThreadController extends Controller
*/
public function edit(Thread $thread)
{
//
return view("edit")->withThread($thread);
}
/**
@ -76,7 +78,8 @@ class ThreadController extends Controller
*/
public function update(Request $request, Thread $thread)
{
//
$thread->thread_title = $request->thread_title;
$thread->save();
}
/**

@ -0,0 +1,21 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class PostCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'data' => $this->$collection
];
}
}

@ -0,0 +1,21 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class TagCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
"data" => $this->$collection
];
}
}

@ -19,6 +19,9 @@ class ThreadsCollection extends ResourceCollection
];
}
/**
* Deprecated, kept for posterity.
*/
public function getCreators() {
foreach($this->collection as &$t) {
$creator = $t->creator;

@ -6,8 +6,6 @@ use Illuminate\Database\Eloquent\Model;
class Thread extends Model
{
private $creator_name;
/**
* Get the creator of the thread.
*/
@ -21,4 +19,11 @@ class Thread extends Model
public function tags() {
return $this->belongsToMany('App\Tag');
}
/**
* Get the posts for the thread.
*/
public function posts() {
return $this->hasMany('App\Post');
}
}

Loading…
Cancel
Save