Skip to content

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

@mohammadjouhari

Description

@mohammadjouhari

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions