Back end finishedgit add .git add .git add .git add .git add .git add .git add .git add .git add .

pull/1/head
Braydon Kains 6 years ago
parent 3b1ef512b4
commit 6e8aad9241

@ -8,25 +8,14 @@ use Illuminate\Http\Request;
class PostController extends Controller
{
/**
* Display a listing of the resource.
*
* @param integer $thread_id
* @return \Illuminate\Http\Response
*/
public function index(Thread $thread)
{
//
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create(Thread $thread)
public function create(Thread $post)
{
return view("create_post")->withThread($thread);
return view("create_post")->withThread($post);
}
/**

@ -51,7 +51,7 @@ class ThreadController extends Controller
$thread = new Thread;
$thread->thread_title = $request->thread_title;
$thread->thread_poster_id = $request->user_id;
$thread->thread_creator_id = $request->user_id;
$thread->save();
}
@ -63,10 +63,10 @@ class ThreadController extends Controller
* - A thread ID
* @return \Illuminate\Http\Response
*/
public function show(integer $id)
public function show(int $id)
{
$thread = ThreadsCollection(Thread::find($id)->with("posts")->get());
return view("thread_view")->withThread($thread);
$selected_thread = new ThreadsCollection(Thread::with("posts")->get()->where("id", $id));
return $selected_thread;
}
/**

@ -26,6 +26,10 @@ class RouteServiceProvider extends ServiceProvider
//
parent::boot();
Route::model('thread', 'App\Thread');
Route::model('post', 'App\Post');
Route::model('tag', 'App\Tag');
}
/**

7
public/js/app.js vendored

@ -36855,8 +36855,11 @@ var render = function() {
_vm._v(" "),
_vm._l(_vm.threads, function(thread) {
return _c("div", { key: thread.id, staticClass: "card card-body" }, [
_c("p", [_vm._v(_vm._s(thread.creator.name) + "\n ")]),
_c("h3", [_vm._v(_vm._s(thread.thread_title))])
_c("p", [_vm._v(_vm._s(thread.creator.name))]),
_vm._v(" "),
_c("a", { attrs: { href: "./test/" + thread.id } }, [
_c("h3", [_vm._v(_vm._s(thread.thread_title))])
])
])
})
],

@ -2,8 +2,8 @@
<div>
<h2>Browse Threads</h2>
<div class="card card-body" v-for="thread in threads" v-bind:key="thread.id">
<p>{{ thread.creator.name }}
<a href="./test/{ {{ thread.id }} }"><h3>{{ thread.thread_title }}</h3></a>
<p>{{ thread.creator.name }}</p>
<a v-bind:href="'./test/' + thread.id"><h3>{{ thread.thread_title }}</h3></a>
</div>
</div>
</template>

@ -17,4 +17,38 @@ Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
Route::get('threads', 'ThreadController@index');
/**-
* Thread routes
*/
$thread_prefix = "thread";
//Gets
Route::get('threads', 'ThreadController@index');
Route::get($thread_prefix . '/{id}', 'ThreadController@show');
//Posts
Route::post($thread_prefix . '/update/{thread}', 'ThreadController@update');
Route::post($thread_prefix . '/store', 'ThreadController@store');
Route::post($thread_prefix . '/destroy/{thread}', 'ThreadController@destroy');
/**
* Post routes
*/
$post_prefix = "post";
//Posts
Route::post($post_prefix . '/update/{post}', 'PostController@update');
Route::post($post_prefix . '/store', 'PostController@store');
Route::post($post_prefix . '/destroy/{post}', 'PostController@destroy');
/**
* Tag routes
*/
$tag_prefix = "tag";
Route::get('tags', 'TagController@index');
Route::get($tag_prefix . '/{id}', 'TagController@show');
//Posts
Route::post($tag_prefix . '/update/{tag}', 'TagController@update');
Route::post($tag_prefix . '/store', 'TagController@store');
Route::post($tag_prefix . '/destroy/{tag}', 'TagController@destroy');

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save