inmn

Experience

5,960

0 Best Reply Awards

  • Member Since 2 Years Ago
  • 45 Lessons Completed
  • 0 Favorites

6th March, 2018

inmn left a reply on Why Cant I Access Named Routes In Views? • 6 months ago

Figured this out

it wanted me to call

route('name',['domain'=>$domain])

Instead i made a helper function to auto add domain for me to avoid redundancy * 1000

inmn started a new conversation Can I Get An Opinion On Extending Spark: Custom Tables, DB Driven Gateways, Etc. • 6 months ago

Instead of Users & Teams; I need to have

Users -><- Members:Memberships -><-Orgs

Each Membership of an Org can theoretically have a unique payment id / cards; vs attaching it to user record.

Orgs haveMany Memberships / Members; Orgs haveMany Invoices (one off transactions)

My other need is to load db driven elements for plans, payment gateways for Org, etc.

... So, the $20,000 question:

Would it be advisable to try to hack apart spark and customize Invites, etc, or, simply just Diy from cashier?

2nd March, 2018

inmn left a reply on Why Cant I Access Named Routes In Views? • 6 months ago

In boot i have

    public function boot()
    {
        \Route::pattern('domain', '[a-z0-9.\-]+');

        // Default

        parent::boot();
    }

In my controller i have middleware in constructor calling this

$domain = $request->route()->parameter('domain');

What should i add @Snapey ?

inmn left a reply on Why Cant I Access Named Routes In Views? • 6 months ago

` /** * Define the "web" routes for the application. * * These routes all receive session state, CSRF protection, etc. * * @return void */ protected function mapWebRoutes() {

    // Match my own domain FIRST
    Route::group(['domain' => 'mt.n','www.mt.n','admin.mt.n'], function()
    {
        // Original Web Route
        Route::middleware('web')
             ->namespace($this->namespace)
             ->group(base_path('routes/web.php'));
    });



    // Match any other domains or subdomains
    Route::group(['domain' => '{domain}'], function()
    {
        // Org middleware
        Route::middleware('web')
            ->namespace($this->namespace)
            ->group(base_path('routes/org.php'));
    });
    
}

`

inmn started a new conversation Why Cant I Access Named Routes In Views? • 6 months ago

web.php routes uses Controller (default); named routes work fine.

However, I have a route group; which uses the SAME middleware as web.php; and it's controller (namespaced ..Controllers/Org) extends Controller (use ..Controllers/Controller)

In my routes/org.php i can say Route::get('/test', '[email protected]')->name('test'); Route::get(/'view', '[email protected]')->name('view');

@view simply returns a blade file, in which i call {{ route('test'); }}

then i get a Missing parameters for Route: test error

inmn left a reply on Cannot Call Auth::routes In Other Locations • 6 months ago

Actually playing with it, it seems the route() functions are not made available in my entire Org group;

its like the service provider ONLY works with the web.php routes

inmn left a reply on Cannot Call Auth::routes In Other Locations • 6 months ago

Error was on slack, but basically it couldnt find the named resource.

Basically the route:: ... ->name('foo') wasnt resolving.

It seems out you CANT have a name in two different route groups be the same. Or, my named routes in my org.php arent working.

1st March, 2018

inmn started a new conversation Cannot Call Auth::routes In Other Locations • 6 months ago

My routes service provider uses WEB middleware group, for both /routes/web and routes/custom;

But Auth::routes() only works in routes/web.php ; not routes/custom.php.

Any idea why?

--- Code here: Stack isnt much help. Trying trusty laracasts crew now :)

https://stackoverflow.com/questions/49019093/cannot-use-authroutes-outside-default-routes-web-php?noredirect=1#comment85056114_49019093

17th February, 2018

inmn left a reply on Should I Use Model Relationships Vs Query Scopes And A Simple Mysql Join? • 7 months ago

Thanks, @Borisu

Can hasMany only work if all hasMany?

I am hitting issues

where

org hasMany members but members belongsTo both org and user

15th February, 2018

inmn started a new conversation Should I Use Model Relationships Vs Query Scopes And A Simple Mysql Join? • 7 months ago

Perhaps I am missing something; but when using belongsTo or hasMany models, I am finding that I often just return more than I need.

Ie:

If an Org has Members; $org->with('members'); gives me

Org

  • Members

If i want user data I have to do $org->with('members','members.user')

Which gives me Org

  • Members -- User Record

If the user has any related fields, like contact numbers I am then working with Org

  • Members -- User Record ----Related Models of User Record ------- Maybe even more

When returning public json output, i then have to clean up many of the fields being returned

(still learning how only return PARTS of the related models)

So with a query scope / custom mysql i could easily return a flat array of selected data for the memberDataOf($org)

What would you recommend?

12th February, 2018

inmn started a new conversation Constructors In Controllers Arent Supposed To Use Middleware, Correct? • 7 months ago

It seems it loads as:

  1. Controller:: __construct
  2. Middleware
  3. Controller::function

So - construct(){$this->user = 'me';} wont work; even if middleware registers a service to the container.

Correct?

So i I am trying to avoid crazy code, simply make

public function currentUser(){
    return \App::make('current_user');
} 

in the controller; and in my individual controller functions simply use $this->currentUser;

Correct?

(yeah my code works, just making sure i understand it)

7th February, 2018

inmn left a reply on Subdomain And Custom Domain Mapping Setup Question • 7 months ago

@bobbybouwmann @martinbean So after more learning and doing,

config.org_id = 1 means in my controllers; i basically end up getting that object then using the related models later;

So $org->members; $org->news; etc

Given that the object should basically be a singleton for the servicecontainer of that mapped site, I assume it would be better to just allow the Org to persist;

Right now i am actually adding the org to Request, then calling via \Request::get('org');

But would love to just be able to call org(); What do I need to do for that? :) (is that a service provider, a facade, what?)

5th February, 2018

inmn left a reply on Getting Error In Middlewhere When Using A WhereHas Fn • 7 months ago

Stupid error was due to use of protected vs public

4th February, 2018

inmn started a new conversation Getting Error In Middlewhere When Using A WhereHas Fn • 7 months ago

I have

App\Org which has a field of "subdomain"

and an App\Domain which belongsTo Org; and has a field of "domain"

... 
    protected function domains()
    {
        return $this->hasMany('App\Domain');
    }

In my middleware i am trying to lookup a domain using a whereHas orWhereHas type of query:


$org = Org::whereHas('domains', function($q){
                        $q->where('domain','=',$domain);
                    })
                    ->orWhereHas('subdomain','=', $sub)
                    ->get();

I get this error: "Call to undefined method Illuminate\Database\Query\Builder::domains()"

So either i cant call this in middleware, or docs are wrong, or?

22nd January, 2018

inmn started a new conversation How To Validate Form Input When A Route Isnt Nested/bound? • 7 months ago

In my mind (php); nested resources helps insist on binding a value to prevent users from posting to anything by modifying the dom.

(please dont ask "wait why cant they post comments everywhere .. i know, terrible example)

Ie.

/post/$id/comment/create sets a $_SESSION[comment_postid] = $id;

Store then uses the /post/$id/comment/store that validates the $id == $_SESSION['comment_postid'];

If its just /comment ; is it as simple as having create form set same session (via blade); and store validating it?

is there a more laravel-esque way?

inmn left a reply on Route Model Binding - Nested Routes Via Resource() Function Doable? • 7 months ago

@snapey youre right other than the index function returning all of the comments, otherwise Create / Edit / etc are all just part of it.

I will search / ask the follow up question; but it revolves around nesting /comments/store

inmn started a new conversation Route Model Binding - Nested Routes Via Resource() Function Doable? • 7 months ago

Lets say I have

Posts, Comments (belongsTo post); Rating belongsTo Comment) Posts hasMany Comments; Comments hasMany Ratings.

If my goal is to reduce junk in Routes:

/post/ /post/id/comment/ /post/id/comment/id/rating/id

I can define

Route::resource('post','PostController');
Route::resource('comment','CommentController');
Route::resource('rating',RatingController');

Each will work, however, they do not force the relationship.

Ie, post/id loads post; but /post/1/comment/ (all in index) loads every comment for all posts, not those belonging to Post #1

What is the best laravel esque way to handle this?

... or is " Route::resource() " not meant to do this type of specificity?

inmn left a reply on Is Lazy Loading Going To Make Some Gigantic Models? • 7 months ago

Ha - I was being rushed. ;) Yeah - its bad pseudophp

Thanks. So best way is $post->comments->get();

:)

21st January, 2018

inmn left a reply on Is Lazy Loading Going To Make Some Gigantic Models? • 7 months ago

and no. i learned a long time ago showing people DB schema leads for points of arguments, so its better to speak in the abstract ;)

inmn left a reply on Is Lazy Loading Going To Make Some Gigantic Models? • 7 months ago

How am I defining wrong?

https://laravel.com/docs/5.5/eloquent-relationships#one-to-many

Comment::class or App/Comment is fine; app comment is from the docs.

The result renders but with full body of the post model attached. I would rather just return comments of.

filder is "filter" misspelled.

It would be helpful to return Comments of Post;

So basically a

DB all comments where post_id = $post_id; Yes. I know i can write it, but i am after a laravel esque way.

Comments::of(Post) would be super helpful :)

inmn started a new conversation Is Lazy Loading Going To Make Some Gigantic Models? • 7 months ago

I have an example:

Post with

$comments = return $this->hasMany('App\Comment');

Comment with a function of

$post = return $this->belongsTo('App\Post')

So lets say I want to see all comments of a post; ive ran across suggestions of calling this inthe comments controller:

$comments = Comment::with('post')->find($post_id);

but ive noticed the lazy loading shoves the whole post into the memory along with its comments. I do not see an Eloquent filder of "of"

Is this a bad use of this for a filter? Would it be better to simply not hitup the belongsTo function; or what am I doing wrong?

18th January, 2018

inmn left a reply on Subdomain And Custom Domain Mapping Setup Question • 8 months ago

@bobbybouwmann yes, but none for now. Just slow to be excited about learning the various naming conventions for classes and functions ;)

17th January, 2018

inmn started a new conversation How Should I Handle Roles Type Middleware With Vue? • 8 months ago

Lets say I have an isAdmin type function for modifying this Account; (not all users are admins of all accounts)

With Rest, the validation should be done as part of the rest request, right? So lets say i have a user / token; it id's them, then determines if user can access this resource;

With vue, should I still use that mentality? Or should i use the User functionality of a logged in laravel session and remove the user / tokens from the request?

Is there a reason to do it one way or another?

4th January, 2018

inmn left a reply on Subdomain And Custom Domain Mapping Setup Question • 8 months ago

Thanks. Still learning where and how to stick things in laravel.

inmn left a reply on Subdomain And Custom Domain Mapping Setup Question • 8 months ago

Awesome ty. My app is slightly diff, one db only, but I still have to pull an org id. now if I am more DB driven saas, what is more efficient?

A custom config variable to be used throughout app? config()->set('site_org)->$tenant->id)

Or some other global method (?? service Provider?? )

3rd January, 2018

inmn started a new conversation Subdomain And Custom Domain Mapping Setup Question • 8 months ago

I have a project that will allow both user profile pages based on subdomains.myapp.example and customdomains.example; I need to know what to look to do in laravel to make sure I am doing it effeciently. In php, I would simply lookup the URI in the index.php page, set a $GLOBAL['org_id'] to be used on all things later on (routes, etc)

The rules should break down to first recognize known myapp.example domains, and subdomain pairs (www. ; api. );

Then route model binding for custom-subdomain.myapp.example;

Then a "not recognized" (??middleware??) for customDomain-xyz.example

This middleware would lookup a Model to find an org; then set a ((service provider?)) for the rest of the requests;

Am I on the right path? Or am I looking at the wrong or inefficient methods of implementing this?

(routes for customDomain.example would be like /news ; where I would get News that belongsTo $org();

1st January, 2018

inmn started a new conversation Does Laravel/Eloquent Have An "if Set" Function When Handling Optional Data In Controllers? • 8 months ago

I have optional data fields, so like

User::create([
'name' => $data['name'],
'city' => $data['city'],
]);

Not all are required.

I cannot do a foreach loop and set Key => val; as some parts in function do things like Password => bcrypt

I could make a foreach $key=>$val for $optfields, or wrap each optional line with

isset($data['name']) ? $data['name'] : 'null');

but that seems clunky. Is there a better way to handle?

16th November, 2017

inmn left a reply on Would You Heavily Modify Spark, Or, Roll Your Own? • 10 months ago

Cashier still attaches payments to users, but it seems easier to extend than spark

inmn left a reply on Does TeamBilling Have Issues When A User Has More Than One Admin Role On A Team? • 10 months ago

Seems like YES.

Since a User's Card is stored to the user record; rather than a UserCards table with a user hasMany cards type of relationship,

it seems YES.

inmn started a new conversation Would You Heavily Modify Spark, Or, Roll Your Own? • 10 months ago

We have a need for features Spark doesnt offer, like:

Not attaching Payment Details to a User

Not attaching Team levels to a User

Using Custom Team Levels for Subscriptions setup by Team admins

Allowing Members of Teams without subscriptions, yet tracking a members active subscription status

Allowing Teams to manage Offline Payments for Invoices

Allowing Teams to create sub-teams, and manage billing subscription plans

Spark can do it all except attaching a TEAM level to a User's CC; but when we want to extend into other areas, it starts becoming convoluted.

So my question is.. Would you User Spark,. make CustomSparkClasses that extend spark, and do what you can to allow offline payments, etc,

OR

Just make your own?

I know we can always purchase spark then rob the code examples / fork it; etc.

That $99-300 is not an issue. I dont want to waste money on MVP dev if we can extend it, but if you guys think it will be a nightmare to extend it, then its likely worth the 40-80 hours to build/clone a lot of this functionality into our own app.

inmn left a reply on Get Client IP Address • 10 months ago

Lol. Your IP is 127 because youre local server is 127.

If you want to see your ISP's IP, you have to actually use it to connect to your local server

(public SHARE is another option.. etc)

15th November, 2017

inmn started a new conversation Does TeamBilling Have Issues When A User Has More Than One Admin Role On A Team? • 10 months ago

So if I understand it, TeamBilling has an "owner" that pays. However, this payment profile seems to be attached to the owner, not the team. From what I can tell, if a User1 owns team A, B, and C; he cannot have multiple billing profiles for each team. He will instead be charged from same payment profile.

Is this true, or am i reading docs wrong?

Also - Is the OWNER the only role accessing payment? Or can other admin types update payments?

...It seems this is kind of due to how Cashier attaches payment details to a User model rather than have a "Payment Details" table that could have a mappable belongsTo field.

27th September, 2017

inmn left a reply on Best Way To Access Collection's Attributes? • 11 months ago

Thanks @Snapey :)

inmn left a reply on Best Way To Access Collection's Attributes? • 11 months ago

Basically if i wrote a select

SELECT p.name,w.weapon 
FROM people p
INNER JOIN killers k 
    ON p.id = k.user_id
LEFT JOIN weapons w 
    ON k.weapon_id = w.id
GROUP BY p.name

So is "lazy loading" a good way for that, the eloquent way?

inmn left a reply on Best Way To Access Collection's Attributes? • 11 months ago

Im thinking in terms of eloquent orm model; User;

So ignore that,

$people = DB::... db query to get all people

$killers_with_weapons = $people->load('kills','weapon');

Or is it better to do a Union/Join in DB?

Goal is to have functions that want to cache results;

26th September, 2017

inmn left a reply on Best Way To Access Collection's Attributes? • 11 months ago

Silly question. Does this also work with collections.

Like $user = $user->all();, or is it better practice to not use Lazy Loading relationships with that, and instead Union/Join a query?

25th September, 2017

inmn started a new conversation Best Way To Access Collection's Attributes? • 11 months ago

I have a list of Kills by UserId; and a Table of Weapons;

I want to create a view with a Users Kills, and Weapon of Choice

(hasMany it seems.. but thats for a later tutorial)

Right now I can query a Collection and Get weapon_id's where Auth:user..

But I cant use those weapon_ids in the next query

$kills = new Kills; 
$my_kills = $kills->where('user_id',$me)->get();
...
$weapons = Weapons::whereIn('id',$my_kills->weapon_id);

Tips? :)

22nd September, 2017

inmn started a new conversation Looking For More Advice On Where To Put My Logic. • 11 months ago

So .. I hate putting login in /routes; but in Tuts, it talks about querying DB in it, and passing into view.

Normally I have 4 simple folders:

/classes/ /controllers/ /models/ /views/

I would put things like CRUD type functions in /classes; Models would be used to add my validation and rules, like "using Classes, get this users favorite foods if validation is ok" and controllers simply just have simple things like "if this users cool from this model, return this view"

In laravel the Tuts talk about doing DB queries in /routing/ (controllers); /Controllers seem to be a way to "fragment" your folders of /routing/ but also are are often used to display logic.

Middleware seems like a place for models that can either be on demand or attached to a group?

.. so where would a good old fashioned class go?

... /app/Http/ClassNameHere.php? (or /app/Me/ClassNameHere) ?

21st September, 2017

inmn left a reply on Laravel From Scratch. Anything Incorrect In 5.4 Tut Applied To 5.5 Release? • 1 year ago

Thanks. So model factory seems the most substantial. It is nice to know the "old" way was fine.

20th September, 2017

inmn left a reply on Laravel From Scratch. Anything Incorrect In 5.4 Tut Applied To 5.5 Release? • 1 year ago

Its more about the inconsistency of not knowing if this is depreciated, or a new way or if the "taught" method should even be employed.

As far as differences, this is the list I am working with from last time I glanced at: https://laravel.com/docs/5.0/releases#laravel-5.0

inmn started a new conversation Laravel From Scratch. Anything Incorrect In 5.4 Tut? • 1 year ago

I want to begin learning again. I abandoned laravel last year, trying to come back. Now I am finding 5.4 tutorials with a 5.5 current stable release.

Can I begin? If so - is anything obsolete in these lessons?

Should I wait for 5.5?

(PS. Sidebar rant.. this is why I hate frameworks.)

17th August, 2017

inmn started a new conversation Cannot Get Simple Laravel Valet Site Up • 1 year ago

I love new things. Hate when they dont work.

Went through a holy nightmare getting brew php 71 up and rolling, nginx up and rolling, fixing broken brewskies.

Now Valet seems to be pointing at my localhost, but ngnix isnt seeming to host the sites.

Could you please check my setup.

Laravel's config app domain i have "http://foo" and app name is "foo"

Valet i set the directory to "Valet park"

Valet Domain local

accessing http://foo.local i get "Connection Refused"

Pinging http://foo.local i get a hit to 127.0.0.1

Advice? :)

7th August, 2017

inmn started a new conversation Site Ids For A "nested" Site. Should This Be Handled Outside Laravel? • 1 year ago

Example:

(yes, this is very wordpress multisite-y)

If i had

A. Main.com a.1 1.main.com a.2 2.main.com B other.com B.1 1.other.com B.2 (cnamed) other-cnamed-domain.org B.3 (cnamed) other-diff.net B.4 4.other.com

In PHP i would first do a lookup of my "domains" table. see which domain belonged to what site, and what its parent / associated sites are.

set const SITE_ID = (lookup function )

Then later in my classes, $this->site_id = SITE_ID

In laravel. Whats the best way to approach this?

18th November, 2016

inmn left a reply on Laravel Is Slow As A Grandma Named Edna Counting Coupons At The Supermarket At 545pm. • 1 year ago

By the way - I played with this, tossing a simple POC app together. When i had to access Memcached for session, check if user exists, etc. My RPS went to 50, with a 300-400ms app load time, on a $20 digital ocean server

yes - not a "amazing" prod env, but should be able to handle more, yes?

Php7 Mysql 5.6

--- In comparison, I threw it on a t2-medium box @ aws; - i got 118 rps on -c 25;

We have a staging app with a 80gb DB, our user entries are there, which are 1mm rows. Not memcached; it could handle 300rps; I enabled memcached for sessions and i got 1800 -c 25 rps

It uses php custom framework; twig, guzzle, monolog, mandril, awssdk, and a few other packages. So by no means "light"

The page itself also had far more assets. Which doesnt matter for rps really, but still.

apache to apache, it was just slow. :(

Goodbye laracasts :(

17th October, 2016

inmn left a reply on Laravel Is Slow As A Grandma Named Edna Counting Coupons At The Supermarket At 545pm. • 1 year ago

Yes - but still, Apache, which is meant to serve, is still only 120 RPS;

Seems very sluggish, does it not?

inmn left a reply on Laravel Is Slow As A Grandma Named Edna Counting Coupons At The Supermarket At 545pm. • 1 year ago

So this was due to the nature of php artisan serve; when done via Apache2.4; the RPS went from 30 to 140

Installed apache on my machine

However - laravel is getting only 80-150 RPS consistently. I understand this is subject to machine variables; BG processes, etc.

However, similar tests via Apache are far faster. Is 130rps and a 800 mean time an acceptable metric for apache2.4 on a macbook pro (2015, i7, 16gb ram, not optimized)

apache2.4 mysql 5.6* php 7.1

inmn started a new conversation Laravel Is Slow As A Grandma Named Edna Counting Coupons At The Supermarket At 545pm. • 1 year ago

Laravel has a base install; started adding migrations, but havent run them yet; etc.

Noticed laravels home page loaded in 900ms.

Upgraded to php7.1; ran all recommended optimizations; still slow

Ran AB against laravel, at best i get 35 rps; a comparative hello world in php gives me XXXXrps. I know PHP is not a framework; but I would expect a 20% RPS of a heavy framework .

While i know "30 rps" is fine. Seems excessive.

MAC is using a SSD; so disk read issues is unlikely

Thoughts?

15th September, 2016

inmn left a reply on Before Jumping Into Laravel, Can Configs Be Dynamic? • 2 years ago

@LozovoyV - Thanks for the tip; can definately get something going with all this advice.

@everybody - appreciate the help in this thread!

inmn left a reply on Before Jumping Into Laravel, Can Configs Be Dynamic? • 2 years ago

Awesome - thanks Ryan :)

inmn left a reply on Before Jumping Into Laravel, Can Configs Be Dynamic? • 2 years ago

@londoh - thanks, so l4 is "filters" is the keyword for searching for the way to do this via l5 is "middleware"

before Middleware to be specific?

Ive read complicated multitenant setups; and for the most part; my indended app would start as "pseudo" multi tenant; much like a standard CMS using subdomains. I would like the option to extend. The problem that i have is when I read documentation on things like "this facebook package" - it says "set the Fb App Id in the config file here X"

Part of a new framework is always the whole "What the hell is it named" aspect of things; then its "what happens before what, magically"

So appreciate the help :)

Edit Your Profile
Update

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