Title: Laravel 4 Model Class Function is not being found correctly
Tags: model-view-controller;laravel;laravel-4
Question: I am working on an event manager using the Laravel 4 framework and have made a new model in /app/models/Event.php. In this file, I have the method public function postCreateEvent($eventDetails). I am getting the error, Call to undefined method Illuminate\Events\Dispatcher75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0postCreateEvent(). Can anyone help me identify why Laravel 4 is not finding the function in the model?
The /app/controllers/Events/Controllers/Manager/ManagerController.php is:
<?php
namespace Events\Controllers\Manager;
use \View, \BaseController, \Site, \Event, \Input;
class ManagerController extends BaseController
//This control ensures the user is logged in before they can view any of the manager pages or use the manager actions
public function __construct()
$this-&gt;beforeFilter('auth');
//This control gets the correct manager page and displays it
public function getManager($nav = null)
if ($nav == null)
return View75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0make('manager');
else
return View75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0make('manager/'.$nav);
//This control takes the site settings page when it is POSTed and moves it to the model to update the site settings.
public function postSiteSettings()
$siteSettings = array(
'siteTitle' =&gt; Input75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0get('siteTitle'),
'siteAddress' =&gt; Input75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0get('siteAddress'),
'adminEmail' =&gt; Input75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0get('adminEmail'),
'openRegistrations' =&gt; Input75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0get('openRegistrations')
);
Sit75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0postSiteSettings($siteSettings);
return View75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0make('manager/settings');
public function postCreateEvent()
$eventDetails = array(
'eventCalendar'         =&gt; Input75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0get('siteTitle'),
'eventName'             =&gt; Input75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0get('eventName'),
'eventDescription'      =&gt; Input75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0get('eventDescription'),
'eventCapacity'         =&gt; Input75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0get('eventCapacity'),
'eventRegistrationType' =&gt; Input75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0get('eventRegistrationType'),
'eventLocationName'     =&gt; Input75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0get('eventLocationName'),
'eventLocationAddress1' =&gt; Input75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0get('eventLocationAddress1'),
'eventLocationAddress2' =&gt; Input75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0get('eventLocationAddress2'),
'eventLocationAddress3' =&gt; Input75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0get('eventLocationAddress3'),
'eventLocationCity'     =&gt; Input75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0get('eventLocationCity'),
'eventLocationState'    =&gt; Input75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0get('eventLocationState'),
'eventLocationZIP'      =&gt; Input75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0get('eventLocationZIP'),
'eventLocationCountry'  =&gt; Input75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0get('eventLocationCountry'),
'eventLocationPhone'    =&gt; Input75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0get('eventLocationPhone'),
'eventStartDate'        =&gt; Input75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0get('eventStartDate'),
'eventEndDate'          =&gt; Input75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0get('eventEndDate'),
'eventStartTime'        =&gt; Input75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0get('eventStartTime'),
'eventEndTime'          =&gt; Input75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0get('eventEndTime'),
'eventRSVPEndDate'      =&gt; Input75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0get('eventRSVPEndDate'),
'eventPublishDate'      =&gt; Input75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0get('eventPublishDate'),
'eventArchiveDate'      =&gt; Input75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0get('eventArchiveDate')
);
$event = new Event;
if (Event75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0postCreateEvent($eventDetails))
return View75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0make('manager/createEvent');
else
echo "WTF....";
The /app/models/Event.php is:
<?php
class Event extends Eloquent {
* The database table used by the model.
* @var string
protected $table = 'events';
* Add New Event To The Database
* @param array
* @return booelan
public function postCreateEvent($eventDetails)
$event = new Event;
$event-&gt;eventCalendar           = $eventDetails['eventCalendar'];
$event-&gt;eventName               = $eventDetails['eventName'];
$event-&gt;eventDescription        = $eventDetails['eventDescription'];
$event-&gt;eventCapacity           = $eventDetails['eventCapacity'];
$event-&gt;eventRegistrationType   = $eventDetails['eventRegistrationType'];
$event-&gt;eventLocationName       = $eventDetails['eventLocationName'];
$event-&gt;eventLocationAddress1   = $eventDetails['eventLocationAddress1'];
$event-&gt;eventLocationAddress2   = $eventDetails['eventLocationAddress2'];
$event-&gt;eventLocationAddress3   = $eventDetails['eventLocationAddress3'];
$event-&gt;eventLocationCity       = $eventDetails['eventLocationCity'];
$event-&gt;eventLocationState      = $eventDetails['eventLocationState'];
$event-&gt;eventLocationZIP        = $eventDetails['eventLocationZIP'];
$event-&gt;eventLocationCountry    = $eventDetails['eventLocationCountry'];
$event-&gt;eventLocationPhone      = $eventDetails['eventLocationPhone'];
$event-&gt;eventStartDate          = $eventDetails['eventStartDate'];
$event-&gt;eventEndDate            = $eventDetails['eventEndDate'];
$event-&gt;eventStartTime          = $eventDetails['eventStartTime'];
$event-&gt;eventEndTime            = $eventDetails['eventEndTime'];
$event-&gt;eventRSVPEndDate        = $eventDetails['eventRSVPEndDate'];
$event-&gt;eventPublishDate        = $eventDetails['eventPublishDate'];
$event-&gt;eventArchiveDate        = $eventDetails['eventArchiveDate'];
$event-&gt;created_at              = date('Y-m-d H:i:s');
$event-&gt;updated_at              = date('Y-m-d H:i:s');
if ($event-&gt;save())
return true;
else
return false;
public static function test()
echo "True";
Can anyone see why Laravel 4 is not finding the function in the model?

Here is the accepted answer: The class Event already exists in the framework and that's what you call in
Event75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0postCreateEvent($eventDetails)
So it tries to call the postCreateEvent method on the framework's Event class but that method doesn't exist.
Try changing the class name to something else if that helps.


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2013:00:06/17/13', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<model-view-controller><laravel><laravel-4>', 'Title': 'Laravel 4 Model Class Function is not being found correctly', 'ViewCount': 775, 'id': 17158058, 'user_AboutMe': '<p>I am a security architect for a major ISP. My goal is to better secure software and network elements while encouraging the use of new and emerging technologies to achieve business goals using secure automation.</p>\n', 'user_AccountId': 1797870.0, 'user_DisplayName': 'kkirsche', 'user_Reputation': 1177.0, 'user_Views': 73.0, 'user_id': 1636883.0}}