you can use the controller filter to check whether the user is logged in or not, and how you call any function of the model.
public function __construct(array $attributes = []){
$this->beforeFilter('auth', array('except' => 'login'));
if(Auth::user()){
$user_id = Auth::user()->user_id;
$model = new Model($attributes);
}
}
Constructor model binding attributes
Model.php
public function __construct(array $attributes = array())
{
$this->setRawAttributes($attributes, true);
parent::__construct($attributes);
}
source
share