getherbert / herbert

The WordPress Plugin Framework:
http://getherbert.com/
632 stars 94 forks source link

Can't find Model #79

Closed aucms closed 8 years ago

aucms commented 9 years ago

Hi ... stumbled on Herbert recently and after setting up one project with it fell in love with it ... nice job.

Now i've been stuck for the past few hours. I have set up controller, tables and models and when trying to call it from a controller i just get the always fun class 'Couponcode' not found error. Here is what i have:

My table:

Capsule::schema()->create('p11_coupon_codes', function($table)
{
    $table->increments('id');
    $table->string('coupon_code');
    $table->enum('coupon_type', array('per_user','multiple_use'))->default('per_user');
    $table->enum('discount_type', array('percentage','cash'))->default('percentage');
    $table->float('discount_value')->nullable();
    $table->dateTime('start_date');
    $table->dateTime('end_date');
    $table->integer('coupon_use')->nullable();
    $table->softDeletes();
    $table->timestamps();
});

Couponcode.php Model

<?php namespace Siduris\Models;

use Illuminate\Database\Eloquent\Model as Eloquent;
use Illuminate\Database\Eloquent\SoftDeletingTrait;

class Couponcode extends Eloquent {
    use SoftDeletingTrait;
    protected $table = 'p11_coupon_codes';
    protected $fillable = array('coupon_code','coupon_type','discount_type','discount_value','start_date','end_date','coupon_use');
    protected $dates = array('deleted_at');
}

MembershipController.php

<?php namespace Siduris\Controllers;

use Siduris\Models\Couponcode;

class MembershipController {
    public function showIndex() {
            $model = Couponcode::find(1);
        }
}

I've updated, self-updated, dump-autoloaded the heck out of composer, even version update it, permission checked it and updated it ... still nothing and i'm almost at the point where i punch my head through the wall. I had a problem with permissions, was working as root, then not, then root but thanks to an article that i of cause cant find now i managed to revert that.

aucms commented 8 years ago

Hi @ConnorParksVS ... ive checked that part many times but that thought had come to mind ...

folder/file tree view

ConnorVG commented 8 years ago

Very odd indeed. Could you paste the content's of composer.json for me please?

aucms commented 8 years ago

@ConnorVG

composer.json

{
  "name": "getherbert/herbert-plugin",
  "description": "Herbert plugin",
  "license": "MIT",
  "require": {
    "getherbert/framework": "~0.9"
  },
  "config": {
    "preferred-install": "dist"
  },
  "minimum-stability": "dev",
  "autoload": {
    "psr-4": {
      "Siduris\\": "app/"
    }
  }
}
aucms commented 8 years ago

for some reason it seems to have worked it self out. The last thing i did was i updated composer again so i'm guessing that the issue was always with composer rather then dear old herbert.

Marking this closed ... for now at least.