36864

Experience

61,750

88 Best Reply Awards

  • Member Since 1 Year Ago
  • 0 Lessons Completed
  • 0 Favorites

7th September, 2018

36864 left a reply on Laravel, JQuery, Bootstrap, Laraval-Mix • 1 month ago

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

4th September, 2018

36864 left a reply on Updating Answer - Mention User • 1 month ago

Testing

22nd August, 2018

36864 left a reply on JSON Column - Find Any Matching Value • 1 month ago

You could use a raw query:

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

36864 left a reply on Laravel Constants • 1 month ago

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));

20th August, 2018

36864 left a reply on Laravel And Security With .git • 2 months ago

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 • 2 months ago

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? • 2 months ago

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.

17th August, 2018

36864 left a reply on Error On The Boot Method • 2 months ago

            $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

            });

10th August, 2018

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

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();

9th August, 2018

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

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 • 2 months ago

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 • 2 months ago

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 • 2 months ago

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 • 2 months ago

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 • 2 months ago

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.

8th August, 2018

36864 left a reply on How To Print Province Name Using Province_id In Laravel 5.6 • 2 months ago

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 • 2 months ago

...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 • 2 months ago

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) • 2 months ago

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.* ? • 2 months ago

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 • 2 months ago

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 • 2 months ago

You should encapsulate your code with triple backticks ```

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

36864 left a reply on Hash::check Not Matching Password • 2 months ago

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 • 2 months ago

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?

7th August, 2018

36864 left a reply on Private Method Injection In A Trait • 2 months ago

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. • 2 months ago

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.

6th August, 2018

36864 left a reply on Private Method Injection In A Trait • 2 months ago

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. • 2 months ago

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.

3rd August, 2018

36864 left a reply on Error: "count(): Parameter Must Be An Array Or An Object That Implements Countable" • 2 months ago

https://laravel.com/docs/5.6/queries#aggregates

$active_posts_count = Post::where('isVisible', 1)->count();

36864 left a reply on Production Splash Page • 2 months ago

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) • 2 months ago

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) • 2 months ago

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) • 2 months ago

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

2nd August, 2018

36864 left a reply on Probability Of Same UUID • 2 months ago

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

31st July, 2018

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

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 • 2 months ago

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 • 2 months ago

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 • 2 months ago

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? • 2 months ago

@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? • 2 months ago

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? • 2 months ago

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 • 2 months ago

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 • 2 months ago

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 • 2 months ago

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 • 2 months ago

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 • 2 months ago

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.

30th July, 2018

36864 left a reply on Queue:work Is Stopping The Application • 2 months ago

Are you locking the database somehow in your jobs?

36864 left a reply on Unable To Connect To Server's Database • 2 months ago

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 • 2 months ago

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();
Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.