Talinon

Experience

64,470

37 Best Reply Awards

  • Member Since 2 Years Ago
  • 419 Lessons Completed
  • 0 Favorites

4th June, 2018

Talinon left a reply on Validating JSON API Request With Laravel 5.6 • 2 weeks ago

The problem is with your validation rule array. Try this:


$validator = Validator::make($request->json()->all(), [
            'code' => 'required',
            'description' => 'required',
        ]);

31st May, 2018

Talinon left a reply on Favorite Testing Methodology? • 2 weeks ago

@jlrdw Even though interesting, your link is regarding NASA Test Pilots :)

Talinon left a reply on How To Enable Dusk Test, Open Chrome To View The Whole Process • 2 weeks ago

I think you just need to remove the --headless option from the driver() method within DuskTestCase.php:

protected function driver()
    {
        $options = (new ChromeOptions)->addArguments([
            '--disable-gpu',
//            '--headless'
        ]);

        return RemoteWebDriver::create(
            'http://localhost:9515', DesiredCapabilities::chrome()->setCapability(
                ChromeOptions::CAPABILITY, $options
            )
        );
    }

Talinon left a reply on Validating Array Of Input Fields Not Working In Firefox. Chrome Okay • 2 weeks ago

looks like you're missing an equals sign:

<form method="post" action="{{ route('file.store') }}" enctype='multipart/form-data' files="true">

17th April, 2018

Talinon left a reply on How To Change ISO_8601 In UTC To Mysql Timestamp • 2 months ago

I'm not exactly sure what you're trying to do.. Is it important that the actual data within the database is in ISO_8601 format, or do you just need it converted for application logic?

If you are just looking for a way of working with the timestamp within your application, you might want to look into Carbon (it's included with Laravel)

https://carbon.nesbot.com/docs/

To take it a step further, if you wish to always have a Carbon instance of your my_date field, you can create a Model accessor within your User model:

public function getMyDateAttribute($value)
{
    return \Carbon\Carbon::parse($value);
}

This way whenever you try to access $user->my_date you will get a Carbon instance of your date/timestamp, and you can do whatever you wish with it.

13th April, 2018

Talinon left a reply on How To Create An Array Only Generate Certain Rows In A Table • 2 months ago

$roles = Role::pluck('role_name', 'id')->except(['role_1', 'role_2']);

Talinon left a reply on How To Group Multiple Fields Under Validator->sometimes Validation? • 2 months ago

Recently I had something similar to this with several sometimes validations. I couldn't think of any practical way to improve upon it other than just refactoring them to their own methods to try to keep it as organized and descriptive as possible.

Talinon left a reply on Laravel 5.2 -> Laravel 5.6 Framework Upgrade • 2 months ago

Yeah, one step/version at a time. I would make a new branch for each version and just make my way through the change log and test everything.

I upgraded at a pace of one version per week. I'd apply the changes over a weekend, and pray on Monday morning that everything went well. If everything was smooth by mid week, I'd start a new branch and work on the next version.

FYI - laravelcollective/html was removed from the main laravel package, but you can still pull it in through composer to use with any version. I'm still using it with 5.5 without any problems.

Talinon left a reply on Laravel 5.2 -> Laravel 5.6 Framework Upgrade • 2 months ago

I also maintain a corporate intranet that includes mega applications such as CRM, Project Management, POs, among others. I upgraded from 5.2 to 5.5 last year, and it went relatively smooth. I just started off with the upgrade notes for 5.3, and made my way through all the changes. I would run 5.3 on production for a week or so to make sure everything was stable, and then proceed with the next version.

I found upgrading from 5.2 to 5.3 to be the most intensive, the other jumps to newer versions were completely painless.

If by chance you have 100% test coverage, this gives you much more confidence to make the upgrades. IMO, the upgrade was definitely worth it, but that is a decision you need to make on your own.

Talinon left a reply on PHP-Laravel UnitTesting • 2 months ago

Might be worth mentioning that your second post/assertion will only execute if your first assertion passes.

Talinon left a reply on Wildcard In Middleware • 2 months ago

Talinon left a reply on Wildcard In Middleware • 2 months ago

Why not handle it on the routing level?

Route::group(['middleware' => ['api-middleware'], 'prefix' => 'api'], function() {

    // api routes

});

12th April, 2018

Talinon left a reply on How To Pass One Variable To View • 2 months ago

you could just do:

return view('post.create', compact('id'));

4th April, 2018

Talinon left a reply on Need An Ideal Solution In Queuing Many Many Emails • 2 months ago

Your solution seems fine to me. Your concern about taxing your server with a lot of tasks is exactly why queues exist. Your emails can be queued to be delivered in a controlled and orderly fashion so that other requests to your application are not hindered.

The only thing you may want to consider is the handling of the loop itself. If the scenario you describe is an accurate number of iterations, then you'll be fine.. but if it ends up being something like a million emails, you may want to consider breaking up the loop itself into chunks that also get queued.. but I doubt that will be necessary.

Talinon left a reply on === Operator In Laravel • 2 months ago

It may not necessarily be your code per se, but it could very well lead us to the problem. For instance, where does the data come from that the strict equals operator is used upon? If it's coming from somewhere like a database, it will be driver related, which is what I expect. Probably something is being returned from some driver as a different type than what the driver returns under your xampp environment.

Talinon left a reply on Query By Count Of Relationship Comparison To Parent Field Value • 2 months ago

You should be able to do something like this:


Project::has('users')->with('users')->get()->filter(function ($project) {

    $project_count = $project->users->count();

    return $project->user_count < $project_count;

});

5th March, 2018

Talinon left a reply on Spitting Results • 3 months ago

It is because you are not passing the member data to the view properly.

Try one of these methods instead:

    return view('welcome', compact('member));

or

    return view('welcome')->with(['member' => $member]);

9th February, 2018

Talinon left a reply on Call To Undefined Function Mb_strimwidth() • 4 months ago

See if the module is activated by either `<?php echo phpinfo();' or run the command: 'php -i | grep mbstring'?

Talinon left a reply on Call To Undefined Function Mb_strimwidth() • 4 months ago

It sounds like you don't have the Multibyte String (php-mbstring) PHP extension installed.

Running this command should install it on your server:

sudo apt-get install php-mbstring

Talinon left a reply on Division By Zero • 4 months ago

This likely occurs when $figure_votes has a count of 0, so you end up dividing 0 by 0, which is erroneous.

As @tykus mentioned, this seems a bit much for blade, but a quick fix would be to wrap it in an @if directive:

@if ($figure_votes->count())
     {{ number_format($figure_votes->where('figure_id' ,$data->figure_id)->get()->pluck('figure_vote_id')->count() / $figure_votes->count() * 100, 2) }}% 
@endif

Talinon left a reply on Execute Shell Commands HELP • 4 months ago

Unfortunately, since HTTP is stateless, it's going to need to get a bit more complex. In order to make the output display to the client in real time, you're going to need to implement something like WebSockets. Something like Laravel Echo might help you.

Talinon left a reply on Why ->exists Property Errors Out On Upgrade From 5.3 To 5.5 ? • 4 months ago

Yeah, I just tested this on 5.4 - when I provide a null default for a model, Laravel ignored it and route model bound it anyway. Starting in 5.5, looks like it honours the actual null and doesn't inject a new model instance. I haven't dived into the code to pinpoint it, but this type of behaviour makes sense to me and was likely an intended change.

Talinon left a reply on Why ->exists Property Errors Out On Upgrade From 5.3 To 5.5 ? • 4 months ago

Hmm. Are you sure that you defaulted $channel = null in the method in 5.3 as well?

By having the method parameter defaulted to null, your first route `photolibrary' would definitely result in channel being $null, and the reason for your object error.

Alternatively, if you did NOT have $channel defaulted to null, Laravel would instead method inject a new model instance of Channel, where the $channel->exists property would be available.

8th February, 2018

Talinon left a reply on Execute Shell Commands HELP • 4 months ago

You might want to take a look at Symphony's Process component:

https://symfony.com/doc/current/components/process.html#getting-real-time-process-output

This is already included as a dependency in a Laravel install

Talinon left a reply on Why ->exists Property Errors Out On Upgrade From 5.3 To 5.5 ? • 4 months ago

According to that error, the problem is with your non-object, not the property.. meaning that $channel is likely empty instead of being the expected object.

You say it is taken "more or less" from the tutorials, so I have no idea what is the cause, but your $channel is not being set.

4th February, 2018

Talinon left a reply on PHP Classes And Good Practice Question • 4 months ago

I would go with the second option and make it a class private/protected property. This way, you can reference it anywhere within your class without the need of passing it through method calls.

I'm sure it was just an oversight, but you would also want to call $this->someFunction()

2nd February, 2018

Talinon left a reply on How To Remove This Error?? Please Help • 4 months ago

Check this link, it may be the issue:

https://laravel-news.com/laravel-5-4-key-too-long-error

Talinon left a reply on Taylor Otwell Cancelled My Account Without Asking Me • 4 months ago

It seems to be like you're just on a witch hunt and you're using this forum as your platform to try to bring some form of social justice.

Quite frankly, I think this thread should be cancelled much like your forge account.

31st January, 2018

Talinon left a reply on ┬┐how Can I Select All Partial Views Using View Composer ? • 4 months ago

Yes, that is exactly how you do it. Have you tried it?

26th January, 2018

Talinon left a reply on No Concat Method On Collection • 4 months ago

oh, yeah that very well may be the case. The method didn't exist until 5.4

Talinon left a reply on Route Not Working • 4 months ago

Your {logs} wildcard route is preventing your logs/create route from being reached. Simply move the last route so it's before it:

Route::get('logs/create', '[email protected]');

Route::get('logs/{log}', '[email protected]');

Talinon left a reply on Route Not Working • 4 months ago

Your {logs} wildcard route is preventing your logs/create route from being reached. Simply move the last route so it's before it:

Route::get('logs/create', '[email protected]');

Route::get('logs/{log}', '[email protected]');

Talinon left a reply on No Concat Method On Collection • 4 months ago

The method exists. Let's see some code to figure out what is going on?

24th January, 2018

Talinon left a reply on Formating Date With Carbon In Eloquent Collection • 4 months ago

Check your database - do any rows in the Page table contain null for created_at? This might explain why it works if you dd() because the first record may have date, but a subsequent may be null.

23rd January, 2018

Talinon left a reply on How To Retrieve Multiple Selected Values In A Modal Select Box Using Ajax • 4 months ago

On each iteration of your each loop you are overwriting the value of the select element. Instead, pass an array into the val() method:

Talinon left a reply on How To Retrieve Multiple Selected Values In A Modal Select Box Using Ajax • 4 months ago

The val() method is not going to work in this case.

Try this:

$.each(roles, function(key, role) {

        $('#role_id option[value=' + role.id + ']').attr('selected', true);

})

Talinon left a reply on Laravel 5.4 - Class Not Found In Controller • 4 months ago

You likely haven't namespaced your classes.

Does your ItemCategories class have a namespace at the very top?

<?php

namespace App;

22nd January, 2018

Talinon left a reply on VS Code: Better PHPUnit: Error: Path Must Be A String. Received Null • 4 months ago

When I first started using Code, I had similar issues with that extension. I would recommend trying out the PHPUnit Extended extension. I found it provided more functionality such as: test suite, test file, test nearest, run last, cancel test, etc. With all the choices bound to keyboard shortcuts, it makes for a powerful testing set-up. I found Better PHPUnit to be limited in this regard.

19th January, 2018

Talinon left a reply on SWITCH TO LINUX • 5 months ago

My vote would be for Ubuntu Server

18th January, 2018

Talinon left a reply on Create A User Register On Admin Side • 5 months ago

Of course that is possible, but you're not going to find that functionality out-of-the-box. It should be pretty simple though.. just create a form that is only accessible by admins, and then bind the user account model. No need to logout/login.. Just have a dedicated controller that persists the new account and then redirects back to the admin panel.

Talinon left a reply on Laravel-mix / Webpack == Hell On Earth • 5 months ago

There is nothing forcing you to convert to webpack/mix. If you were comfortable using something like Gulp in 5.2, you can still keep rolling with it. IMO, l it's not worth losing sleep over a module bundler.

I kept Gulp with a 5.2 -> 5.5 migration.. I've just started using Webpack with new projects.

Talinon left a reply on Table Field With _id Saved As Integer When The Field Type Is Varchar • 5 months ago

I am unable to reproduce this..

This works just fine:

$model::create([
    'title' => 'Some Title'
    'ad_account_id' => 7855107227  // varchar(191)
]);


// |  1 | Some Title | 7855107227    | 2018-01-18 17:07:16 | 2018-01-18 17:07:16 |

Do you have a mutator set on your model perhaps? I've tried a simple mutator, and it behaves properly, too.

How are you saving?

Talinon left a reply on Table Field With _id Saved As Integer When The Field Type Is Varchar • 5 months ago

I think placing this on your model might do the trick:

protected $casts = [
    'ad_account_id' => 'string',
];

Talinon left a reply on Export Search Data • 5 months ago

I'm not sure I understand your question?

If you're looking to export your data to a csv, you need to handle this from the controller, not the view.

You can look into this package: https://github.com/Maatwebsite/Laravel-Excel

Talinon left a reply on Checking Eloquent Returns For Correctness • 5 months ago

For this particular scenario, would the findOrFail() or firstOrFail() methods not work?

https://laravel.com/docs/5.5/eloquent#retrieving-single-models

13th January, 2018

Talinon left a reply on Select 2 Not Working After Adding Vue. • 5 months ago

Well, I'm still learning Vue myself, but I think your problem is that you're running your JQuery scripts first, then instantiating Vue, which will overwrite the DOM with its own greediness. If you move the Vue code outside of Jquery ready function, and load it first, it should work.

Using your fiddle:

new Vue({el: '#app'});

$(document).ready(function() {
    $(".asd").select2();
});

I think you still need to be careful at this point with mixing Jquery and Vue safely ... This web resource explains better than I can and goes into detail about how you can make Jquery and Vue play nicely together:

https://vuejsdevelopers.com/2017/05/20/vue-js-safely-jquery-plugin/

12th January, 2018

Talinon left a reply on Dependency Issues When Installing Laravel 5.0 On PHP 5.4.16 • 5 months ago

Right, but there is likely a package that is requiring the dependencies you just listed. Around the start of the error message it should state there is a problem with a package?

Talinon left a reply on Dependency Issues When Installing Laravel 5.0 On PHP 5.4.16 • 5 months ago

What dependencies are causing the errors?

Edit Your Profile
Update

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