laravel - Using Sentry with Codesleeve Stapler? -


update #1

so think found out problem since lack knowledge, there's no way me solve it.

when using sentry, i've tried extending both 'model' default sentry package , laravel's 'eloquent' under illuminate\database\eloquent\model. neither worked. while using laravel's eloquent on own (no sentry package addons), stapler works nicely.

so guess there compatibilty problem between stapler , sentry's user model though uses eloquent (its functionalities might conflicting stapler's traits or construct function, don't know). bad since sentry great package managing authentication , throttling , used far know.

is there easy way use stapler's agnostic version sentry or have rewrite code use laravel's auth?


main question

i'm building app uses cartalyst's sentry managing users. however, want users , other models able have associated avatars, i'm using codesleeve's stapler too.

i've read both laravel-stapler's readme , of stapler's standalone version documentation couldn't figure out how make them work sentry. whenever try create user through function:

$user = sentry::createuser(array(     'username'      => input::get('username'),     'email'         => input::get('email'),     'password'      => input::get('password'),     'activated'     => false,     'avatar'        => input::file('avatar') ));  return 'success'; 

i get:

sqlstate[42s22]: column not found: 1054 unknown column 'avatar' in 'field list'  

so seems sentry querying if avatar string , stapler not working.

here sentry user model (which i'm extending in laravel's):

use illuminate\database\eloquent\softdeletingtrait; use illuminate\database\eloquent\model; use codesleeve\stapler\orm\staplerableinterface; use codesleeve\stapler\orm\eloquenttrait; use cartalyst\sentry\groups\groupinterface; use cartalyst\sentry\hashing\hasherinterface; use cartalyst\sentry\users\loginrequiredexception; use cartalyst\sentry\users\passwordrequiredexception; use cartalyst\sentry\users\useralreadyactivatedexception; use cartalyst\sentry\users\userexistsexception; use cartalyst\sentry\users\userinterface;  class user extends model implements userinterface, staplerableinterface {          use softdeletingtrait, eloquenttrait;          protected $fillabe = array('username','email','password','password_temp','code','active','avatar');          public function __construct(array $attributes = array()) {                 $this->hasattachedfile('avatar', [                     'styles' => [                         'medium' => '300x300',                         'thumb' => '100x100'                     ]                 ]);                  parent::__construct($attributes);         }         protected $dates = ['deleted_at']; 

and inside sentry's config:

'model' => 'cartalyst\sentry\users\eloquent\user', 

this might simple solve since i'm pretty new laravel, sentry , stapler couldn't find info make me solve problem.

thanks in advance!

yes, can done. based on what's in op, root cause appears user model doesn't know avatar stapler-provided column.

theory: sentry user provider manufactures user model, right here. user model must stapler-aware, per stapler docs. fortunately, sentry configurable , can tell use custom model setmodel().

rough outline of solution: first, need model stapler-aware. might have this. note extends sentry-provided model class , imports stapler trait. both important.

<?php // app/models/usermodel.php namespace app\model; use codesleeve\stapler\orm\staplerableinterface; use codesleeve\stapler\orm\eloquenttrait; use cartalyst\sentry\users\eloquent\user sentryusermodel;  class usermodel extends sentryusermodel implements staplerableinterface {     use eloquenttrait; } 

second, need instruct sentry use this. below use run-time configuration changes, preference. can change sentry configuration file:

<?php // app/bootstrap.php  \sentry::getuserprovider()->setmodel('app\model\usermodel'); 

i'm doing memory on laravel 4, there may need tweaking involved.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -