jeudi 25 août 2016

Laravel Controller error

I'm learning how to do a simple Laravel app, an social network and I came across an error

[Fri Aug 26 00:46:30 2016] PHP Fatal error:  Class 'App\Http\Controllers\Post' not found in C:\xampp\htdocs\social-network\app\Http\Controllers\PostController.php on line 13

My PostController.php is this:

<?php
namespace App\Http\Controllers;

use App\User;
use Illuminate\Http\Request;

class PostController extends Controller
{

    public function postCreatePost(Request $request)
    {

        $post = new Post();
        $post->body = $request['body'];
        $request->user()->posts()->save($post);
        return redirect()->route('dashboard');

    }
}

My Post model is this:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Post extends Model
{

    public function user(){
        return $this->belongsTo('App\User');
    }
}

I don't understand what I did wrong. Can anyone help me figure out the error. Thanks in advance



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire