コード例 #1
0
ファイル: BlogController.php プロジェクト: joeyisking/sunbros
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     //Grab all the data we need to instead into the row
     $auth = new Auth();
     $user_id = $auth::user()->id;
     $input = Input::all();
     $param = array("user_id" => $user_id, "title" => $input['title'], "body" => $input['body']);
     //Create the row in the database
     Blog::create($param);
     return Redirect::route('blogs.index')->with('message', 'Blog created');
 }
コード例 #2
0
 /**
  * fetches every blogs.
  *
  * @return [type] [description]
  */
 public function index()
 {
     return Blog::all();
 }
コード例 #3
0
 public function store(Request $request)
 {
     $blogData = $request->all();
     $blog = Blog::create(['title' => $blogData['title'], 'content' => $blogData['content']]);
 }