Is it just me or is this a bug?
j-shelfwood opened this issue · 1 comments
I've looked at your package and it looks really interesting, with my application our customers will be able to generate graphs based on data from their dataloggers. However when i tried to implement it remember() does not seem to be recognized.
`<?php
namespace App;
use DB;
use App\Dlog;
use App\Group;
use Illuminate\Database\Eloquent\Model;
use Watson\Rememberable\Rememberable;
class Datalogger extends Model
{
protected $connection = 'mysql';
protected $table = 'datalog_gsm_info';
protected $primaryKey = 'GSM_ID';
public $incrementing = false;
use Rememberable;
public function logs()
{
return $this->hasMany(Dlog::class, 'GSM_ID')->remember(60);
}
public function groups()
{
return $this->belongsToMany(Group::class, 'datalog_gsmex_info', 'GSM_ID', 'Property_value');
}
// public function zeroFilled()
// {
// $id = $this->GSM_ID;
// $length = strlen($id);
// $a = 6 - $length;
// for($i = $a; $i > 0; $i--)
// {
// $id = '0' . $id;
// }
// return $id;
// }
}
`
This bit of code produces this error : http://puu.sh/oO24D/d570502375.png
What am I doing wrong here?
Due to the implementation of this package, you're not able to call remember()
on your relationship definition (for example, belongsToMany()
returns an instance of a relationship definition, not a query builder). Generally you're going to use remember()
when writing a query with the model, like Datalogger::latest()->remember(60)->get()
for example.
One thing you could try - not sure if this will fix it though - is checking that the Dlog
model also uses the Rememberable
trait.