36864

36864

Member Since 1 Year Ago

Experience Points 61,750
Experience
Level
Lessons Completed 0
Lessons
Completed
Best Reply Awards 88
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.

07 Sep
3 months ago

36864 left a reply on Laravel, JQuery, Bootstrap, Laraval-Mix

Check the generated HTML and look at the order your scripts are being injected.

04 Sep
3 months ago
22 Aug
3 months ago

36864 left a reply on JSON Column - Find Any Matching Value

You could use a raw query:

Model::whereRaw('json_field->"$[*].*" like ?', "%$searchterm%")->get()

36864 left a reply on Laravel Constants

The way I handle something like this is, in my OrderStatus model, I have a few constants for each valid status, and an array of valid statuses, like this:

const STATUS_NEW = 1;
const STATUS_PROCESSING = 2;
const STATUS_CANCELED = 3;
const VALID_STATUSES = [
    STATUS_NEW,
    STATUS_PROCESSING,
    STATUS_CANCELED,
];

And then I use them wherever I like with OrderStatus::STATUS_NEW.

If I want to show a dropdown with all the valid statuses for example, I'll build that in the controller and pass it into the view:

$valid_statuses = OrderStatus::find(OrderStatus::VALID_STATUSES);
return view('foo', compact($valid_statuses));
20 Aug
3 months ago

36864 left a reply on Laravel And Security With .git

To answer your question directly, laravel doesn't handle this in any way.

This is a web server configuration issue and there's nothing you can do within laravel to protect against or make yourself vulnerable to this attack.

36864 left a reply on Dump And Die Can See Variable But I Am Unable To Print It Out

As you can see, some of your objects don't have an author property.

When you dd($update->author->id), execution stops as soon as you print out the first one. If execution doesn't stop, your code will eventually try to access a property that doesn't exist.

You need to either check for the property's existence or use the null-coalescing operator to use a default value, such as {{ $update->author->id ?? 'No Author' }}

36864 left a reply on Laravel 5.7 Is Actually Released Or Just Documentation Is Updated With Version?

5.7 is due to release during LaraconEU.

Documentation always goes up a few weeks prior to new releases so people can prepare for their upgrades.

17 Aug
3 months ago

36864 left a reply on Error On The Boot Method

            $model->addActivity($event); // this is the undefined variable
        });```

You forgot to pass in the $event variable. Change that to this:

static::$event(function($model) use($event) {

                $model->addActivity($event); // this is the undefined variable

            });
10 Aug
4 months ago

36864 left a reply on Query Model Based On Variable Input That Can Be Null?

Sorry, I made an error in my example. This should work though:

 Product::when($color !== 'any', function($query) use($color) {
        return $query->where('color', $color);
    })
    ->(...)
    ->get();
09 Aug
4 months ago

36864 left a reply on Query Model Based On Variable Input That Can Be Null?

You could use a conditional clause to decide whether or not you want to apply a filter: https://laravel.com/docs/5.6/queries#conditional-clauses

So, something like

    Product::when($color !== 'any', function($query, $color) {
        return $query->where('color', $color);
    })
    ->(...)
    ->get()

36864 left a reply on PHP Artisan Migrate Leaves Blank Rule

It's unlikely that swapping mysql for mariadb will solve anything.

Have you tried a fresh laravel install? As in create a new laravel project, run php artisan make:auth, followed by php artisan migrate. If that works, it's likely a problem in your app somewhere. If it doesn't, then look at your infrastructure.

36864 left a reply on PHP Artisan Migrate Leaves Blank Rule

It might be worth a shot. Reinstalling laravel shouldn't take you very long at all, and it's not like you'd be losing your work.

Ping back if it doesn't solve anything.

36864 left a reply on PHP Artisan Migrate Leaves Blank Rule

hmm no output at all is a bit weird, especially with verbosity set to max.

Were there any issues at all when you ran composer install?

For general debugging purposes, could you try running php artisan clear-compiled and composer dumpautoload and trying again?

36864 left a reply on Event Subscribers

Yes, you would still need to create separate events. A subscriber is a replacement for multiple listeners, not for events.

As for queuing, I'm not sure. I think you can, but there's no mention of it in the documentation and I haven't looked into the source for that in a while. If you can, try queuing them and report back with your results.

36864 left a reply on PHP Artisan Migrate Leaves Blank Rule

What's a blank rule? Do you mean an empty line in your console or something else?

Try running php artisan migrate -vvv to run it at maximum verbosity.

Also, check your logs in storage\logs, there might be a clue there.

08 Aug
4 months ago

36864 left a reply on How To Print Province Name Using Province_id In Laravel 5.6

Obviously you need to set the variable before you can dump it out...

36864 left a reply on How To Print Province Name Using Province_id In Laravel 5.6

...what

dd should be dumping the contents of $town and then immediately terminating execution.

Clear your view cache and try again.

36864 left a reply on How To Print Province Name Using Province_id In Laravel 5.6

Or just dd($town_list) in your controller so you can check them all at once

36864 left a reply on Laravel-mix With Toastr Notification (laravel 5.6)

Are you including your app.js file before that script block in your page?

36864 left a reply on How Many Way Exist To Add Custom Classes To Laravel 5.* ?

Still unclear on what you're asking.

What does "add custom classes to laravel" mean to you?

You can use any class you define in your project. Laravel is still just php, so even if you don't do the whole autoload thing you can still just import php files and use whatever classes are defined there.

It would be easier to help if we knew exactly what you're looking for.

36864 left a reply on Hash::check Not Matching Password

That seems to indicate there's no issue with the way the value is stored/retrieved from the database.

That leaves two likely scenarios: You made a typo when first setting the password, or you changed your app's encryption key at some point.

36864 left a reply on Option Value Selecting Using Search Without

You should encapsulate your code with triple backticks ```

Like this: ``` { code } ```

36864 left a reply on Hash::check Not Matching Password

There may be some issue with your database's encoding that's messing with the stored string. You're sure you didn't change your app's encryption key between creating this model and trying to check it, right?

Try this (tinker would make it easier to test):

$master = Master::first(); //or fetch any user, doesn't matter
$master->password = Hash::make('selena123');
$master->save();
$master->refresh();
Hash::check('selena123', $master->password);

If that returns false, there's a problem in the way your app is storing/retrieving the hash string. Try copy/pasting the string as it is in your database and pass it directly to the Hash::check method.

36864 left a reply on Hash::check Not Matching Password

That's expected. Every time you generate a hash, a random salt is generated for it. Did you change your app's encryption key at any point?

Does Hash::check('selena123', Hash::make('selena123')) return true?

07 Aug
4 months ago

36864 left a reply on Private Method Injection In A Trait

Your getRouteKey() calls encodeId() with no parameters, but encodeId requires a parameter to be passed into it.

The example in Optimus' readme file takes advantage of laravel's dependency injection to obtain an Optimus instance in the route action method.

You could have laravel inject optimus into your controller's constructor, and store that optimus instance as a property of the controller. This would then allow you to use that instance in the controller's methods, even if those methods are in a trait.

If you want the trait to be standalone though, you will need to ask the container to resolve an optimus instance for you explicitly.

36864 left a reply on Developing Without A Local VM.

All you need is an installation of php, your database of choice, and a web server such as apache or nginx. I personally use Bitnami's WAMP stack. Pretty much plug-and-play, no issues at all.

06 Aug
4 months ago

36864 left a reply on Private Method Injection In A Trait

We're gonna need some more information to go on.

Post your trait and model code, along with a code sample where you're encountering the error.

36864 left a reply on How To Modify A Trait In A Composer Package.

You can declare a new trait that uses the package's trait and overrides the methods you need:

trait MyRouteWithFakeIds {
        use RouteWithFakeIds;

    /**
     * Get the value of the model's route key.
     *
     * @return mixed
     */
    public function getRouteKey()
    {
        return 'foo';
    }
}

Then just use that trait in your models instead of the package's trait.

03 Aug
4 months ago

36864 left a reply on Production Splash Page

Alternatively, you could put your app in maintenance mode and have the maintenance page be your splash.

36864 left a reply on Laravel 5.6 Register Doesn't Work, No Redirect And No Errors (edited Register Fields)

If you didn't get the data dump, your object probably didn't pass validation.

Dump out the errors variable in your view to make sure you're not missing anything:

@dump($errors)

36864 left a reply on Laravel 5.6 Register Doesn't Work, No Redirect And No Errors (edited Register Fields)

Dump out the data array in the create method to check if you're even hitting it.

protected function create(array $data)
{
    dump($data);
    //rest of your code

36864 left a reply on Laravel 5.6 Register Doesn't Work, No Redirect And No Errors (edited Register Fields)

I'm fairly sure fields are case-sensitive. You're using "Forklift_cert" in your frontend and "forklift_cert" in your backend.

02 Aug
4 months ago

36864 left a reply on Probability Of Same UUID

@abudo at that point you might as well just use the user's id.

31 Jul
4 months ago

36864 left a reply on Why Instead Of Appear A Validation Error Appears "Undefined Variable: SelectedRtypes" Error?

Where did you declare $selectedRtype? In the snippets you've showed us, that variable doesn't exist. Did you mean to use $selectedRtypes instead?

36864 left a reply on Online/offline User Status

I suppose you might be able to use websockets to detect when a connection is terminated and push a notification based on that. I wouldn't know how to do that though.

36864 left a reply on Online/offline User Status

Keep a "last_active_at" timestamp and determine online/offline state based on that. Update that value any time the user interacts with the app, and possibly null it out when the user logs out.

To determine if a user is online, simply check if "last_active_at" is not null and greater than current time - 5 minutes.

You could also add a javascript onunload handler to make an ajax request to the logout route, but that's not entirely reliable.

36864 left a reply on Any Way To Compile The Vendors Folder

Those 10 files would have to contain all the information that's in the 10 separate folders.

You'd get no performance benefits, and only a slightly smaller total package size.

I assume you're uploading the vendor folder to your server instead of using composer to fetch your dependencies after uploading your code. This is generally not a good idea unless your development and production environments are exactly the same, as some packages are platform-specific.

Even then, you'd be better off zipping the vendor folder and unzipping it on the server.

36864 left a reply on OOP Question Related To Good Practices - Who Should Have The Property?

@click again, that would limit the ability to have questions in different orders for different quizzes. You'd basically be able to choose between two orders (ascending or descending), instead of being able to define a specific order for every quiz.

For example, if you have questions A through D, you might want Quiz 1 to go B > C >D >A while Quiz 2 goes D > A > B > C, and maybe Quiz 3 goes B > D > C (omitting A).

36864 left a reply on OOP Question Related To Good Practices - Who Should Have The Property?

That would prevent you from reusing questions in different quizzes unless you want every quiz to have the exact same question order.

36864 left a reply on OOP Question Related To Good Practices - Who Should Have The Property?

The Quiz model should have an ordered list of Questions. Questions do not need to know about other Questions.

36864 left a reply on [L 5.6] Where Condition On JSON Columns

Just a side note, this will also work with a regular where statement if you use DB::raw(). This can come in handy if you want to use user input:

Content::where(DB::raw('JSON_LENGTH(`mycolumn`, \'$."programStages"\')), '=', 0)->pluck('id')    
Content::where(DB::raw('JSON_LENGTH(`mycolumn`, \'$."programStages"\')), '>', 0)->pluck('id')

36864 left a reply on Probability Of Same UUID

Like I said, you'll probably get a few billion uuids before there's a meaningful chance of collision.

Even then, the visible part of the user's uuid would be duplicated, but the actual uuid stored in the database would be unique.

36864 left a reply on Probability Of Same UUID

There's a significantly higher chance of collisions for that scenario.

You're still probably looking at a few biliion UUIDs before you'd expect a collision though.

36864 left a reply on Probability Of Same UUID

From wikipedia:

For example, the number of random version 4 UUIDs which need to be generated in order to have a 50% probability of at least one collision is 2.71 quintillion [...]

This number is equivalent to generating 1 billion UUIDs per second for about 85 years, and a file containing this many UUIDs, at 16 bytes per UUID, would be about 45 exabytes, many times larger than the largest databases currently in existence, which are on the order of hundreds of petabytes.

This is, of course, assuming 128 bits of entropy. You'll probably be fine for anything you do. Maybe throw a jackpot error in case a user manages to generate a collision.

36864 left a reply on In ProviderRepository.php Line 208: Class 'Illuminate\Html\HtmlServiceProvider' Not Found

The gist of it is, all web developers know HTML, but not all developers know laravelcollective/html.

If someone who hasn't used that library catches your project in the future, and they need to make a change to a form, they'll have to spend some time learning the library before they can do anything.

Even something as simple as changing a select from single-choice to multiple-choice, which is trivial to do for anyone with even a basic knowledge of HTML, would take a while to figure out if it's done with this library.

And at some point, you might want to switch out that select input for a searchable text box, which may not be a simple task even in HTML, but would be made harder by the fact that not all larvelcollective input tags take the same parameters.

It's really just adding complexity for no gain. A better effect could be achieved by just adding some snippets to your code editor.

30 Jul
4 months ago

36864 left a reply on Queue:work Is Stopping The Application

Are you locking the database somehow in your jobs?

36864 left a reply on Unable To Connect To Server's Database

Is your config cached? Try clearing it with php artisan config:clear.

36864 left a reply on Error Encoding Model: Malformed UTF-8 Characters, Possibly Incorrectly Encoded

Could you try a couple more things for me please? Tinker would be great for rapidly testing this:

$employee = Employee::select(...)->find(202);
$employee->toArray();
$employee->jsonSerialize();
$employee->toJson();