How can I customize shetabit/visitor Laravel package for changing ORM fields?
mohammadjouhari opened this issue · 7 comments
How can I customize shetabit/visitor Laravel package?
I have visited class I want to add mobile and name fields to it. How do I set it in the controller?
filling methods did not works?
class Visit extends Model
{
protected $table = 'visits';
protected $fillable = [
'method', 'request', 'url', 'referer',
'languages', 'useragent', 'headers',
'device', 'platform', 'browser', 'ip','name','mobile',
'visitor_id', 'visitor_type',
];
protected $casts = [
'request' => 'array',
'languages' => 'array',
'headers' => 'array'
];
public function visitable()
{
return $this->morphTo('visitable');
}
public function visitor()
{
return $this->morphTo('visitor');
}
}
$model = \App\Models\Visit::make();
$request = Request::instance();
$name = $request->request->get('name');
$mobile = $request->request->get('mobile');
$model->fill(['name' => $name]);
$model->fill(['mobile' => $mobile]);
var_dump($model);
$request->visitor()->visit($model);
read the docs, you misunderstood the visitor and visits log!
add custom fields in your visitor model, then the package will auto-save the model identifier.
I did added in the model level, however I do not have visitor.php. I can see under model u have visit.php
currently, this package does not support customizing the visitor
model. could you add this feature and send a pull request?
ok i am trying to navigate to the model using f12 but not getting the code. I am using vs code
I can not debug ur code am I missing any installation of ur package. https://stackoverflow.com/questions/45092844/go-to-definition-not-working-in-vs-code
read the docs, you misunderstood the visitor and visits log! add custom fields in your visitor model, then the package will auto-save the model identifier.
Sorry, but, where is the documentation? I can't find it in this repository... the wiki link redirects to the home... Regards.
currently, there is no wiki. we have only the Readme.md
file on the package's Github homepage