Talinon

Talinon

Member Since 3 Years Ago

Toronto

Experience Points
167,030
Total
Experience

2,970 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
880
Lessons
Completed
Best Reply Awards
126
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 34
167,030 XP
Oct
07
1 week ago
Activity icon

Replied to Prevent Running SetUp Method On Some Tests In PHPunit

@untymage No, it will run on every test. This is baked directly into the core of PHPUnit.

I would suggest breaking up your tests into multiple files and only include the setUp() code necessary for the tests within.

Another option would be to exclude the setUp() method from your test file completely. Just create a new method and call it only on the specific tests that require it.

Oct
04
1 week ago
Activity icon

Replied to Get Text Value From Select And Put Value In A Label

This is wrong:

v-bind:value="@{{packhouse.id}}">

When using v-bind, anything within the quotes is an expression. So you'll be causing an error when you're using the curly braces, which would be the cause of your screen to disappear.

This is why I suggested this:

:value="packhouse.id"

FYI: :value is just shorthand for v-bind:value

Oct
03
1 week ago
Activity icon

Replied to Get Text Value From Select And Put Value In A Label

@rvermaak

If I understand correctly, maybe something like this?

    <label>{{ selectLabel }}</label>
    <select v-model="selected">
        <option v-for="packhouse in packhouses" :value="packhouse.id">@{{packhouse.PlantName}}</option>
    </select>

data: {
    selected: 0,
},

computed: {

    selectLabel() {

        if (!this.selected) return 'Make a selection';

return this.packhouses.find(opt => opt.id == this.selected).PlantName;

        }

    },


Activity icon

Replied to How To Merge Multiple Value To $request

@afoysal Yes. Is there some reason you think this wouldn't work?

Activity icon

Replied to Global GetAttribute For All Dates Format

@knubbe82

You could create your own abstract class with your accessor logic.

use Illuminate\Database\Eloquent\Model;

class MyModel extends Model
{

    public function getMyDateAttribute()
    {
        ...
    }
}

Just extend MyModel for any model that you want to have the accessor function.

Your other option would be to create a trait and use it on each appropriate model. This is likely the choice I would make in this situation.

Activity icon

Replied to What To Do With Increasing Use Of Vue

@rsteen A full SPA has undeniably the best user experience. Developing it certainly requires a shift in mindset. Whether or not you will "like it" depends on your willingness to adapt and evolve. Make no mistake, you WILL encounter challenges and frustrations, but like anything, the more you use it, the more natural it will become.

Having said that, not all applications require SPA.. it depends. Some applications warrant the extra work, others it's not all that necessary. Sometimes using inline templates like you describe, pulling in vue for some simple benefits for a specific page might be the way to go. Once you feel comfortable with all the options, you can appropriately make the call.

Activity icon

Replied to How To Return Only Related Models In Relationship With Specific User ?

@mostafalaravel

Just chain on a where condition:

 return \App\Group::with(['users' => function($query) {
        $query->select('name');
    }, 'permissions' => function($query) {
        $query->where('user_id', 211)->select('name');
    }])->get();
Oct
02
2 weeks ago
Activity icon

Replied to Implement Guzzle In Whole Laravel

@pierre4854

Just create a facade and add the alias to your config/app.php

Facade:

namespace App\Facades;

use Illuminate\Support\Facades\Facade;

class Guzzle extends Facade
{
    protected static function getFacadeAccessor()
    {
        return 'guzzle';
    }
}

config/app.php:

    'aliases' => [

    ...
        'Guzzle' => App\Facades\Guzzle::class,
    ...

GuzzleClientServiceProvider:

$this->app->alias('GuzzleHttp\Client', 'guzzle');

Or use this package:

https://github.com/urakozz/laravel-guzzle

Sep
30
2 weeks ago
Activity icon

Replied to From Companies Table Data Fetches Properly But From Company_other_infos Not Fetching Data

@kanchan186

 $CompanyOtherInfo=CompanyOtherInfo::get();

How do you expect this to work? This will return you a collection of every company's "other info"

A quick fix would be:

 $CompanyOtherInfo=CompanyOtherInfo::where('company_id', $company_id)->first();

But - If you are making a lot of joins, why didn't you just include one more to retrieve this too? This way you can avoid the extra unnecessary database query.

Sep
29
2 weeks ago
Activity icon

Replied to Please Could You All Advice Me

I don't pretend to know your life situation, but being single you can probably spare at least an hour a day to set aside for learning. After a year and 360+ hours, you'll have a better understanding on whether or not you'll want to continue with programming as your career choice. As @siangboon mentioned, keep your job and start off with some Laracasts lessons.

Wait until you're married and have children, then you can talk about not having any free time :)

Sep
20
3 weeks ago
Activity icon

Replied to Trying To Get Property 'username' Of Non-object On My Tag Page

So $news->user isn't returning a User model. Do you have a user relationship defined in your News model?

Activity icon

Replied to Trying To Get Property 'username' Of Non-object On My Tag Page

@henryoladj

Pretty hard to help without seeing some code.

Probably something within your blade file for viewing a Post?

Activity icon

Replied to Pass Model By Reference?

@bionary

I'm not exactly sure what you're trying to do, but you would be better off by placing a public method on your Task model.

Task:

protected $errors=[];

public function addError($error) {
    $this->errors[] = $error;
}
public function getBrandsList(Task $task) { 
    $task->addError('Another Error'); 
}
Activity icon

Replied to Adding Helper Files From A Package To A Laravel App

@roni

I see what you're saying. I'm not sure if there is a way of doing that thru composer packages.

You could probably place something like this within your package's service provider:

include_once(__DIR__.'/Helpers.php');

Then define all your global helper functions within that file, wrapping each one in a if function_exists()

I don't see why that wouldn't work.

Activity icon

Replied to Laravel + VUE + SPA

@jasomo

You don't need jQuery if you're going to use vue.

Having said that, they can still co-exist. You can load jquery in your main app.js or bootstrap.js:

window.$ = window.jQuery = require('jquery');
Activity icon

Replied to Adding Helper Files From A Package To A Laravel App

@roni

That is because it's in the laravel/framework's composer.json file

Since the file isn't namespaced it's in the global scope.

https://github.com/laravel/framework/blob/e7b2e534d91c47376af5a089a59fa2c3e1ce61c1/composer.json#L95

Adding the same to your package's composer.json should do the same thing.

Activity icon

Replied to Adding Helper Files From A Package To A Laravel App

@roni I think you'd just need to follow the same steps for your package's composer.json file.

This might be of help: https://laravel-news.com/creating-helpers

I'll point out the importance of using function_exists(), which the link above covers.

Sep
19
3 weeks ago
Activity icon

Replied to Opinions About Using Storage Inside A Controller

@sidirgot

Short answer: it's okay.

Long answer: Most developers strive to keep controllers from getting "fat" with code. Personally, I would likely create a helper class that the controller invokes to handle. I would try my best to name the class to something that describes it's role.

Bottom line - it really doesn't matter; you'll get the same result either way. This all comes down to structure and being consistent with it. If you're working with a team, you all should be on the same page as to what level of extraction is to be expected from everyone contributing to the code base.

Since you're practising TDD, you can confidently refactor away and play around with what works best for you.

Aug
29
1 month ago
Activity icon

Replied to Database Is Always Empty And App('name') Cannot Be Mocked.

I mean what is actually defined within your factory, such as /database/factories/ClientDomainFactory.php

When you create a ClientDomain model, does the host get set to localhost by default?

Otherwise you might need to:

factory(ClientDomain::class)->create([
    'client_id' => $client->id,
    'host' => 'localhost'
]);
Activity icon

Replied to Database Is Always Empty And App('name') Cannot Be Mocked.

@nicolasbuch

The first thing I would look at is your where condition and $this->getHttpHost() If that returns no results, you'll end up with the "Trying to get property 'client' of non-object" error.

What is your ClientDomain factory default setting for host?

Aug
27
1 month ago
Activity icon

Replied to {message: "The POST Method Is Not Supported For This Route. Supported Methods: GET, HEAD.",…}

Do you possibly have a typo mix-up with message and chat?

POST api/message/post App\Http\Controllers\[email protected]

Route::post(' chat/post', '[email protected]');

Activity icon

Replied to {message: "The POST Method Is Not Supported For This Route. Supported Methods: GET, HEAD.",…}

@grahammorbydev

You must have more than 1 route. Your error message even says that GET is a supported method, which means you have a GET route somewhere...

Make sure you haven't cached your routes. Run php artisan route:clear

Activity icon

Replied to {message: "The POST Method Is Not Supported For This Route. Supported Methods: GET, HEAD.",…}

@grahammorbydev

The answer provided by @nakov would be my first guess, too.

Failing that, try running php artisan route:list and make sure that your route is prefixed with api

Activity icon

Replied to Add New Comment Syntax For Blade: ';;' ?

As previously mentioned, its rare you should need to comment in a blade file anyway. If you need to explain logic, that is likely an indication you should be handling that within your controller. Blade files should be as close to template placeholders as possible.

Activity icon

Replied to Add New Comment Syntax For Blade: ';;' ?

@miwal

You would probably be better off by just creating a snippet within your editor.

I don't know what editor you use, but pretty much any half decent one would support such a feature, or an extension/package.

For example, if you use VS Code, you could create a global snippet such as:

    "Blade Comment": {
        "prefix": "cc",
        "body": [
            "{{--  --}}",
            ""
        ],
        "description": "Blade Comment"
    },

The code formatter isn't working properly above.. the line directly below body should read:

"{{-- $1 --}}",

Then if you type cc (or whatever you want) and press tab, it'll insert the blade comment syntax and place your cursor between them where you can proceed immediately with your comment. 3 key strokes, which would be comparable to your 3 keystrokes: ;; plus a space.

https://code.visualstudio.com/docs/editor/userdefinedsnippets

Aug
23
1 month ago
Activity icon

Replied to RoueServiceProvider Not Found When Installing NWidart/laravel-modules On Lumen?

@ahmedqader The lumen support was by a contributor that hasn't kept up with the latest versions. The author of nWidart/laravel-modules himself said he will not support Lumen.

You can see a discussion here:

https://github.com/nWidart/laravel-modules/issues/671

Aug
21
1 month ago
Activity icon

Replied to RoueServiceProvider Not Found When Installing NWidart/laravel-modules On Lumen?

@ahmedqader

Lumen doesn't have a Route Service Provider, and that package doesn't fully support Lumen.

You might be able to find a forked package that supports Lumen.

Aug
20
1 month ago
Activity icon

Replied to Upload Image To Local And Path Recorded In Database

You're welcome! I'm glad that solved your issue.

Activity icon

Replied to Download File From Resources Path

@mindexperiment

I think file is not found because when you fake your storage, your tests will be looking within storage/framework/testing path for the file.

You should create a temporary file within your test that will be stored in the fake storage location.

I usually just use UploadedFile like so:

        UploadedFile::fake()->create('template.ait')->storeAs('prj', 'template.ait', 'local');

At the start of the next time you run your test, the temporary storage will be cleared by the framework.

Activity icon

Replied to Upload Image To Local And Path Recorded In Database

@xitox

I would suggest not to mix the request() helper along with the Request object. Neither is wrong, just pick one and stick with it. In your case, you are assigning your $request variable to the result of the validate() method, which is why you're getting that error.

Instead, just inject the Request object by type-hinting it in your controller's method:

public function store(Request $request)

and then remove the $request assignment and helper call:


$request->validate([
            'captain_id' => 'required',
            'name' => 'required',
            'area' => 'required',
            'qtty_member' => 'required',
            'image' => 'required|image|max:1999'
        ]);

Aug
10
2 months ago
Activity icon

Replied to Override Boot Function When Insert Function Calling In Laravel

@vaibhavsinghal

The problem is that insert() is not a model function; the model is never retrieved so there is no event.

The reason you can use ModelName::insert() is because you end up with an instance of Query Builder due to some magic calls. Since Builder will directly insert into the database, you never have an actual model instance.

You shouldn't need to use insert() unless you're dealing with mass/batch inserts. In that case, you'll have to write your own logic to dispatch your own events.

Activity icon

Replied to Laravel Throttle

@mailnike

I had this problem once dealing with webhooks with a custom ERP integration.

You could create your own middleware group for the webhooks and either exclude the throttle middleware within your app/kernel.php, or increase the number of requestes allowed:

You might just be using an umbrella 'api' middleware group:

'api' => [
    'throttle:240,1'  // allow 240 requests per minute to api group
]

disable all throttling for shopify:

'shopify' => [
    // 'throttle:60,1'
]

You could also add throttling on specific route, or a group of routes:

->middleware('throttle:120,1');


Route::group(['prefix' => 'webhooks', 'middleware' => 'throttle:120,1'], function () {
    Route::get() ....
    Route::get() ....
});



But in the case of applying it to a single route you'd want to make sure the route is not part of a middleware group that has the throttle middleware applied or it would still be in effect for each request. In other words, it won't override it.

As for the cons of completely disabling throttling, your application simply won't rate limit incoming requests.

Aug
09
2 months ago
Activity icon

Replied to Checkbox Value

@hjortur17

You're bouncing all over the place with different questions. I would suggest to just take a step back and soak in some tutorials to help you overcome the confusion. Start with this series to better acquaint yourself with the framework:

https://laracasts.com/series/learn-vue-2-step-by-step

As for your Access-Control-Allow-Origin error, review this video:

https://laracasts.com/series/laravel-vue-and-spas/episodes/7

Activity icon

Replied to Syntax Error, Unexpected '(', Expecting Identifier (T_STRING) Or Variable (T_VARIABLE) Or '{' Or '$'

@andreas94

Looks like you're missing a function call, a where condition perhaps?

if (GDPR::where('id_user', Auth::user())->where('type', '1')->exists())
Activity icon

Replied to Checkbox Value

@hjortur17

It has nothing to do with the number of checkboxes. A million checkboxes would not fix this problem. I don't think you're understanding the security issue we're trying to make you aware of.

Let's say you have a website up and running on the web. I could literally use a command line to send a POST request to your API with whatever data I want. You do NOT want your application to just accept whatever price is given to it from the front-end. Unless of course it's an administrator setting prices, but I don't think that is the issue here.

Instead, you could pass thru an array holding the IDs of the services that the user selected with the checkboxes. Then in your backend, you'd fetch the true selling price from your database.

I have really no idea what your application logic is, but to try to give you a basic idea...

I assume you're using laravel, so something like this:

public function store(Request $request) {  

    // assuming you have already handled validation...

    $items = Item::whereIn('id', $request->services)->get();  // get all items the user selected

    // or maybe something like this:

    $totalPrice = Item::whereIn('id', $request->services)->sum('price');  // get sum of prices of items selected

}
Activity icon

Replied to PHPUnit Returning 404 After First GET Request

@pedroroccon

Awesome, I'm glad that fixed your issue. I remember that being a head scratcher for me, too.

Probably a better way of going about adding multiple route files, opposed to using require within your web,php, is to add your additional route files within the RouteServiceProvider

This blog speaks about it, and it's exactly how I go about doing it:

https://medium.com/@ntimyeboah/how-to-add-a-custom-route-file-in-laravel-93a087c62424

Activity icon

Replied to File Upload Limit Issues

@mattb

Do you have a maximum size rule in the form validation? Perhaps failed validation is causing a redirect and you're not outputting the errors to the page?

Activity icon

Replied to File Upload Limit Issues

@mattb

Yes, within the php.ini file.

No errors? Nothing in the laravel log? What about the web server log?

You could also try bumping the memory_limit a bit higher than the default. To my understanding this shouldn't really affect file uploads because they shouldn't be fully stored in memory, but rather in chunks as it stores to the disk.. but worth trying.

Activity icon

Replied to File Upload Limit Issues

@mattb

Perhaps check your max_input_time and max_execution_time settings. If you are uploading large files, it would stand to reason it would take a longer time.

Activity icon

Replied to PHPUnit Returning 404 After First GET Request

@pedroroccon

Do you have multiple route files?

I remember having a similar problem, and I think it came down to having broken up my web routes into different files. This thread jogged my memory and I'm pretty sure was my problem:

https://laracasts.com/discuss/channels/testing/phpunit-says-route-not-defined

The thread topic says it throws a slightly different error, but that is because of using named routes. The underlying issue would be the same (404 in your case)

Aug
08
2 months ago
Activity icon

Replied to ReflectionException (-1) Class Post Does Not Exist

@romainb

Sorry, I'm not sure why I was thinking PostController - rather, I meant Post.

I've looked over your code several times, and if you have done a composer dump-autoload like you said, there is nothing obvious that I can see that would cause this.

The only thing I can think of, going back to the container, is the possibility you have made a binding for your Post class that tries to resolve to something that can't be found. Like within AppServiceProvider doing something like:

$this->app->bind(\App\Post::class, 'SomethingThatDoesntExist');

That would certainly cause a ReflectionException when Laravel tries to resolve the Route Model Binding on the Edit/Destroy methods.

One way to test it is to fire up tinker and try:

resolve(App\Post::class); - which would return the ReflectionException

new App\Post; - would return a new model instance of Post

If that doesn't shed any light on the problem then I have no idea.. maybe another member can think of something.

Activity icon

Replied to PHPUnit Returning 404 After First GET Request

@pedroroccon

I wonder why it is requesting app/organizacao instead of admin/organizacao?

1) Tests\Feature\OrganizacaoCrudTest::has_create_form()
Symfony\Component\HttpKernel\Exception\NotFoundHttpException: GET http://localhost/app/organizacao

Where is $this->sysPath coming from? That wasn't in your original code snippet.

Activity icon

Replied to ReflectionException (-1) Class Post Does Not Exist

@romainb

Could you post the entire stacktrace?

This is a long shot - but by chance have you bound something into the container that has the same fully qualified namespace as your PostController?

Aug
06
2 months ago
Activity icon

Replied to Checkbox Value

@hjortur17

Using Vue to represent the prices for the front-end is fine.

I also need the value to save to the database

Here is what I'm saying you need to consider:

When you submit the request to your back-end application, are you sending thru the price information to be stored in the database?

If so, what is stopping a user from manipulating the payload to the server? Instead of 50.00, the user submits 1.00

If your application doesn't consider this, it'll just heedlessly accepts whatever is submitted, and it'll persist 1.00 to the database.

What I'm suggesting is having your back-end check for the existence of the checkbox value, and if it's within the payload, then apply the price from your database when it goes to store the transaction. Don't let the front-end dictate what the end price will be.

Activity icon

Replied to Passing Custom Variables To The Mail

@gouseferoz

No, it should not affect your email per se.

Although, Laravel serializes models for a reason. By not serializing, the queued job will only have the information that was available at the time the event was created.. which is fine in some cases.

But, if anything were to change on your models before the job is executed, it won't know about those changes.

Hopefully that makes sense?

Activity icon

Replied to Passing Custom Variables To The Mail

It looks like all you really need as an additional dependency in your Mailable is the Issue model. Just pass both your User and Issue model from your controller:

IssueJob::dispatch($user, $issue)->delay(now()->addSeconds(1));

Then you can delete all those other lines from your controller and reference them from your template (as long as you make the $issue property a public property on your IssuesMail class.

For example:

<h2>Comment: <br> {{ $issue->comment }}</h2> 

It looks like you still might need to retrieve your question information from your Text model, but your Mailable can handle doing that; no need to have that in your controller.

Activity icon

Replied to Passing Custom Variables To The Mail

@gouseferoz

I'm pretty sure what is happening is your User model is being serialized by the SerializesModels trait. In other words, it just stores your user's id in the job queue and then when the job is executed, retrieves a fresh instance from the database; hence why your temporary properties are lost.

Instead of adding temporary properties to your model (which I would argue is bad practice for Eloquent models in most cases) build an array, or another object, and pass that into your event along with your user.

Activity icon

Replied to Passing Custom Variables To The Mail

@gouseferoz

My guess is that it is because you're trying to access your data in the template as an array instead of an object, which is how you set them within your controller.

<h2>Issue: {{ $user->question_issue }}</h2>
Activity icon

Replied to Checkbox Value

@hjortur17

If you're dealing with money, I would suggest handling these prices in the back end. If the request contains the checkbox then apply the price from the database. Otherwise, what is stopping a dishonest user from just sending a post request with whatever price they feel like paying?

Aug
02
2 months ago
Activity icon

Replied to Send Event To Pusher ( Laravel 5.7)

@atfinho

Did you restart your queue workers to update their memory for your application changes?