mardi 2 février 2016

accessing model methods from controller class laravel

I am new to laravel, I am trying things around while going through a tutorial. This is where I am facing an unexpected behaviour.

I have a model tweet and a controller named tweetsController

when I call tweet::find() or any similar method I find this.

FatalErrorException in tweetsController.php line 13: Class 'App\Http\Controllers\tweet' not found

I have also tried App\tweet::find(). Everything seems fine though tinder

please explain

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
class tweetsController extends Controller
{
    public function show(){
    $data = tweet::first()->tweetBody;
    return view('tweets.list',['passedData'=> $data]);
    }

    public function delete($id){
    return "here we dele the tweet ".$id;
    }

    public function add(){
        return "i add your tweet to database then show you all the tweets";
    }
}

*tweet.php

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class tweet extends Model
{
    protected $fillable = array(
            'tweetHead',
            'tweetBody'
        );
}

?>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire