Talinon

Talinon

Member Since 4 Years Ago

Toronto

Experience Points
211,770
Total
Experience

3,230 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
1025
Lessons
Completed
Best Reply Awards
173
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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 43
211,770 XP
Apr
04
1 day ago
Activity icon

Awarded Best Reply on Testing Laravel HTTPNOTFOUND Exception On Second Pass

Do you have multiple route files?

Check out this thread, sounds like it could very well be your issue:

https://stackoverflow.com/questions/23418150/unable-to-run-multiple-controller-tests-in-laravel

Apr
01
4 days ago
Activity icon

Awarded Best Reply on How To Not Loop The Same Data In Foreach ?

@fareedr

Assuming you're using a collection, just use the unique() method

https://laravel.com/docs/6.x/collections#method-unique

Activity icon

Replied to How To Not Loop The Same Data In Foreach ?

@fareedr

Assuming you're using a collection, just use the unique() method

https://laravel.com/docs/6.x/collections#method-unique

Mar
27
1 week ago
Activity icon

Awarded Best Reply on General Error: 1 No Such Table: Main.id (SQL: Insert Into "sessions"...)

@tills98 Your problem is within your migration:

$table->foreign('journey_id')->references('journeys')->on('id');

Should be:

$table->foreign('journey_id')->references('id')->on('journeys');
Mar
26
1 week ago
Activity icon

Replied to General Error: 1 No Such Table: Main.id (SQL: Insert Into "sessions"...)

@tills98 Your problem is within your migration:

$table->foreign('journey_id')->references('journeys')->on('id');

Should be:

$table->foreign('journey_id')->references('id')->on('journeys');
Mar
10
3 weeks ago
Activity icon

Awarded Best Reply on PHPUnit Segmentation Fault On AWS Elastic Beanstalk Deployment (exit Status 139)

@fylzero I'd start off with runing phpunit with --debug to isolate the test method that is causing it, and then review from there.

Activity icon

Replied to The GET Method Is Not Supported For This Route. Supported Methods: POST

@henryoladj Can you not connect and login to the server via ssh?

Activity icon

Replied to PHPUnit Segmentation Fault On AWS Elastic Beanstalk Deployment (exit Status 139)

@fylzero I'd start off with runing phpunit with --debug to isolate the test method that is causing it, and then review from there.

Activity icon

Replied to The GET Method Is Not Supported For This Route. Supported Methods: POST

@henryoladj Perhaps you have your routes cached? Try clearing it: php artisan route:clear

Mar
07
4 weeks ago
Activity icon

Replied to WhereBetween Gives Null In Laravel Even When Data Exist !

@princeoo7

Have you tried removing the other where clauses to rule out any interference?

Document::select(['id', 'title', 'type', 'valid_to', 'notification_status', 'user_id', 'status_id'])
            ->with(['owner'])
//            ->whereNotificationStatus(Status::On)
//            ->whereStatusId(Status::Active)
            ->whereBetween('valid_to', [$from, $to])
            ->get();
Feb
27
1 month ago
Activity icon

Awarded Best Reply on 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

Feb
26
1 month ago
Activity icon

Awarded Best Reply on Why Horizon Save Failed Jobs To Redis?

@kingshark Running php artisan queue:retry all would only push failed jobs within the mysql database back on the queue, so that is expected behaviour.

When you retry a failed job within Horizon, a new job is created. If the new job fails, another new entry should be added to your mysql failed jobs database, but Horizon doesn't delete the original failed job. Now, if you go and push failed jobs back onto the queue from your mysql database using artisan, and they succeed, they'll be removed from the mysql database but not Horizon/Redis (at least I'm pretty sure that is how it works)

So maybe it's just a matter of confusion resulting from pushing jobs with artisan, yet still seeing failed jobs within horizon?

Activity icon

Replied to Why Horizon Save Failed Jobs To Redis?

@kingshark Running php artisan queue:retry all would only push failed jobs within the mysql database back on the queue, so that is expected behaviour.

When you retry a failed job within Horizon, a new job is created. If the new job fails, another new entry should be added to your mysql failed jobs database, but Horizon doesn't delete the original failed job. Now, if you go and push failed jobs back onto the queue from your mysql database using artisan, and they succeed, they'll be removed from the mysql database but not Horizon/Redis (at least I'm pretty sure that is how it works)

So maybe it's just a matter of confusion resulting from pushing jobs with artisan, yet still seeing failed jobs within horizon?

Activity icon

Replied to How To Display Exception Error Msg ?

You're welcome.

Feb
25
1 month ago
Activity icon

Replied to Why Horizon Save Failed Jobs To Redis?

@kingshark It is normal for horizon to store failed job keys, as it uses them to populate the dashboards. You can find their settings for how long Horizon keeps failed data in the config/horizon.php file (if you have it published)

It seems like the main problem is they're not being stored to your mysql table.

I'm not sure why they wouldn't be storing in the database. Are you certain you're checking the right database? (this happens more often than you'd think)

Activity icon

Replied to It Is Necessary To Initialize The Public,protected Variable Inside The Constructor?

@benitto_raj No, it's not necessary, they would default to public. It's a good habit to get into the practice of doing though. It's much easier to look at the top of a class and see all its explicitly defined properties rather than searching thru all the methods.

Usually, you want to avoid using public properties whenever possible. Having public properties means they can be mutated from anywhere in your app (outside the class) and that is generally considered a bad thing.

Activity icon

Replied to Why Horizon Save Failed Jobs To Redis?

@kingshark Do you actually have a period at the end of your environment value, or is that just a typo?

Make sure you don't have your configuration cached.

Run php artisan config:clear

Activity icon

Replied to How To Display Exception Error Msg ?

@somenet77

You are right - you are catching the error. Once you catch the error, you are returning a JsonResponse to your controller:

return response()->json([
                'message' => sprintf('No query result is found with id %d', $id),
                'code' => $e->getCode()
            ]);

Your controller then passes it to CategoryResource where it harfs on your JsonResponse because it's not a model it's expecting.

There are lots of ways to go about correcting this. One quick way would be to check what the repository returns and handle it conditionally within your controller:

 public function show($id)
    {
        $category = $this->category->show($id);

    if ($category instanceof \Illuminate\Http\JsonResponse)
        return $category;  // returns your custom response


    // otherwise pass it on to the JsonResource
        return (new CategoryResource($category))
            ->response()
            ->setStatusCode(Response::HTTP_OK);
    }

My suggestion would be not to return a JsonResponse from your repository. Either return a model or null. Let your controller decide what response to provide.

Activity icon

Awarded Best Reply on Url Validation Including Prefill Http(s)//

@mbo I don't see an issue with just having a select element that forces them to select either http or https. It's easy enough to do string manipulation in the backend to prefix the url with the selection.

Activity icon

Replied to How To Display Exception Error Msg ?

@somenet77 It looks like you need to examine what the find() method on the CategoryContract class is returning. It appears when it does not find an existing resource, it is returning a JsonResponse which does not have a getMedia() method.

public function show($id)
    {
        return $this->categoryContract->find($id);   // <-- is returning JsonResponse when not found
    }

If you're using Eloquent within your CategoryContract, you can catch the ModelNotFoundException within exceptions/handler.php and return a custom json response.

Activity icon

Replied to Url Validation Including Prefill Http(s)//

@mbo I don't see an issue with just having a select element that forces them to select either http or https. It's easy enough to do string manipulation in the backend to prefix the url with the selection.

Feb
24
1 month ago
Activity icon

Replied to How To Seed The Prod Database ?

@mostafalaravel You can use Seeders and execute them via Artisan commands, but you will need to specify the --force flag to run in production (which is a good thing, its a safety mechanism)

or you can use database dumps and import them.. I've used this approach many times.

Activity icon

Replied to The Results Of A Failed Request

@lavina Not sure why you are trying to reinvent the wheel when Laravel comes with user registration out of the box.

But anyway... that is expected behavour for form validation; the Request object protects your controller logic. When the user gets redirected back to the form, you will have access to an error MessageBag. This is what you can use to display your errors within the view.

You can read more about it here:

https://laravel.com/docs/master/validation#working-with-error-messages

Feb
21
1 month 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
1 month 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
1 month 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
1 month 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
1 month 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 month 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