websanova

Developer at http://langnova.com

Experience

2,845

0 Best Reply Awards

  • Member Since 2 Years Ago
  • 48 Lessons Completed
  • 4 Favorites

27th September, 2017

websanova started a new conversation Laravel Cashier Subscriptions Sync? • 1 month ago

I'm using Laravel Cashier and Stripe.

There have been some changes to some of the customers subscriptions made directly on Stripe. Like plan change or cancellations.

Of course these are now not reflected locally within the app. I was looking around but didn't see any kind of syncSubscriptions function.

Does anyone have experience with this or have a code snippet I could quickly add?

30th July, 2017

websanova left a reply on Set Queue Name Dynamically For Event Listener • 3 months ago

lol, ok, thanks. But that doesn't answer this question at all :-)

websanova left a reply on Set Queue Name Dynamically For Event Listener • 3 months ago

I'm having same issue here. My situation is that I run multiple apps on the same box so I need simple way to manage the queue naming via env as well.

25th January, 2017

websanova started a new conversation Dompdf Issues With 7.1 • 9 months ago

Just updated to latest version of Homeseated wiht php v7.1. But seems there are some issues with some of the packages like dompdf.

I already have services deployed as well and I'm not really an admin, so would like to just downgrade it to v7.0 for the time being.

sudo apt-get install php7.0 php7.0-mysql libapache2-mod-php7.0 php7.0-mcrypt php7.0-curl

Tried just doing a normal install but it's giving me a lot of not found errors for the packages. I'm using Homestead/Forge out of the box stuff.

Does anyone know how I an do this downgrade?

15th January, 2017

websanova left a reply on Spark API Returning 401 • 10 months ago

Just adding to this since I had the same issue. After playing around for about 30 minutes I found that setting the middleware to both 'api' and 'auth:api' worked.

middleware' => ['api', 'auth:api'],

Also you can then just directly use $this->middleware('dev'); in the controller for dev access to that api also.

13th March, 2016

websanova left a reply on Using Socialite With An API? • 1 year ago

Found out my issue, have to use stateless in both calls:

Socialite::with('facebook')->stateless()->redirect()->getTargetUrl()

$fb_user = Socialite::with('facebook')->stateless()->user();

12th March, 2016

websanova started a new conversation Using Socialite With An API? • 1 year ago

I'm trying to use Laravel Socialite package over an api. I try to pass the code into my api to fetch the user but it keeps giving me an error:

Fatal error: Call to a member function pull() on null

Since I'm doing the request over an API, I take the following steps.

  1. send a request to api for the url to fetch the code:

    Socialite::with('facebook')->stateless()->redirect()->getTargetUrl()

  2. Then make a request with the above fetched url, which redirects with the code parameter.

  3. Send the code to the api and fetch the user:

    $fb_user = Socialite::with('facebook')->user();

This is where it crashes. I'm not sure why.

I've used the package before and it works fine when I just have an app that reloads the page. But when I send it to an api (on a different domain) it crashes. I'm thinking there is some issue with how the code is generated. Is there anyway to fix this?

28th February, 2016

websanova started a new conversation Laravel JWT Authentication • 1 year ago

I'm trying to get Laravel JWT Authentication going. I'm using Homestead with php-7. Using the package and following the tutorial below:

https://packagist.org/packages/tymon/jwt-auth https://scotch.io/tutorials/token-based-authentication-for-angularjs-and-laravel-apps

Seems to be working ok, but when I do the Auth::attempt() call I just get a 502 Bad Gateway from Nginx.

If I comment out that call and echo something I will see it.

Really not sure what's going on.

29th December, 2015

websanova left a reply on Homestead PHP 7 Server Refused Our Key • 1 year ago

I was able to login with vagrant:vagrant, but not sure why the key is not working.

websanova left a reply on Splitting Large Feature Web Application Into Multiple Laravel Application • 1 year ago

Well without immediately knowing what you're doing. If you really thing it's that large and you want to get started on the right foot. Then sub-domains are a good choice.

-domain.com -auth.domain.com -api.domain.com

However in my experience I think it's good to keep things in one code base with namespace routes and folders, api, www, admin, etc. The reason being is that you will be sharing a lot of code like your Models, Observers, etc. You don't want to have multiple copies of those. Otherwise you can still keep your app on separate servers with different domains.

For your routes it will be cached anyway, so you can just wrap it with some if statements. Also it will make it easier for local testing.

From there just keep things super modular and try to build your app through packages.

websanova left a reply on How To Make My Project Modular ? • 1 year ago

This is from my blog, but seems to have helped some people out, so I will post it for you here. I'ts five part series on Laravel package development. You can contact me directly if you need any help.

http://www.websanova.com/blog/laravel/creating-a-new-package-in-laravel-5-part-1-package-workflow

28th December, 2015

websanova started a new conversation Homestead PHP 7 Server Refused Our Key • 1 year ago

I'm trying to run the homestead php-7 box. I'm following the "Upgrading to PHP 7.0" Instructions. Everything seems ok, but when I try to login I get a "Server refused our key" error.

Is this normal?

9th September, 2015

websanova started a new conversation Local Changes Take A Few Seconds To Sync On Homestead? • 2 years ago

I've just recently started using Homestead. I really love it and really hope I can continue using it. However it seems like I'm getting a bit of a lag issue when making changes on my local drive.

I already issues with response times related to using NFS on Windows. I made some changes there and everything was working great.

I don't think it's related but read something about a sendfile option in Nginx which I've already set to off.

However I'm still noticing some lag when making changes ad it's quite frequent. Like every second or third page load. Sometimes it takes a few seconds and a few pages loads before my changes appear.

Is anyone else experiencing this? Any bit of lag is a deal breaker for development, I hope there is some simple setting for this. I would rather have some longer page load times then worrying about whether my changes have synced up in Homestead.

31st August, 2015

websanova started a new conversation Should I Keep Deleted Items In Cache? • 2 years ago

I'm building an app and we have "active", "pending" and "deleted" items by a status field in the db.

We have a caching mechanism that stores "active" items in the cache. Should we also store "pending" and "deleted" items in the cache? The are of course low volume and mostly for administrative purposes. Seems like we shouldn't bother as they get a very small amount of hits.

Is there a general best practice or rule for this?

28th August, 2015

websanova left a reply on Issues Publishing Package To Packagist • 2 years ago

Right, clicked update about a hundred times already...

websanova started a new conversation Issues Publishing Package To Packagist • 2 years ago

I just published my first package on Packagist. A short lived Yay.

I'm having a bunch of issues.

  1. It keeps showing dev-master as the latest package even though I have official tagged versions in my repository.

  2. My GitHub service hook doesn't seem to be working. From GitHub side it seems fine when I run the test. Using:

user: websanova token: mytoken domain: https://packagist.org/packages/websanova/easycache

  1. When I try to install it via composer require websanova/easycache 1.1.1 it fails and tells me the package does not exist.

  2. The tag line (from GitHub) "Easily cache and retrieve models" is way old, I updated that about two days ago.

What gives?

20th April, 2015

websanova left a reply on Load Collection As Key/value Pair? • 2 years ago

Ended up taking your lead with the custom PermissionCollection. Seems to work quite well. Thx @pmall.

websanova left a reply on Load Collection As Key/value Pair? • 2 years ago

Well if I set up some kind of helper method (or custom collection) won't it iterate through the list of permissions each time to find a match?

I think it would be more efficient to just have something like:

 return $user->permissions->post_item === 'admin';

Which of course can be wrapped in some kind of helper method or function. I have a lot of permissions, about 30 with a range of levels for each permission. With all the users and checks it seems like a lot of iterating.

I think running through the list once before caching the user object is the best way.

However this poses issues as I have to store it in another variable/object since I can't overwrite the original permissions data set. Which means I have two sets of the data now.

Ultimately I would just like one data set:

$user->permissions = (object) [
    'post_item' => 'super',
    'put_item'   => 'admin'
    ...
]

Then just access them directly to see if the proper permission level is set.

websanova left a reply on Load Collection As Key/value Pair? • 2 years ago

I have a list of permisisons in a table

user_id, key,                      value
1              put_item              super
1              post_item            admin
1              delete_item         user
1              approve_item      admin
...

I'ts a user object with a hasMany relationship. I call it like so.

 $user = User::with('permissions')-find($id);

This returns a collection of permissions which is not very useful in that format. So I wanna convert it to a format so I can access it as:

$user->permissions->put_item;
$user->permissions->post_item;

I'm aware I can use a mutator and that it is cached so that a 'lists()' call is only processed once per request. But I would prefer to just cache it in the latter format all together.

websanova left a reply on Load Collection As Key/value Pair? • 2 years ago

Yes, the real issue is not so much creating the set of permissions. It's getting it back to the user object.

In my getById method I cache the objects. Which means I need to reassign the permissions object on the user.

$model->permissions = $model->permissions->lists('value', 'key');

This is fine but now when I logout it tries to save it when it updates the remember_token. Since it's using the ->save() method I can't block it with fillable or guarded.

The value is cached and besides that I check permissions a lot so I don't want to process the lists each time. I need it done just once and stuffed in as an attribute in the cache.

One option is to create a public variable in the model called perms and done stuff it in there which avoids the save. But this is not really a nice solution as now I have two sets of the object under two different names: 'permissions' and 'perms'..

19th April, 2015

websanova started a new conversation Load Collection As Key/value Pair? • 2 years ago

I have a set of Permissions which I make available on the User model through a hasMany relationship.

I have access to it via $user->permissions collection. However I would like to convert that collection to a key/value pair so i an access the permissions directly via $user->permissions->blah.

Is there any Laravel way to do this on the fly. I have a general getById method so it's a bit inconvenient to stuff it in there as then I also need to set some flags in my model so it would know to process it.

Also I have to create a setPermissionsAttribute so that it won't try to save the property later on (for instance on logout).

It's a bit inconvenient, is there a better way to do this?

23rd March, 2015

websanova left a reply on Laravel 5 DB::statement Not Working? • 2 years ago

Yes, it's working fine, I was having a brain fart, sry.

17th March, 2015

websanova left a reply on Laravel 5 DB::statement Not Working? • 2 years ago

Thx

15th March, 2015

websanova started a new conversation Laravel 5 DB::statement Not Working? • 2 years ago

Trying to run this:

DB::statement("RENAME TABLE `item_tag` TO `items_tag`;");

It just won't fire. Even if I change to an incorrect table name like item_blah it throws no errors.

Having same issue trying to rename column but seems to work with other statements.

Really not sure what's going on here.

14th March, 2015

websanova left a reply on Laravel 5 MassAssignmentException On Update With Fillable Already Set? • 2 years ago

For #@&! sakes, had it as protected instead of public.

websanova left a reply on Laravel 5 MassAssignmentException On Update With Fillable Already Set? • 2 years ago

@usman, that was the first thing I tried, should have mentioned that.

But it doesn't make sense anyway, I thought the whole point of fillable was so that I didn't have to worry about it. How does Laravel know what is a hidden field or not anyway. A user could put anything as a parameter.

websanova started a new conversation Laravel 5 MassAssignmentException On Update With Fillable Already Set? • 2 years ago

I'm trying to run this:

$model->update(Input::all());

I already have $fillable = ['field1', 'field2']; set in the model

It's still throwing me a MassAssignmentException?

websanova left a reply on Best Place To Store Model Observers (Events) In Laravel 5 • 2 years ago

Ya, I guess that makes sense. I was thinking about namespace too like App\Events\Observers. I guess just gotta do what makes sense for the project size/scope. Thx!

websanova started a new conversation Best Place To Store Model Observers (Events) In Laravel 5 • 2 years ago

Just trying out Laravel events and observers for the first time.

http://laravel.com/docs/5.0/eloquent#model-observers

I see in some old postings about Laravel 4 a good place to store them was just in app/models/observers. However in Laravel 5 since the folder structure has changed a bit I'm wondering where is a good place to store them?

Should I be storing them in the Events folder?

26th February, 2015

websanova left a reply on Best Way To Increment View Totals In DB And Cache? • 2 years ago

It's not totally critical to have accurate view totals. I'm curious from a technical point of view as well.

I suppose using the Cache::increment and maybe only updating the actual Item.views_total when the cache resets. That way if it's resetting every hour and the load is heavy you avoid all the $item->increment() calls.

My app pretty much won't function if Redis is down although that means it could potentially lose an hours worth of views data for some items if they happen to be towards the longer end.

25th February, 2015

websanova started a new conversation Best Way To Increment View Totals In DB And Cache? • 2 years ago

I'm setting up an app with a list of items. Those items have a "views_total" column.

When I view an items page /items/:id I want to increment the views_total which I do with

$item->increment('views_total');

This is fine but now my cached data is stale and I need to flush my cache every time this item is viewed even though there are no updates other than the view.

Are there any good solutions to this. I thought about have two separate cache objects for each item like item-Id-1 and item-id-1-views-total and then using the Cahce::increment. I implemented this and seems to work okay, but I'm wondering if there are better way to handle this?

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.