shetabit / visitor

a laravel package to work with visitors and retrieve their informations
MIT License
527 stars 68 forks source link

How can I customize shetabit/visitor Laravel package for changing ORM fields? #19

Open mohammadjouhari opened 3 years ago

mohammadjouhari commented 3 years ago

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);
khanzadimahdi commented 3 years ago

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.

mohammadjouhari commented 3 years ago

I did added in the model level, however I do not have visitor.php. I can see under model u have visit.php

khanzadimahdi commented 3 years ago

currently, this package does not support customizing the visitor model. could you add this feature and send a pull request?

mohammadjouhari commented 3 years ago

ok i am trying to navigate to the model using f12 but not getting the code. I am using vs code

mohammadjouhari commented 3 years ago

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

drewkenobi commented 2 years ago

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.

khanzadimahdi commented 2 years ago

currently, there is no wiki. we have only the Readme.md file on the package's Github homepage