私は Laravel 4 フレームワークを使用してイベント マネージャーに取り組んでおり、.NET で新しいモデルを作成しました/app/models/Event.php
。このファイルには、メソッドがありpublic function postCreateEvent($eventDetails)
ます。というエラーが表示されますCall to undefined method Illuminate\Events\Dispatcher::postCreateEvent()
。Laravel 4がモデル内の関数を見つけられない理由を特定するのを手伝ってくれる人はいますか?
/app/controllers/Events/Controllers/Manager/ManagerController.php は次のとおりです。
<?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->beforeFilter('auth');
}
//This control gets the correct manager page and displays it
public function getManager($nav = null)
{
if ($nav == null)
{
return View::make('manager');
}
else
{
return View::make('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' => Input::get('siteTitle'),
'siteAddress' => Input::get('siteAddress'),
'adminEmail' => Input::get('adminEmail'),
'openRegistrations' => Input::get('openRegistrations')
);
Site::postSiteSettings($siteSettings);
return View::make('manager/settings');
}
public function postCreateEvent()
{
$eventDetails = array(
'eventCalendar' => Input::get('siteTitle'),
'eventName' => Input::get('eventName'),
'eventDescription' => Input::get('eventDescription'),
'eventCapacity' => Input::get('eventCapacity'),
'eventRegistrationType' => Input::get('eventRegistrationType'),
'eventLocationName' => Input::get('eventLocationName'),
'eventLocationAddress1' => Input::get('eventLocationAddress1'),
'eventLocationAddress2' => Input::get('eventLocationAddress2'),
'eventLocationAddress3' => Input::get('eventLocationAddress3'),
'eventLocationCity' => Input::get('eventLocationCity'),
'eventLocationState' => Input::get('eventLocationState'),
'eventLocationZIP' => Input::get('eventLocationZIP'),
'eventLocationCountry' => Input::get('eventLocationCountry'),
'eventLocationPhone' => Input::get('eventLocationPhone'),
'eventStartDate' => Input::get('eventStartDate'),
'eventEndDate' => Input::get('eventEndDate'),
'eventStartTime' => Input::get('eventStartTime'),
'eventEndTime' => Input::get('eventEndTime'),
'eventRSVPEndDate' => Input::get('eventRSVPEndDate'),
'eventPublishDate' => Input::get('eventPublishDate'),
'eventArchiveDate' => Input::get('eventArchiveDate')
);
$event = new Event;
if (Event::postCreateEvent($eventDetails))
{
return View::make('manager/createEvent');
}
else
{
echo "WTF....";
}
}
}
/app/models/Event.php は次のとおりです。
<?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->eventCalendar = $eventDetails['eventCalendar'];
$event->eventName = $eventDetails['eventName'];
$event->eventDescription = $eventDetails['eventDescription'];
$event->eventCapacity = $eventDetails['eventCapacity'];
$event->eventRegistrationType = $eventDetails['eventRegistrationType'];
$event->eventLocationName = $eventDetails['eventLocationName'];
$event->eventLocationAddress1 = $eventDetails['eventLocationAddress1'];
$event->eventLocationAddress2 = $eventDetails['eventLocationAddress2'];
$event->eventLocationAddress3 = $eventDetails['eventLocationAddress3'];
$event->eventLocationCity = $eventDetails['eventLocationCity'];
$event->eventLocationState = $eventDetails['eventLocationState'];
$event->eventLocationZIP = $eventDetails['eventLocationZIP'];
$event->eventLocationCountry = $eventDetails['eventLocationCountry'];
$event->eventLocationPhone = $eventDetails['eventLocationPhone'];
$event->eventStartDate = $eventDetails['eventStartDate'];
$event->eventEndDate = $eventDetails['eventEndDate'];
$event->eventStartTime = $eventDetails['eventStartTime'];
$event->eventEndTime = $eventDetails['eventEndTime'];
$event->eventRSVPEndDate = $eventDetails['eventRSVPEndDate'];
$event->eventPublishDate = $eventDetails['eventPublishDate'];
$event->eventArchiveDate = $eventDetails['eventArchiveDate'];
$event->created_at = date('Y-m-d H:i:s');
$event->updated_at = date('Y-m-d H:i:s');
if ($event->save())
{
return true;
}
else
{
return false;
}
}
public static function test()
{
echo "True";
}
}
Laravel 4がモデル内の関数を見つけられない理由を誰でも見ることができますか?