beerbuddha

beerbuddha

Member Since 4 Years Ago

Experience Points 28,070
Experience
Level
Lessons Completed 317
Lessons
Completed
Best Reply Awards 1
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

20 Nov
22 hours ago

beerbuddha left a reply on Nova Panel Width Resizing

@EJDELMONICO - good approach - will check - thanks

beerbuddha left a reply on Nova Panel Width Resizing

@EJDELMONICO - yeah i tried - but i need a blueprint to base myself on. the nova-components so far as example:

  • entirely new resource dashboard
  • custom cards.

need something on the panel level. so far its everything but the panel

beerbuddha left a reply on Nova Panel Width Resizing

@EJDELMONICO - hi, i didnt want the resizing of the cards ...i asked for panels. the width function is for cards and im asking for a way to resize panels.

17 Nov
3 days ago

beerbuddha left a reply on Nova Actionable - How To Extend Or Show Field

@LARS-JANSSEN - but how does it attach to nova?

beerbuddha started a new conversation Nova Panel Width Resizing

With cards ->width('1/3'); can be used to take 1/3 of the space.

How would one do with a panel (i tried it said the function doesn't exist) as i have a model with many attributes and some relationships So instead of scrolling I wanted to group 2 pannels together but have them on split view horizontally (as if it was a card)

beerbuddha left a reply on Nova Actionable - How To Extend Or Show Field

@LARS-JANSSEN - Good old Spatie to the rescue. Thanks!

15 Nov
5 days ago

beerbuddha started a new conversation Nova Actionable - How To Extend Or Show Field

The idea of actionable is interesting with Nova - however I thought it would have been a history record log. So far it shows me "who did what and to what element" however its missing the "value" portion. As i dig into the trait - its a morphTo ... thats when i got lost.

Has anyone achieve customization for the Actionable trait to display extra columns...or to display more columns / relations in that section of the table?

So for example If a user Edited - i would like to know what they edited and possibility (within range) what was the previous value.

05 Nov
2 weeks ago

beerbuddha started a new conversation Nova BelongsTo Relationship Resource Creation Yields 404

Hi

I have the latest released 1.1.7.

I have two resources - once of which is a relationship When I create a relationship entry coming from the parent (so think user -> post and I am creating a post which has belongsto relationship as per documentation example)

I get that the relationship has been created (green message) BUT I then get a 404. As i do an inspect, the resource ID is not passed (its shown as undefined) from the nova-api//undefined

as I check the response it says: No query results for model

effectively that makes sense because no ID is being passed. I dont know what is going on or how to debug the fact that the ID from the parent relationship is missing yet the relationship has been created.

as far as my "fields" for my relationship model goes:

             ID::make('post_id', 'post_id')
                ->sortable()
                ->resolveUsing(function ($post_id) {
                    return (string)$post_id;
                }),
            Select::make('rating')
                ->options($value)
                ->sortable(),
            BelongsTo::make('User', 'user', User::class)
                ->hideWhenCreating()
                ->hideWhenUpdating()
                ->withMeta(['belongsToId'=> (string)$this->post_id])
                ->rules('required'),
        ];

Note I use the resolveUsing because the post_id are bigint and due to JS limitation with bigint - i have to convert them into strings for it to work.

19 Oct
1 month ago

beerbuddha left a reply on How To Bulk Edit In Nova

@bryanmonzon thanks for pointing that out - appreciated

beerbuddha left a reply on How To Bulk Edit In Nova

@bryanmonzon code wise is ...?

18 Oct
1 month ago

beerbuddha left a reply on How To Bulk Edit In Nova

Sure. Lets take Nick Basile's Deep dive into Nova: https://nick-basile.com/blog/post/deep-diving-laravel-nova

in the lead resource - if i want to select several leads (or all) i can - but then I would like to take an action on it (ie change PROSPECT to LEAD) - how would one do it? - hence the bulk edit question

16 Oct
1 month ago

beerbuddha started a new conversation How To Bulk Edit In Nova

I know you can set a boolean (or fixed field) as an action (such as deactivating)

How would one bulk edit - like I have a resource of Items and I would like to change the prices on select items to be a certain amount.

So far I have managed to adventure to the Action part - however I am uncertain how to invoke it properly.

10 Oct
1 month ago

beerbuddha started a new conversation How To Effectively Microservices With Nova

Hi

I have several microservices that I am fetching data from (the bane of microservices) - so i do not control all the DB entries points - is there any one who has successfully leverage microservices and the nova together? I would like to know some form of high level workflow if possible, (examples of user->post->comments) is fine.

Normally (in regular laravel application i have built) I would create a service - that feeds itself Guzzle and get set via config which service url it needs

then I would call such service inside a controller / manager to fetch the required data - then once the data is return - operate logic. When I would work with a Front-end developer on this with Laravel as the "service" I would make sure the controller is json formatted so that the vue-components for the front end receive the data. I haven't been able to figureout if Nova can easily solve this (or be extendible) in regards using Nova as the boilerplate front-end and then the back-end laravel application are calling the microservices instead of having eloquent do it.

Or perhaps Nova can't be coupled or not yet flexible for such feature. tks for the help

17 May
6 months ago

beerbuddha started a new conversation Queue::bulk Not Testable

I was able to use Queue::bulk to send a bunch of queue jobs and have Queue::fake test them.

For some reason this week (May 11ish) - this is no longer the case and without changing my tests i have to use Queue::pushOn() instead.

version of laravel: "version": "v5.5.21",

15 May
6 months ago

beerbuddha started a new conversation Why Goto Was Used Inside The Laravel Framework

So on twitter this little discovery escaped me, a goto command inside a laravel helper: https://github.com/laravel/framework/blob/35a8805603b63e18949cab5bb1c260261ddc1435/src/Illuminate/Support/helpers.php#L780

now obviously - inside php manual there is a xbdc meme about it: https://stackoverflow.com/questions/1900017/is-goto-in-php-evil

I was just wondering - do/while...or while infinite break....but goto?

do it just boil down to readability?

11 Apr
7 months ago

beerbuddha started a new conversation Better Way To Submit Json Data In Post Test

I currently have this testable piece of code to submit a json filled data via post. I let my controller do its thing and respond back.

$responseKey = 'abcdabcd6b1649f681a408f1beebabcd';
        $sendJson    = $this->createSaleResponse($responseKey);
        $sendHeaders = [ 'CONTENT_TYPE' => 'application/json' ];
        $response = $this->call(
            'POST',
            'ext-purchase-api/api/roku/notifications',
            [],
            [],
            [],
            $sendHeaders,
            $sendJson
        );
        $this->assertEquals(200, $response->status());
        $receiveData = $response->getContent();
        $this->assertEquals($responseKey, $receiveData);
        $response->assertHeader('ApiKey', $secret);

I am used to the restful API of $this->get and $this->post - is there a better way to format this code?

23 Feb
8 months ago

beerbuddha left a reply on Any Reasonable Reason To Use Yield?

@Cronix the example from the php page did not enlighten on the reasoning behind using yield.

beerbuddha started a new conversation Any Reasonable Reason To Use Yield?

I never knew the function yield existed in PHP until Laravel's Illuminate/Database/Connection.php

line 369 (from Laravel 5.5) - has

        while ($record = $statement->fetch()) {
            yield $record;
        }

im so used to foreach/while standard that i dont get why a yield is useful here.

Anyone able to explain?

14 Feb
9 months ago
13 Feb
9 months ago

beerbuddha started a new conversation Laravel Passport Not Respecting Oauth Refresh_token?

Hi I have a laravel application (5.5) using passport but the refresh_token seems weird.

I thought refresh_tokens can be kept (hence why long lived) to request new access_tokens until revoked/expire

but within laravel passport - it is a one time usage.

I was in the assumption from the following articles:

https://auth0.com/blog/refresh-tokens-what-are-they-and-when-to-use-them/ https://medium.com/@bantic/more-oauth-2-0-surprises-the-refresh-token-1831d71f4af6

that indeed refresh_tokens doesn't refresh the access_token but grant you new ones but while granting new ones - it grant me a new refresh_token to use and actually revoked the old one.

  1. is this weird behavior? or is this how it is suppose to be??
  2. is there a way to make the refresh_token be reusable to grant access_tokens until revoke/expire
14 Jan
10 months ago

beerbuddha started a new conversation Using FormRequest To Power Routes

For those who are Taylor Otwell's Laravel tip, has anyone been able to figure out where he has gotten the return query from?

use App\Order;
use App\Http\Requests\OrderSearchRequest;

Route::get('/', function (OrderSearchRequest $request) {
    $request->filters()->each->apply(Order::newQuery());

    return $query->get();
});

was the final refactor but variable $query was never declared so I am wondering where it came from. Can anyone help?

12 Dec
11 months ago

beerbuddha started a new conversation One Time Usage For Laravel Passport Refresh_token ?

So i am using passport to implement OAuth2.0 - however I've been told (and also assumed) that the refresh_token is long lived. (which is the case) but also multiple usage.

After experimenting with Laravel Passport - I found that it maybe long lived - but its a single usage - when you invoke the refresh_token grant - you get a new refresh_token with the new access_token.

As per documentation: refresh_token is to obtain a new access_token - not to refresh the access_token. I wanted to know if the one time usage is from Laravel Passport point of view or has it always been like this?

I cannot find documentations about how many usage the refresh_token is suppose to be.

19 Oct
1 year ago

beerbuddha started a new conversation Using Caching A Bit More OOP

I have the following for index() inside my controller:

 $members = Cache::remember('members'.sha1($membershipsBuild->toSql()), env('CACHE_MEMBERS_TIME', 0.001), function () use ($membersBuild) {
                return $membersBuild->get();
            });

My questions are:

  1. is there a better OOP approach? Ie can I avoid the helper? I am aware that it is actually a contract but If i send the contract - I will need to fetch the instance afterward.
  2. is there a better approach to past the TTL of the cache instead of ENV? feeding it an arbitrary fixed number seems wrong..but this is my best way for this for now.
  3. when adding cache - so far with this solution - makes tests past - Is there any usefulness in testing the cache itself? I mean I could in theory mock it but that would be a separate test on itself...However i find it tidious to do it. Any opinions on that?
18 Oct
1 year ago

beerbuddha left a reply on How To Implement Middleware Structure Design

Well in terms of application (let it be SasS or PasS) Business Logic is define as: your features.

It the most raw term: "whatever you do to the content-data in terms of manipulation"

example:

  • Give me a list of customers's data (first name, last name, DOB) - content-data - can be fetch via a lean microservice (in laravel it can be model->find();)

business logic on top of it:

  • give me all patients thats has been Sick for the past 4 weeks and their symptoms. (which in term we can present it inside a dash board).

that means->go fetch user data->then load relationships->remove non-essential items (so using fractal...i can remove pivot data if necessary) and then return. I would typically make a controller "/sickpatients/" which returns only patients that was sick, this way the given client (so lets say blade or vue) can just fetch everything and present it to the client.

beerbuddha started a new conversation How To Implement Middleware Structure Design

So Laravel has it's own middleware which you can use for validations for example.

My coworker insist that "business logic" be put in the middleware and the API logic becomes the microservice then VUE/blade can be the front-end presentation.

However - with the ease of Laravel - I've put some logic inside controllers.

Is the same middleware that my coworker is talking about the same middleware found in Laravel?

If not - then where / how would you structure the separation of: Presentation -> middleware -> microservice?

13 Oct
1 year ago

beerbuddha started a new conversation What Is The Proper Approach To Service Batch Request Via API

I am using Laravel 5.5 as a CMS.

My coworker is the frontend - I am the backend.

I treat frontend as a client (so if it was mobile or other application written in angular) as a contract work where I service API as a backend developer.

My issue currently (despite working so far) is that clients (let it be the frontend developer or a project owner) wants faster speed. Then they utter the words

"can't we send everything in a batch bundle and you as a back end treat it as such"

Now as much as i like developing restful api - I honker down to: "ok well...send your POST/PUT as a json - and I will treat it as a field and unroll it"

On gut feeling - I loose a lot of the simple fundamental on restAPI validation (ie ifi use the validator I have to first check if json is correct, then i let it go through and i need to build another layout for individual mini post data.

Does anyone have a good solution to avoid a single entry point of a controller that does a large singular unrolling?

Now as an example:

  • given a form written in vue.js - you can allow the user to chain up forms for submission. (similar to where you can hit the + symbol and a new mini form opens up and you can chain up to N forms). Ideally I would like for each part of the form to be submitted to each restful endpoint - however practically (for speed) vue.js will bundle everything into one submit.
12 Oct
1 year ago

beerbuddha started a new conversation Dusk With Vue.js Testing

Seeing this piece of news: https://laravel-news.com/vue-js-unit-testing-utils

Has anyone successfully integrated this into Laravel Dusk? Or is Laravle Dusk not appropriate for this

10 Oct
1 year ago

beerbuddha left a reply on Eager Loading OrderBy Not Working As Expected

Thanks to @Snapey - I rolled back and with the help of the following person (3 years ago) https://laravel.io/forum/02-10-2014-several-eager-loading-with-constraints

I have found that I need to nest it:

$data = $this->users
    ->with([
        'roles' => function ($q) {
            $q->with(['tabs' => function ($q) {
                $q->with(['department' => function ($q) {
                    $q->with(['panel' => function ($q) {
                        $q->orderBy('position', 'asc');
                    }])->orderBy('position', 'asc');
                }])->orderBy('position', 'asc');
            }])->orderBy('position', 'asc');
        }
    ])
->findOrFail($id);

beerbuddha left a reply on Eager Loading OrderBy Not Working As Expected

@Snapey you are correct - with only 1 eager loading - it is working as respected - it is when you start chaining them - that the first relationship doesn't respect it anymore.

the position column is almost everywhere (its similar if I wanted to order them with created_at which is everywhere also

beerbuddha left a reply on Eager Loading OrderBy Not Working As Expected

@Snapey one issue with giving a new relation is that now I have to use the new relation name instead of the old one.

I have to modify all old reference of $user->roles-> to $user->rolesAsc instead.

beerbuddha left a reply on Eager Loading OrderBy Not Working As Expected

@Snapey yes - but if thats the case - I need to know how i can point out in the documentation that its not working as it should

beerbuddha left a reply on Eager Loading OrderBy Not Working As Expected

@Snapey Unfortunately I need it to be dynamic - I shouldn't be forced bootstrap it like that.

so is this a bug? because the documents states otherwise and so does other places.

My only true hack for this is to do a queryScope and use your solution.

Ill do that as a last resort.

beerbuddha left a reply on Eager Loading OrderBy Not Working As Expected

@Snapey I want to order the relations, and the ordering of the relations are not respected. Thats the issue.

beerbuddha left a reply on Eager Loading OrderBy Not Working As Expected

@bobbybouwmann Actually I just re-read your statement, i do not want to re-order the users (as you can see its a findOrFail at the end)

What i want is the elements of the eager loading to be ordered (ill edit my question too for anyone else responding)

beerbuddha left a reply on Eager Loading OrderBy Not Working As Expected

@bobbybouwmann then how come in the documentation it shows that it should work? thats the confusing part.

beerbuddha started a new conversation Eager Loading OrderBy Not Working As Expected

as per documentation: https://laravel.com/docs/5.5/eloquent-relationships#constraining-eager-loads

I am trying to run eager loading with constraint by doing multiple with closure. However they do not return the correct constraint specified.

$data = $this->users
                ->with(['roles' => function ($q) {
                    $q->orderBy('position', 'asc');
                }])
                ->with(['roles.tabs' => function ($q) {
                    $q->orderBy('position', 'asc');
                }])
                ->with(['roles.tabs.department' => function ($q) {
                    $q->orderBy('position', 'asc');
                }])
                ->with(['roles.tabs.department.panel' => function ($q) {
                    $q->orderBy('position', 'asc');
                }])
                ->findOrFail($id);

the position of all "with" are not respected. Any reason?

04 Oct
1 year ago

beerbuddha started a new conversation Relationships Vs Relationships() In Eloquent

I would like to re-understand the relationship modifier in Eloquent properly as I am properly misusing it.

If I have a one to many or many-to-many relationship between class A and class B

I find myself bumping into Query::builder errors when applying the relationships within foreach loop. (i find it skipping)

ie :

foreach ($objectA->relationships() as $objRel) {
...
+

in order to effectively utilize this:

foreach($objectA->relationships()->get() as $objRel) {
...
}

is the correct way.

But I find that I sometime do this instead:

foreach($objectA->relationships as $objRel) {
...
}

and the application works and doesn't squawk.

However I wanted to know which way is correct and which way if I have eager-loaded my relationship with the with() is the correct invocation that effectively use the eager-loading properly.

15 Sep
1 year ago

beerbuddha started a new conversation Pug/Jade Path Not Resolving Properly Into Laravel Views

I am porting over an existing pug/jade template over to Laravel 5.5. I am using https://github.com/BKWLD/laravel-pug package.

Original file structure was: /views/*.jade /public/fonts/ /public/resources/ /public/svg /public/vendor

When i ported them over into laravel, I kept the same structure. Inside my index.jade file.

I have includes that looks like:

include /views/include

// body starts here
body
div(class="ma-container content-stage-wrapper ")
    div(class="push-left-2")
        section(class="row vertical-push-1 user_section")
            aside(class="admin_section_aside")
                include /views/manage_tab/edit_tab_form

    div(class="row pad-hor-2")
        include /views/user_panel

    div(class="admin-panel-app-overlay")

in the original project - no issues. In the Laravel project - "page not found" which i am assuming that those /views/manage_tab/ sub_folders jade template are not being rendered properly.

in my laravel-pug.php file I have enabled both .jade and .pug file extension and the baseDir is 'basedir' => resource_path('views'),

what am I missing so that the original path is being understood from the structure of laravel? It seems that it is not resolving properly.

12 Sep
1 year ago

beerbuddha left a reply on Cannot Deploy Coaster CMS On Forge Server

@ejdelmonico have you ever compiled a pro/con between the 3 CMS that you have installed so far that are laravel base? Im curious to see the differences between them

beerbuddha left a reply on Cannot Deploy Coaster CMS On Forge Server

@ejdelmonico Yup - I tried running it and it tells me that the command doesn't exists.

According to CoasterCMS you are suppose to load the service providers and everything is fine (works on local / valet) but on forge server it refuses to get recognized

beerbuddha started a new conversation Cannot Deploy Coaster CMS On Forge Server

I am able to run Coaster CMS via Valet, however when i deploy on forge: php artisan coaster:update-assets failed to work on forge.

I am getting an error that on 'php artisan coaster:update-assets' that it doesnt exists. All the other instructions I have done and it works on my local - however for this it doesnt.

Any idea? also i tried to use your read me and it tells me it is deprecated. echo "This script is deprecated, you should now run: php artisan coaster:update-assets \n";

I have also deleted the vendor and reloaded it on the forge server itself - same outcome.

07 Sep
1 year ago

beerbuddha left a reply on If Vue-router Is The Future, What Are Web Routes Good For?

@R3l4x3 3 years in tech is quite a long time.

yes if it is a minor sass app with a simple back, I would think think the same.

beerbuddha left a reply on If Vue-router Is The Future, What Are Web Routes Good For?

@R3l4x3 good find - however there are no timestamp - therefore some of these "disadvantage" might have been solved.

For example people stated that SPA are bad for SEO - however Evan You has stated that there are solutions for this.

The arguments it presents are sound - but a timestamp on the article would have helped to see which ones are still relevant.

beerbuddha left a reply on If Vue-router Is The Future, What Are Web Routes Good For?

@36864 if you create a webpage fallback if javascript fails...aren't you coding in double? or is something escaping me?

beerbuddha started a new conversation If Vue-router Is The Future, What Are Web Routes Good For?

With vue-router providing front-end framework for web routes thus turning your application into a SPA application - I am wondering is the route/web.php file still relevant?

I mean api.php are for all the API endpoints but seems like the web.php will have the catch-all route so that the vue-router will resolve them.

14 May
1 year ago

beerbuddha left a reply on Composer Conflict When Installing Valet

For those who have this problem still:

Using version ^2.0 for laravel/valet
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install laravel/valet v2.0.4
    - Conclusion: don't install laravel/valet v2.0.3
    - Conclusion: don't install laravel/valet v2.0.1
    - Conclusion: don't install symfony/process v3.2.8

@beeInteractive solution to update: composer global update

worked

12 May
1 year ago
01 May
1 year ago

beerbuddha started a new conversation INSERT INTO SELECT FROM Eloquent Style

Is there a laravel/eloquent way to do a INSERT INTO SELECT FROM WHERE insert into the DB?

I didn't want to invoke a DB::RAW

05 Mar
1 year ago

beerbuddha started a new conversation How To Extends Console Commands

In laravel - console commands are define by: protected $signature

How do you create base commands and then extends the $signature and initialization?

In Symfony commands: there is a configure function and initialize function which can invoke the parent::configure / parent::initialize to chain upward

I am finding too many copy/paste in my current commands due to this - can someone shed some light?