Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BaseModel error #18

Open
osdebianly opened this issue Nov 7, 2016 · 6 comments
Open

BaseModel error #18

osdebianly opened this issue Nov 7, 2016 · 6 comments

Comments

@osdebianly
Copy link

# php artisan make:entity Order
//modify Order extend BaseModel 

class Order extends BaseModel implements Transformable
{
    use TransformableTrait;

    protected $fillable = ['title','price','note'];

}
   public function store(OrderCreateRequest $request)
    {
      
        $data = $request->only(['title', 'price', 'note']);

        $this->validator->with($data)->passesOrFail(ValidatorInterface::RULE_CREATE);

        $oder = $this->repository->create($data);  // Can get an Eloquent instance

        return $order ;  // 500  error,   class Order extends Model is ok 
       
        
    }
// get all data  return 500 ,no errors
  public function index()
    {
        $this->repository->pushCriteria(app('Prettus\Repository\Criteria\RequestCriteria'));
        return  $this->repository->all();
    }
@osdebianly
Copy link
Author

osdebianly commented Nov 7, 2016

$data = $this->repository->all() ;  //return Collection
$data->toArray() ;  // Collection Can't use toArray() method

@milkmeowo
Copy link

@osdebianly $this->repository->all(); // just return as array not Collection

//Skip presenter and bringing the original result of the Model
$post = $repository->skipPresenter()->find(1);

print_r( $post ); //It produces an output as a Model object
print_r( $post->transform() ); //It produces an output as array

@osdebianly
Copy link
Author

@milkmeowo

  • I found the reason for the error 🙏 Infinite loop
    Someline\Base\Models\BaseModel->getIdAttribute() call Illuminate\Database\Eloquent->mutateAttribute() call Someline\Base\Models\BaseModel->getIdAttribute() ...... 😄Always get the id attribute

So I delete Someline\Base\Models\BaseModel->getIdAttribute() function everything is OK

@libern
Copy link
Member

libern commented Nov 9, 2016

use php artisan starter:entity instead :)

@osdebianly
Copy link
Author

I've tried

@Muhammadinaam
Copy link

Hi, this is a nice package but I think that the developers have stopped working on it. Maybe you can try this package: https://github.com/Muhammadinaam/speed-admin. It supports Laravel 8+.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants