Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Orm
Cannot find has_many and belongs_to in sub-folder
rrlledo
October 2020
model/calendaritem.php
namespace Model;
class Calendaritem extends \Orm\Model
{
protected static $_belongs_to = array(
'calendaritem_category' => array(
'model_to' => 'Model\\Calendaritem\\Category',
'key_from' => 'calendaritem_category_id'
)
);
protected static $_has_many = array(
'schedules' => array(
'model_to' => 'Model\\Calendar\\Schedule'
)
);
}
model/calendaritem/category.php
namespace Model\Calendaritem;
class Category extends \Orm\Model
{
protected static $_table_name = 'calendaritem_categories';
}
model/calendar/schedule.php
namespace Model\Calendar;
class Schedule extends \Orm\Model
{
protected static $_table_name = 'calendar_schedules';
protected static $_belongs_to = array(
'calendaritem' => array(
'model_to' => 'Model\\CalendarItem',
)
);
protected static $_has_many = array(
'visits' => array(
'model_to' => 'Model\\VisitLog',
'key_to' => 'calendar_schedule_id'
)
);
}
model/visitlog.php
namespace Model;
class Visitlog extends App
{
protected static $_belongs_to = array(
'schedule' => array(
'model_to' => 'Model\Calendar\Schedule',
'key_from' => 'calendar_schedule_id'
)
);
}
controller/visits.php
namespace Controller;
use Model\Visitlog;
class Visits extends App
{
public function get_index($id = 'all')
{
$options = array(
'limit' => 20,
'related' => array(
'schedule' => array(
'related' => array(
'calendaritem' => array(
'related' => array(
// 'calendaritem_category'
)
)
)
)
)
);
$result = Visitlog::find($id, $options);
}
}
controller/calendaritems.php
namespace Controller;
use Model\Calendaritem;
class Calendaritems extends App
{
public function get_index($id = 'all')
{
$options = array(
'related' => array(
'calendaritem_category',
'schedules' => array(
'related' => array(
'visits'
)
)
)
);
$result = Calendaritem::find($id, $options);
}
}
calendaritem_category in visits controller cannot be found
calendaritem_category & schedules in calendaritems cannot be found
I'm using PHP 7.1/7.4
FuelPHP 1.9
rrlledo
October 2020
Accepted Answer
nm.
The Observer Typing I created caused the issue.
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,089
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
261
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
rrlledo
October 2020