Talinon

Talinon

Member Since 4 Years Ago

Toronto

Experience Points
206,100
Total
Experience

3,900 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
1015
Lessons
Completed
Best Reply Awards
165
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    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 Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

Level 42
206,100 XP
Feb
21
1 day ago
Activity icon

Awarded Best Reply on UploadedFile Path, Filename, Basename, Pathname, And Extension Empty On Ubuntu

@alex29

I suspect it's the upload_max_filesize setting within php.ini on the web server. Default is usually 2MB.

 size: 2497377   // over 2MB

the other clue is the mime type:

-mimeType: "video/mp4"  // local
 -mimeType: "application/octet-stream" // server

That suggests that it can't upload the file in its entirety because again of the max upload file size configuration.

Activity icon

Replied to UploadedFile Path, Filename, Basename, Pathname, And Extension Empty On Ubuntu

You might want to check the post_max_size value, too.

I'm almost certain your problem will be one or the other.

Activity icon

Awarded Best Reply on Update The Record If It Exists Laravel

@jgnasser It looks like you have the parameters reversed for the updateOrCreate() method. The first parameter should be the column / value-pairs that you want to locate, the second parameter is what you want updated.

 $rating = Rating::updateOrCreate(
        ['user_id' => $user_id, 'movie_id' => $movie_id], // locate records matching user_id & movie_id
    ['star_value'=>$star_value]  // update the star_value
        ); 
Activity icon

Replied to Search Key By Value Using Collection

@untymage

I think something like this would work:


$search = 'Folk';

$collection->filter(function ($group) use ($search) { 
    return in_array($search, $group); 
})->keys()->first();

Basically filter the collection down to the items that contain what you're searching for and pull the first key. If it doesn't exist, it should return null.

Activity icon

Replied to Update The Record If It Exists Laravel

@jgnasser It looks like you have the parameters reversed for the updateOrCreate() method. The first parameter should be the column / value-pairs that you want to locate, the second parameter is what you want updated.

 $rating = Rating::updateOrCreate(
        ['user_id' => $user_id, 'movie_id' => $movie_id], // locate records matching user_id & movie_id
    ['star_value'=>$star_value]  // update the star_value
        ); 
Activity icon

Replied to Collection Pass Blade

@aronaman The reason why the collection methods don't work, such as pluck, sum and implode is because you're converting your collection to an array within the controller, then passing that array to blade.

Just don't convert to an array.

 $groups=$lists->groupBy('validation_code')->toArray();  // remove ->toArray()
Activity icon

Awarded Best Reply on Laravel Task Scheduler: Managing Tasks Which Take Longer Than One Minute To Execute?

@tgbv Regardless if Cron is calling every minute, you can configure Laravel's Task Scheduler to execute your tasks whenever, or however frequently you desire. If there is nothing scheduled, Task Scheduler will just close and wait for the next call from Cron.

So, if you have a long running script, just make a task entry for something that runs every 2 minutes, or 5 minutes, or however long you think it needs.

For example:

$schedule->command('my-command')->everyFiveMinutes();

Cron can call Task Scheduler to run every minute, but that command will only execute once every five calls.

To answer your question, no it will not kill processes already running.

If the length of time to process is too much of a variable, then you could consider making some kind of process mutex, drop file, or lock-entry in a database to let future processes know that there is a job in progress and to die immediately.. so yes, handle it yourself in some way.

Feb
20
2 days ago
Activity icon

Awarded Best Reply on Failed Event Will Throw Exception On Retry

@soremwar

What do you have in your VariableApprovalChanged event class? You should have public properties defined within it which the listener can access.

Activity icon

Replied to Report All Errors Via Email

@smartnathan You can set up all kinds of methods and services to report errors. You can read about i there:

https://laravel.com/docs/master/logging

I personally use Bugsnag, which has support for Laravel.

https://docs.bugsnag.com/platforms/php/laravel/

Activity icon

Replied to Telegram Updated Id

@hasen39 I'm afraid you may need to resort to using your brain.

Please don't create duplicate posts. You already got a response here:

https://laracasts.com/discuss/channels/general-discussion/telegram-updated-id

Activity icon

Replied to Collection Pass Blade

@aronaman I think you just need a nested foreach?

@foreach ($groups as $key => $group)

    @foreach ($group as $item)
        {{ $item->id }}
    @endforeach

@endforeach
Activity icon

Replied to Failed Event Will Throw Exception On Retry

@soremwar

What do you have in your VariableApprovalChanged event class? You should have public properties defined within it which the listener can access.

Activity icon

Replied to UploadedFile Path, Filename, Basename, Pathname, And Extension Empty On Ubuntu

@alex29

I suspect it's the upload_max_filesize setting within php.ini on the web server. Default is usually 2MB.

 size: 2497377   // over 2MB

the other clue is the mime type:

-mimeType: "video/mp4"  // local
 -mimeType: "application/octet-stream" // server

That suggests that it can't upload the file in its entirety because again of the max upload file size configuration.

Activity icon

Replied to Trying To Test If A Relationship Exists

@jgravois withoutExceptionHandling() is going to have no affect on a unit test. You would use that on a feature test where you are making a request to the application and want to disable exception handling in order to see the underlying error instead of the exception.

Now that is cleared up. The first thing I notice is you're getting a collection, but treating it like a single model.

 Consignment::with('bands')->whereConsignmentCode('FIXED')->get();  // collection

So, when you access bands on $con, you are trying to access a property on the collection, and getting the error.

Changing get() to first() would retrieve a single model, and then your test should work.

Activity icon

Replied to Laravel Task Scheduler: Managing Tasks Which Take Longer Than One Minute To Execute?

@tgbv Regardless if Cron is calling every minute, you can configure Laravel's Task Scheduler to execute your tasks whenever, or however frequently you desire. If there is nothing scheduled, Task Scheduler will just close and wait for the next call from Cron.

So, if you have a long running script, just make a task entry for something that runs every 2 minutes, or 5 minutes, or however long you think it needs.

For example:

$schedule->command('my-command')->everyFiveMinutes();

Cron can call Task Scheduler to run every minute, but that command will only execute once every five calls.

To answer your question, no it will not kill processes already running.

If the length of time to process is too much of a variable, then you could consider making some kind of process mutex, drop file, or lock-entry in a database to let future processes know that there is a job in progress and to die immediately.. so yes, handle it yourself in some way.

Activity icon

Replied to Adding Data To A Component From Another

Give this a read for a simple explanation on using a global event bus to send and receive events:

https://alligator.io/vuejs/global-event-bus/

Feb
19
3 days ago
Activity icon

Replied to 500 Error In Laravel But Log Folder Is Empty

@afoysal Start off by checking your config/logging.php configuration, and check to see if you have LOG_CHANNEL defined in your .env file. It's possible its set to log to something other than the file system.

You might also get information from the Apache/Nginx webserver error log, too.

Activity icon

Replied to How Can I Count From Model ?

@fareedr

Using the first result from Stock as an example:

Stock::first()->activities()->count()

If you have several results, and you're only looking to get the count, you can do so without the consequence of actually loading the relationship:

$stockCollection = Stock::withCount('activities')->get();

Each result will then have a activities_count attribute representing the number of activities.

foreach ($stockCollection as $item) {
    echo $item->activites_count;
}

You can read more here:

https://laravel.com/docs/5.8/eloquent-relationships#counting-related-models

Activity icon

Replied to Adding Data To A Component From Another

@theunforgiven

You could just pass the form object in as a prop, and that would give you 2-way binding between the components, but it's considered a bad practice; because you are mutating data somewhere other than the parent. Data should only flow down. Reference:

https://vuejs.org/v2/guide/components-props.html#One-Way-Data-Flow

What you should do is $emit an event, which the parent component can listen for and update its own form data accordingly. There are some shortcuts you can use to make this fairly painless.

This is a good resource for you, even has an example of a nested component (grandchild to grandparent)

https://www.telerik.com/blogs/how-to-emit-data-in-vue-beyond-the-vuejs-documentation

Feb
18
4 days ago
Activity icon

Replied to Phpunit Overrides My Msqldatabase

@iristechph

Two things off the top of my head to check:

  1. Check your config/database.php file to make sure your settings for your sqlite connection is correct.

  2. It is possible your settings are being ignored if your configuration is cached. Try running php artisan config:clear. For good measure, maybe give your cache a clear, too: php artisan cache:clear

Activity icon

Awarded Best Reply on Elocuent Newbe Question

@leostereo

When using first() you are receiving a single instance of a model. When using first()->id, you are accessing a property on the model, hence why you get 74.

When using get(), you're expecting to get a collection of models. You can access models within the collection using an index, just as you would an array. If mac is a unique field in your database table, then calling get('id')[0]->id would be the equivalent to first()->id... but is unnecessary since you would use first() on a unique field, but just an example of retrieving an item from the collection by its index.

You can also loop thru a collection just like an arrray, using native foreach.. or you can use many of the powerful built-in methods on the collection class:

https://laravel.com/docs/5.8/collections#available-methods

Feb
17
5 days ago
Activity icon

Replied to Elocuent Newbe Question

@leostereo

When using first() you are receiving a single instance of a model. When using first()->id, you are accessing a property on the model, hence why you get 74.

When using get(), you're expecting to get a collection of models. You can access models within the collection using an index, just as you would an array. If mac is a unique field in your database table, then calling get('id')[0]->id would be the equivalent to first()->id... but is unnecessary since you would use first() on a unique field, but just an example of retrieving an item from the collection by its index.

You can also loop thru a collection just like an arrray, using native foreach.. or you can use many of the powerful built-in methods on the collection class:

https://laravel.com/docs/5.8/collections#available-methods

Activity icon

Replied to Elocuent Newbe Question

@leostereo It is not a "big array of data" but rather a Collection Object. When working with Eloquent, you generally receive an instance of a Model, or a collection of models.

If you specify exactly what you want to get, or pluck, and then use toArray(), as @willvincent mentioned, you will get the data represented in a way you are accustomed to working with.

However, more times than not, you don't need to convert to an array. As the author of Laracasts has said at one time: "think of Collections as an array on steroids". You're essentially working with a more powerful array and you usually don't necessarily need to transform it into a primitive structure.

Feb
14
1 week ago
Activity icon

Awarded Best Reply on How To Sort In A Foraech Statement

@ctyler Sure, assuming you're using Laravel, you could harness the power of collections.

Something like this:


$permissionArray = [
    'assignment_add',
    'assignment_delete',
    // ...
];

$permissions = collect($permissionArray)->groupBy(function ($item) {

    return explode('_', $item[0];

});

That will group all the elements within the collection by the string before the first underscore.

$permissions['assignment'] for example, will give you all permissions starting with assignment

You could then just loop thru the groups, doing your styling for each one as you see fit.

If you're using blade, you could do something like this.. just as a crude example:

@foreach ($permissions as $groupName => $group)

    <h1>{{ $groupName }}</h1>
    @foreach ($group as $permission)

        <ul>{{ $permission }}</ul>
    
    @endforeach

@endforeach
Activity icon

Replied to How To Sort In A Foraech Statement

@ctyler Sure, assuming you're using Laravel, you could harness the power of collections.

Something like this:


$permissionArray = [
    'assignment_add',
    'assignment_delete',
    // ...
];

$permissions = collect($permissionArray)->groupBy(function ($item) {

    return explode('_', $item[0];

});

That will group all the elements within the collection by the string before the first underscore.

$permissions['assignment'] for example, will give you all permissions starting with assignment

You could then just loop thru the groups, doing your styling for each one as you see fit.

If you're using blade, you could do something like this.. just as a crude example:

@foreach ($permissions as $groupName => $group)

    <h1>{{ $groupName }}</h1>
    @foreach ($group as $permission)

        <ul>{{ $permission }}</ul>
    
    @endforeach

@endforeach
Activity icon

Replied to How Can I Load A Relationship On Illuminate\Support\Collection

@untymage If you only want an array of tag names:

$this->groups->tags->pluck('name')->toArray();
Feb
12
1 week ago
Activity icon

Awarded Best Reply on 404 Error After Form Update

@rretzko

It is likely one of your findOrFail() calls. If findOrFail can't find the model, it will default to throwing a 404 if the error is not caught.

Activity icon

Awarded Best Reply on Sometimes Browser Displays JSON Before Full Html Page Load

@guntarsv Sounds like you might need to use the v-cloak directive. You can add it directly to your app' s mounted root element. The documents state its only for mustache bindings, but it's worth giving it a try.

https://vuejs.org/v2/api/#v-cloak

https://stackoverflow.com/questions/42262007/hiding-vue-js-template-before-it-is-rendered

Activity icon

Replied to Sometimes Browser Displays JSON Before Full Html Page Load

@guntarsv There is absolutely nothing wrong with having your component make the ajax calls. That is one of the great things about components - they are like containers where logic and styling can be self contained. It also keeps your app well structured and cleans up your root/parents by moving code into a child component that can be solely responsible for the functionality.

I always look for ways to refactor stuff out of the "root" and into components whenever possible. I might opt for making ajax calls in the parent if it makes sense to do so, such as I need to work with that data across multiple components. Otherwise, I try to encapsulate it as best as I can in sub components.

Activity icon

Replied to Sometimes Browser Displays JSON Before Full Html Page Load

@guntarsv Sounds like you might need to use the v-cloak directive. You can add it directly to your app' s mounted root element. The documents state its only for mustache bindings, but it's worth giving it a try.

https://vuejs.org/v2/api/#v-cloak

https://stackoverflow.com/questions/42262007/hiding-vue-js-template-before-it-is-rendered

Activity icon

Replied to 404 Error After Form Update

@rretzko Glad to hear it. Please mark this thread as closed.

Activity icon

Replied to Can I Choose Between Base Factories For The Same Model?

@consil

You have several options.

As @flyzero said, you could probably just delete the package's factory. The downside to this is you'll need to remember to do that every time you upgrade your dependency.

You could just extend the package's model into your own application specific model, and then create a factory on it.

If its just a one-model exception, you could just make your own factory within your test suite. It could be as simple as defining a function that creates a model (or collection) with the parameters you pass in, then returns it.

Activity icon

Replied to 404 Error After Form Update

@rretzko

It is likely one of your findOrFail() calls. If findOrFail can't find the model, it will default to throwing a 404 if the error is not caught.

Activity icon

Replied to Integrating Laravel With Microsoft Exchange

@ja_laravel_developer

The first thing you need to determine is whether or not you'll be integrating with an on-premises Exchange Server, or working with cloud-based Office-365.

If you're dealing with on-prem, you'll probably want to look into the php-ews package.

https://github.com/jamesiarmes/php-ews

If you're working with Office-365, then I would suggest working directly with Microsoft Graph's API. I just recently migrated a complex application that was heavily integrating with EWS over to Graph. It is Microsoft's latest platform for interacting with all kinds of services. You'll also find much more information, and better documentation.

After working with EWS for the better part of a decade, I can say that working with EWS is hell. If its within your control, I highly suggest working with the modern Graph API. If its not within your control, I would encourage the decision makers to migrate to Office-365 before you even attempt integration. It's just a matter of time until you'll basically be strong-armed into moving to Office-365 anyway. Also, Microsoft has already announced they are no longer adding new features to the EWS platform.

There is a PHP SDK for working with Graph. It's handy for converting responses from the API into flexible models that are easier to work with. Although, I find sometimes it's easier to directly work with the API using guzzle. That is a choice you'll need to make yourself. You can find more information on it here:

https://github.com/microsoftgraph/msgraph-sdk-php

If you're only looking for email integration, you might be able to find a Laravel mail driver that will do the majority of the work for you. In my case, I need much more integration than just email, but also contacts, calendar events, etc. If you foresee needing more integration support down the road, I would avoid using packages or wrappers and just make your own implementation. You'll thank yourself later when you're not hand-cuffed by someone else's package. Like I said, working with Graph is a much more pleasant experience.

You'll also need to handle OAuth2 token-based authentication, which is another layer of complexity, but it's really not that difficult to implement. Come Oct 2020, they are forcing EWS to use OAuth2 token based authentication - so regardless of which solution you decide, you'll be forced to deal with it either way.

Feb
08
2 weeks ago
Activity icon

Awarded Best Reply on Remove Public From Url

@zakariaarrid Of course you would. It sounds like you currently have a big security issue if the root of your website is directed to your Laravel application's root. for example, someone right now could request www.name.com/.env - and you certainly don't want that.

Review your web server configuration and make sure you have it configured to point to your public folder, not your application root. Then your www.name.com site will load from the public folder by default, and you won't need to specify /public within the url.

Activity icon

Replied to Embedding PDF Wishin A PDF Using Laravel-snappy

@browntown Yeah, you might have to resort to another solution, or execute another process that does the merging before serving the file.

You might want to research this, too:

https://www.itsolutionstuff.com/post/laravel-merge-multiple-pdf-files-exampleexample.html

Activity icon

Replied to Remove Public From Url

@zakariaarrid No, you need to change the configuration within your web server.. whatever that may be. Such as Apache, nginx, etc.

Activity icon

Replied to Remove Public From Url

@zakariaarrid Of course you would. It sounds like you currently have a big security issue if the root of your website is directed to your Laravel application's root. for example, someone right now could request www.name.com/.env - and you certainly don't want that.

Review your web server configuration and make sure you have it configured to point to your public folder, not your application root. Then your www.name.com site will load from the public folder by default, and you won't need to specify /public within the url.

Activity icon

Replied to Embedding PDF Wishin A PDF Using Laravel-snappy

@browntown Do you need to keep the formatting of the state provided PDF, or is it just the content that is important? For something that happens once a year, maybe just a manual c&p of the text into a database would suffice. Or like you said, maybe just scan it and append it as an image.

Activity icon

Replied to Embedding PDF Wishin A PDF Using Laravel-snappy

@browntown Honestly, I've never tried. But, I do have an application that requires terms and conditions to be appended to the end of a PDF. I just have the terms stored to a database, and dynamically add them to the end of the page that gets converted to a PDF. In my case, periodically the terms and conditions change, so having them hard written to another PDF wouldn't be ideal anyway.

You might want to consider doing something similar.

Activity icon

Awarded Best Reply on Apache Virtualhost And Routing Issue

@ase

Well, right away you have a typo in your Directory directive:

<Directory /var/vvv/html/mediathek/public>

Should be www not vvv

Also make sure you've made an entry within /etc/hosts for your virtual host. I suspect you have, otherwise you would get an unresolved error, not a 404.. but just thought it is worth mentioning, just in case.

Activity icon

Replied to Apache Virtualhost And Routing Issue

@ase

Well, right away you have a typo in your Directory directive:

<Directory /var/vvv/html/mediathek/public>

Should be www not vvv

Also make sure you've made an entry within /etc/hosts for your virtual host. I suspect you have, otherwise you would get an unresolved error, not a 404.. but just thought it is worth mentioning, just in case.

Feb
07
2 weeks ago
Activity icon

Awarded Best Reply on FormRequest Cusomize Action For Failed Authorization

@bwrigley I just tested this myself - and you're correct. If you return false from the authorize() method, and then override the failedAuthorization method in the way you did, it will continue to execute the controller method. I think this is because the framework would usually throw an AuthorizationException (403) which would prevent the normal execution of the controller method. Since you're overriding that function, the exception isn't being thrown, and your controller method carries on its jolly way.

Instead of returning with back(), I think you could probably throw a custom exception, and then catch it within the App\Exceptions\Handler class. Within there you could return redirect()->back(), which should stop the execution of the controller code.

Feb
06
2 weeks ago
Activity icon

Awarded Best Reply on SQLSTATE[23000]: Integrity Constraint Violation: 1048

@wallyj Well, the error is straight-forward and clear, the contact2homephone column within the table must not be set to allow nullables. Perhaps you're using the wrong database, or you haven't ran a migration to update the table schema?

Try running DESCRIBE contacts and see if the table definition shows contact2homephone as being set to allow nulls?

Activity icon

Replied to SQLSTATE[23000]: Integrity Constraint Violation: 1048

@wallyj Well, the error is straight-forward and clear, the contact2homephone column within the table must not be set to allow nullables. Perhaps you're using the wrong database, or you haven't ran a migration to update the table schema?

Try running DESCRIBE contacts and see if the table definition shows contact2homephone as being set to allow nulls?

Activity icon

Replied to FormRequest Cusomize Action For Failed Authorization

@bwrigley I just tested this myself - and you're correct. If you return false from the authorize() method, and then override the failedAuthorization method in the way you did, it will continue to execute the controller method. I think this is because the framework would usually throw an AuthorizationException (403) which would prevent the normal execution of the controller method. Since you're overriding that function, the exception isn't being thrown, and your controller method carries on its jolly way.

Instead of returning with back(), I think you could probably throw a custom exception, and then catch it within the App\Exceptions\Handler class. Within there you could return redirect()->back(), which should stop the execution of the controller code.

Activity icon

Replied to Attach Method Does Nothing In Observer

@juancruzmartino Do you have your relationship defined correctly? publishers should be defined on your Work model as a belongsToMany relationship

Open tinker and try \App\Work::first()->roles() and make sure it returns a BelongsToMany instance.

Jan
28
3 weeks ago
Activity icon

Replied to Validation Return Nothing When Send Large Text In P Ost Request

@techyad

Then specify required within the validation rules:

'title'=> 'required|string|max:10'  // or min:10, as discussed