我有一个看起来像这样的模型:
<?php
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;
class Post extends Eloquent {
}
然后我尝试添加这样的方法:
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;
class Post extends Eloquent {
public static function create($type, $postid, $url, $author, $content)
{
$post = new Post;
$post->type = $type;
$post->postid = $postid;
$post->url = $url;
$post->author = $author;
$post->content = $content;
try
{
$post->save();
echo $post;
}catch(Exception $e){
throw new Exception( 'Already saved', 0, $e);
}
}
}
在控制器中,我尝试像这样引用该方法:
public function savepostController($type, $postid, $url, $author, $content)
{
Post::create($type, $postid, $url, $author, $content);
}
当我运行控制器时,我得到Controller method not found.