Commit fe5df5df authored by Ranie Santos's avatar Ranie Santos

minor change, fix pluralization of controller and routes

parent 4c307a92
<?php
namespace App\Http\Controllers;
use App\Status;
use App\User;
use Illuminate\Http\Request;
class StatusController extends Controller
{
public function index()
{
return Status::with('user')->latest()->get();
}
public function store(Request $request)
{
// middleware
// validation
$this->validate(request(), [
'body' => 'required',
]);
// create status
$status = User::find(1)
->statuses()
->create($request->only(['body']));
// return with user
return $status->load('user');
}
}
<?php
namespace App\Http\Controllers;
use App\Status;
use App\User;
use Illuminate\Http\Request;
class StatusesController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return Status::with('user')->latest()->get();
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
// middleware
// validation
$this->validate(request(), [
'body' => 'required',
]);
// create status
$status = User::find(1)
->statuses()
->create($request->only(['body']));
// return with user
return $status->load('user');
}
/**
* Display the specified resource.
*
* @param \App\Status $status
* @return \Illuminate\Http\Response
*/
public function show(Status $status)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Status $status
* @return \Illuminate\Http\Response
*/
public function edit(Status $status)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Status $status
* @return \Illuminate\Http\Response
*/
public function update(Request $request, Status $status)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param \App\Status $status
* @return \Illuminate\Http\Response
*/
public function destroy(Status $status)
{
//
}
}
......@@ -50,8 +50,6 @@
addStatus(status) {
this.statuses.unshift(status);
window.scrollTo(0, 0);
alert('Status posted!');
}
}
......
......@@ -4,6 +4,6 @@ Route::get('/', function () {
return view('welcome');
});
Route::get('/statuses', 'StatusesController@index');
Route::get('/statuses', 'StatusController@index');
Route::post('statuses', 'StatusesController@store');
\ No newline at end of file
Route::post('/statuses', 'StatusController@store');
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment