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

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

Open
mohammadjouhari opened this issue Feb 20, 2021 · 7 comments

Comments

@mohammadjouhari
Copy link

mohammadjouhari commented Feb 20, 2021

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
Copy link
Member

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
Copy link
Author

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

@khanzadimahdi
Copy link
Member

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

@mohammadjouhari
Copy link
Author

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

@mohammadjouhari
Copy link
Author

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
Copy link

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
Copy link
Member

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

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

3 participants