CodeIgniter Eloquent Model Relationship Class Model Not Found
i'm trying to implement eloquent into my CodeIgniter project.
It works good when i call a model in my project (it give me data from my database). But when i'm trying to call relation for its model, it's went wrong and show this message:
An uncaught Exception was encountered
Type: Error
Message: Class 'applicationmodelsProfile' not found
Filename: /var/www/public/chupspace-git/vendor/illuminate/database/Eloquent/Model.php
Line Number: 750
Backtrace:
File: /var/www/public/chupspace-git/application/models/User.php
Line: 12
Function: hasOne
File: /var/www/public/chupspace-git/vendor/illuminate/database/Eloquent/Model.php
Line: 2638
Function: profile
File: /var/www/public/chupspace-git/vendor/illuminate/database/Eloquent/Model.php
Line: 2573
Function: getRelationshipFromMethod
File: /var/www/public/chupspace-git/vendor/illuminate/database/Eloquent/Model.php
Line: 3263
Function: getAttribute
File: /var/www/public/chupspace-git/application/controllers/UserController.php
Line: 53
Function: __get
File: /var/www/public/chupspace-git/index.php
Line: 357
Function: require_once
I use "illuminate/database": "5.0.28", library in my composer.json
Here is my model
User.php
if (!defined('BASEPATH')) exit('No direct script access allowed');
use IlluminateDatabaseEloquentModel as Eloquent;
class User extends Eloquent
protected $table = "users";
public function profile()
return $this->hasOne('applicationmodelsProfile');
Profile.php
if (!defined('BASEPATH')) exit('No direct script access allowed');
use IlluminateDatabaseEloquentModel as Eloquent;
class Profile extends Eloquent
protected $table = "user_profiles";
And here is my directory map.

Let me know if there is missing of information, so i can update this thread.
Your help is very valuable to me. Thanks.
php codeigniter model eloquent relational-database
add a comment |
i'm trying to implement eloquent into my CodeIgniter project.
It works good when i call a model in my project (it give me data from my database). But when i'm trying to call relation for its model, it's went wrong and show this message:
An uncaught Exception was encountered
Type: Error
Message: Class 'applicationmodelsProfile' not found
Filename: /var/www/public/chupspace-git/vendor/illuminate/database/Eloquent/Model.php
Line Number: 750
Backtrace:
File: /var/www/public/chupspace-git/application/models/User.php
Line: 12
Function: hasOne
File: /var/www/public/chupspace-git/vendor/illuminate/database/Eloquent/Model.php
Line: 2638
Function: profile
File: /var/www/public/chupspace-git/vendor/illuminate/database/Eloquent/Model.php
Line: 2573
Function: getRelationshipFromMethod
File: /var/www/public/chupspace-git/vendor/illuminate/database/Eloquent/Model.php
Line: 3263
Function: getAttribute
File: /var/www/public/chupspace-git/application/controllers/UserController.php
Line: 53
Function: __get
File: /var/www/public/chupspace-git/index.php
Line: 357
Function: require_once
I use "illuminate/database": "5.0.28", library in my composer.json
Here is my model
User.php
if (!defined('BASEPATH')) exit('No direct script access allowed');
use IlluminateDatabaseEloquentModel as Eloquent;
class User extends Eloquent
protected $table = "users";
public function profile()
return $this->hasOne('applicationmodelsProfile');
Profile.php
if (!defined('BASEPATH')) exit('No direct script access allowed');
use IlluminateDatabaseEloquentModel as Eloquent;
class Profile extends Eloquent
protected $table = "user_profiles";
And here is my directory map.

Let me know if there is missing of information, so i can update this thread.
Your help is very valuable to me. Thanks.
php codeigniter model eloquent relational-database
just out of curiosity... why (besides the standard IT response "because I can") go through all the hoops of making Eloquent (an ORM/ActiveRecord implementation that is part of Laravel, an entirely different PHP framework) when CodeIgniter has its own ActiveRecord implementation built-in and working out of the box? just wondering....
– Javier Larroulet
Nov 13 '18 at 13:51
@Javier one of the most troublemaking things in Codeigniter is the missing part how to structure related data through connections - Eloquent is able to define relations - CI's QueryBuilder isn't. I posted a thread related to this topic a couple weeks ago forum.codeigniter.com/thread-71733.html
– sintakonte
Nov 13 '18 at 14:17
add a comment |
i'm trying to implement eloquent into my CodeIgniter project.
It works good when i call a model in my project (it give me data from my database). But when i'm trying to call relation for its model, it's went wrong and show this message:
An uncaught Exception was encountered
Type: Error
Message: Class 'applicationmodelsProfile' not found
Filename: /var/www/public/chupspace-git/vendor/illuminate/database/Eloquent/Model.php
Line Number: 750
Backtrace:
File: /var/www/public/chupspace-git/application/models/User.php
Line: 12
Function: hasOne
File: /var/www/public/chupspace-git/vendor/illuminate/database/Eloquent/Model.php
Line: 2638
Function: profile
File: /var/www/public/chupspace-git/vendor/illuminate/database/Eloquent/Model.php
Line: 2573
Function: getRelationshipFromMethod
File: /var/www/public/chupspace-git/vendor/illuminate/database/Eloquent/Model.php
Line: 3263
Function: getAttribute
File: /var/www/public/chupspace-git/application/controllers/UserController.php
Line: 53
Function: __get
File: /var/www/public/chupspace-git/index.php
Line: 357
Function: require_once
I use "illuminate/database": "5.0.28", library in my composer.json
Here is my model
User.php
if (!defined('BASEPATH')) exit('No direct script access allowed');
use IlluminateDatabaseEloquentModel as Eloquent;
class User extends Eloquent
protected $table = "users";
public function profile()
return $this->hasOne('applicationmodelsProfile');
Profile.php
if (!defined('BASEPATH')) exit('No direct script access allowed');
use IlluminateDatabaseEloquentModel as Eloquent;
class Profile extends Eloquent
protected $table = "user_profiles";
And here is my directory map.

Let me know if there is missing of information, so i can update this thread.
Your help is very valuable to me. Thanks.
php codeigniter model eloquent relational-database
i'm trying to implement eloquent into my CodeIgniter project.
It works good when i call a model in my project (it give me data from my database). But when i'm trying to call relation for its model, it's went wrong and show this message:
An uncaught Exception was encountered
Type: Error
Message: Class 'applicationmodelsProfile' not found
Filename: /var/www/public/chupspace-git/vendor/illuminate/database/Eloquent/Model.php
Line Number: 750
Backtrace:
File: /var/www/public/chupspace-git/application/models/User.php
Line: 12
Function: hasOne
File: /var/www/public/chupspace-git/vendor/illuminate/database/Eloquent/Model.php
Line: 2638
Function: profile
File: /var/www/public/chupspace-git/vendor/illuminate/database/Eloquent/Model.php
Line: 2573
Function: getRelationshipFromMethod
File: /var/www/public/chupspace-git/vendor/illuminate/database/Eloquent/Model.php
Line: 3263
Function: getAttribute
File: /var/www/public/chupspace-git/application/controllers/UserController.php
Line: 53
Function: __get
File: /var/www/public/chupspace-git/index.php
Line: 357
Function: require_once
I use "illuminate/database": "5.0.28", library in my composer.json
Here is my model
User.php
if (!defined('BASEPATH')) exit('No direct script access allowed');
use IlluminateDatabaseEloquentModel as Eloquent;
class User extends Eloquent
protected $table = "users";
public function profile()
return $this->hasOne('applicationmodelsProfile');
Profile.php
if (!defined('BASEPATH')) exit('No direct script access allowed');
use IlluminateDatabaseEloquentModel as Eloquent;
class Profile extends Eloquent
protected $table = "user_profiles";
And here is my directory map.

Let me know if there is missing of information, so i can update this thread.
Your help is very valuable to me. Thanks.
php codeigniter model eloquent relational-database
php codeigniter model eloquent relational-database
asked Nov 13 '18 at 13:22
Miftah MizwarMiftah Mizwar
617510
617510
just out of curiosity... why (besides the standard IT response "because I can") go through all the hoops of making Eloquent (an ORM/ActiveRecord implementation that is part of Laravel, an entirely different PHP framework) when CodeIgniter has its own ActiveRecord implementation built-in and working out of the box? just wondering....
– Javier Larroulet
Nov 13 '18 at 13:51
@Javier one of the most troublemaking things in Codeigniter is the missing part how to structure related data through connections - Eloquent is able to define relations - CI's QueryBuilder isn't. I posted a thread related to this topic a couple weeks ago forum.codeigniter.com/thread-71733.html
– sintakonte
Nov 13 '18 at 14:17
add a comment |
just out of curiosity... why (besides the standard IT response "because I can") go through all the hoops of making Eloquent (an ORM/ActiveRecord implementation that is part of Laravel, an entirely different PHP framework) when CodeIgniter has its own ActiveRecord implementation built-in and working out of the box? just wondering....
– Javier Larroulet
Nov 13 '18 at 13:51
@Javier one of the most troublemaking things in Codeigniter is the missing part how to structure related data through connections - Eloquent is able to define relations - CI's QueryBuilder isn't. I posted a thread related to this topic a couple weeks ago forum.codeigniter.com/thread-71733.html
– sintakonte
Nov 13 '18 at 14:17
just out of curiosity... why (besides the standard IT response "because I can") go through all the hoops of making Eloquent (an ORM/ActiveRecord implementation that is part of Laravel, an entirely different PHP framework) when CodeIgniter has its own ActiveRecord implementation built-in and working out of the box? just wondering....
– Javier Larroulet
Nov 13 '18 at 13:51
just out of curiosity... why (besides the standard IT response "because I can") go through all the hoops of making Eloquent (an ORM/ActiveRecord implementation that is part of Laravel, an entirely different PHP framework) when CodeIgniter has its own ActiveRecord implementation built-in and working out of the box? just wondering....
– Javier Larroulet
Nov 13 '18 at 13:51
@Javier one of the most troublemaking things in Codeigniter is the missing part how to structure related data through connections - Eloquent is able to define relations - CI's QueryBuilder isn't. I posted a thread related to this topic a couple weeks ago forum.codeigniter.com/thread-71733.html
– sintakonte
Nov 13 '18 at 14:17
@Javier one of the most troublemaking things in Codeigniter is the missing part how to structure related data through connections - Eloquent is able to define relations - CI's QueryBuilder isn't. I posted a thread related to this topic a couple weeks ago forum.codeigniter.com/thread-71733.html
– sintakonte
Nov 13 '18 at 14:17
add a comment |
2 Answers
2
active
oldest
votes
You need to load all relation class before use it.
First of all you need to enable in the application/config/config.php the composer autoload. Just set $config['composer_autoload'] to TRUE
Then you need to extend your composer.json to load every models:
"autoload":
"classmap": ["application/models/"]
Then you need to regenerate the autoload file (run in cli):
composer dump-autoload
It should be works. There is more other ways to do it, but i think it's the clearest.
Thank for your answer. I have done this part before, but the error still the same.
– Miftah Mizwar
Nov 13 '18 at 15:35
add a comment |
I found the solution. We just need to change
$this->hasOne('applicationmodelsProfile');
to be
$this->hasOne(new Profile());
Here is my full code.
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
use IlluminateDatabaseEloquentModel as Eloquent;
class User extends Eloquent
protected $table = "users";
public function profile()
// dd();
return $this->hasOne(new Profile());
It works good for me.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53281979%2fcodeigniter-eloquent-model-relationship-class-model-not-found%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You need to load all relation class before use it.
First of all you need to enable in the application/config/config.php the composer autoload. Just set $config['composer_autoload'] to TRUE
Then you need to extend your composer.json to load every models:
"autoload":
"classmap": ["application/models/"]
Then you need to regenerate the autoload file (run in cli):
composer dump-autoload
It should be works. There is more other ways to do it, but i think it's the clearest.
Thank for your answer. I have done this part before, but the error still the same.
– Miftah Mizwar
Nov 13 '18 at 15:35
add a comment |
You need to load all relation class before use it.
First of all you need to enable in the application/config/config.php the composer autoload. Just set $config['composer_autoload'] to TRUE
Then you need to extend your composer.json to load every models:
"autoload":
"classmap": ["application/models/"]
Then you need to regenerate the autoload file (run in cli):
composer dump-autoload
It should be works. There is more other ways to do it, but i think it's the clearest.
Thank for your answer. I have done this part before, but the error still the same.
– Miftah Mizwar
Nov 13 '18 at 15:35
add a comment |
You need to load all relation class before use it.
First of all you need to enable in the application/config/config.php the composer autoload. Just set $config['composer_autoload'] to TRUE
Then you need to extend your composer.json to load every models:
"autoload":
"classmap": ["application/models/"]
Then you need to regenerate the autoload file (run in cli):
composer dump-autoload
It should be works. There is more other ways to do it, but i think it's the clearest.
You need to load all relation class before use it.
First of all you need to enable in the application/config/config.php the composer autoload. Just set $config['composer_autoload'] to TRUE
Then you need to extend your composer.json to load every models:
"autoload":
"classmap": ["application/models/"]
Then you need to regenerate the autoload file (run in cli):
composer dump-autoload
It should be works. There is more other ways to do it, but i think it's the clearest.
answered Nov 13 '18 at 13:51
ffffff
534
534
Thank for your answer. I have done this part before, but the error still the same.
– Miftah Mizwar
Nov 13 '18 at 15:35
add a comment |
Thank for your answer. I have done this part before, but the error still the same.
– Miftah Mizwar
Nov 13 '18 at 15:35
Thank for your answer. I have done this part before, but the error still the same.
– Miftah Mizwar
Nov 13 '18 at 15:35
Thank for your answer. I have done this part before, but the error still the same.
– Miftah Mizwar
Nov 13 '18 at 15:35
add a comment |
I found the solution. We just need to change
$this->hasOne('applicationmodelsProfile');
to be
$this->hasOne(new Profile());
Here is my full code.
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
use IlluminateDatabaseEloquentModel as Eloquent;
class User extends Eloquent
protected $table = "users";
public function profile()
// dd();
return $this->hasOne(new Profile());
It works good for me.
add a comment |
I found the solution. We just need to change
$this->hasOne('applicationmodelsProfile');
to be
$this->hasOne(new Profile());
Here is my full code.
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
use IlluminateDatabaseEloquentModel as Eloquent;
class User extends Eloquent
protected $table = "users";
public function profile()
// dd();
return $this->hasOne(new Profile());
It works good for me.
add a comment |
I found the solution. We just need to change
$this->hasOne('applicationmodelsProfile');
to be
$this->hasOne(new Profile());
Here is my full code.
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
use IlluminateDatabaseEloquentModel as Eloquent;
class User extends Eloquent
protected $table = "users";
public function profile()
// dd();
return $this->hasOne(new Profile());
It works good for me.
I found the solution. We just need to change
$this->hasOne('applicationmodelsProfile');
to be
$this->hasOne(new Profile());
Here is my full code.
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
use IlluminateDatabaseEloquentModel as Eloquent;
class User extends Eloquent
protected $table = "users";
public function profile()
// dd();
return $this->hasOne(new Profile());
It works good for me.
answered Nov 13 '18 at 15:47
Miftah MizwarMiftah Mizwar
617510
617510
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53281979%2fcodeigniter-eloquent-model-relationship-class-model-not-found%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
just out of curiosity... why (besides the standard IT response "because I can") go through all the hoops of making Eloquent (an ORM/ActiveRecord implementation that is part of Laravel, an entirely different PHP framework) when CodeIgniter has its own ActiveRecord implementation built-in and working out of the box? just wondering....
– Javier Larroulet
Nov 13 '18 at 13:51
@Javier one of the most troublemaking things in Codeigniter is the missing part how to structure related data through connections - Eloquent is able to define relations - CI's QueryBuilder isn't. I posted a thread related to this topic a couple weeks ago forum.codeigniter.com/thread-71733.html
– sintakonte
Nov 13 '18 at 14:17