Based on the recommendtations in theese answers: What are the best practices and best places for laravel 4 helpers or basic functions?
I have created a file app/library/sitehelpers.php
and added it to the application. What should my class extend and how do I refeence it in a controller?
<?php
class SiteHelpers{
function save($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);
}
}
}
I try to reference it like this in a controller:
public function savepostController($type, $postid, $url, $author, $content)
{
SiteHelpers::save($type, $postid, $url, $author, $content);
}
but I get Controller method not found.