search

Home  >  Q&A  >  body text

Laravel associated model can't find the Model?

I put the Models file under AppModels

PHP中文网PHP中文网2783 days ago480

reply all(3)I'll reply

  • PHPz

    PHPz2017-05-16 16:54:04

    It must be written completely. When this code is actually parsed, it will not be clear where the Class you specified is, so you have to write the complete namespace

    ->belongsTo('AppModelsGroup', 'uid', 'gid')

    or

    ->belongsTo(AppModelsGroup::class, 'uid', 'gid')

    reply
    0
  • 为情所困

    为情所困2017-05-16 16:54:04

    Check whether your space name path is the same as your current path

    reply
    0
  • 怪我咯

    怪我咯2017-05-16 16:54:04

    Add

    to the beginning of the file in the current screenshot (the next line of <?php)
    namespace App\Models;

    reply
    0
  • Cancelreply