bestmomo

Experience

354,370

402 Best Reply Awards

  • Member Since 3 Years Ago
  • 19 Lessons Completed
  • 0 Favorites

24th September, 2018

bestmomo left a reply on Query With Count And GroupBy • 1 day ago

If you use Eloquent just do that :

$regios = App\Regio::withCount('inscricoes')->get();

bestmomo left a reply on Difference Between !== & != • 1 day ago

From manual :

$a !== $b Not identical TRUE if $a is not equal to $b, or they are not of the same type.

23rd September, 2018

bestmomo left a reply on Property [id] Does Not Exist On This Collection Instance!!!! • 2 days ago

Let's show some code. Maybe you try to get attribute on collection without iterate...

bestmomo left a reply on Photos Gallery • 2 days ago

bestmomo started a new conversation Photos Gallery • 2 days ago

For information I put on Github an example of a photo gallery.

It serves as the basis for a series of French turoriels on my blog.

17th September, 2018

bestmomo left a reply on Load Js Dependecy In My Bootstrap.js • 1 week ago

Luckily there is something else that bootstrap and jquery :)

bestmomo started a new conversation Bug In Mix ? • 1 week ago

Say in my resources/js/app.js I add a require for sweetalert :

window._ = require('lodash');
window.Popper = require('popper.js').default;
window.swal = require('sweetalert2');

So I launch npm run dev. My sweetalert is not loaded. But now if i change a bit :

window._ = require('lodash');
window.swal = require('sweetalert2');
window.Popper = require('popper.js').default;

It works !

I have tried with other libraries with same result...

Any idea ?

Thanks

11th September, 2018

bestmomo left a reply on Delete File From Dir With Unlink • 2 weeks ago

@tykus

Even the core doesn't use the FileSystem ^^

In UpCommand Console command :

@unlink(storage_path('framework/down'));

bestmomo left a reply on Eloquent Get Insert Id • 2 weeks ago

When you create a record with Eloquent you get the id in the model :

$flight = App\Flight::create(['name' => 'Flight 10']);
$id = $flight->id;

bestmomo left a reply on Route With Names Issue • 2 weeks ago

When you use get you get a collection of elements and you must iterate, if you have only one element use first or firstOrFail.

10th September, 2018

bestmomo left a reply on Helper Function • 2 weeks ago

Happy it works now ;)

bestmomo left a reply on [SOLVED]Requests Not Validating Contact Form • 2 weeks ago

I suppose you use flash package, I never used it but did you installed it correctely ?

bestmomo left a reply on [SOLVED]Requests Not Validating Contact Form • 2 weeks ago

Looks like I got the good answer above ^^

bestmomo left a reply on Helper Function • 2 weeks ago

Do you use some contact variable on this page ?

bestmomo left a reply on Requests Not Validating Contact Form • 2 weeks ago

Remove this line in ContactFormRequest :

use Illuminate\Foundation\Http\FormRequest;
//use App\Http\Controllers\ContactFormRequest;
use App\Mail\ContactEmail;
use Flash;

bestmomo left a reply on Helper Function • 2 weeks ago

With this code you cant get Undefined variable contact...

bestmomo left a reply on Helper Function • 2 weeks ago

Do you really use this code :

<?php

if (!function_exists ('sections')) {
    function sections()
    {
        return \App\Models\Section::all();
    }
}

if (!function_exists ('site_data')) {
    function site_data()
    {
        return \App\Models\SiteData::first();
    }
}

if (!function_exists ('social')) {
    function social()
    {
        return \App\Models\Social::first();
    }
}

if (!function_exists ('contact')) {
    function contact()
    {
        return \App\Models\Contact::first();
    }
}

bestmomo left a reply on Helper Function • 2 weeks ago

Remove these lines :

namespace App\Http;
class helpers
{

It's not a class just a php file with functions

bestmomo left a reply on Helper Function • 2 weeks ago

Dont forget namespaces :

<?php

if (!function_exists ('sections')) {
    function sections()
    {
        return \App\Models\Section::all();
    }
}

if (!function_exists ('site_data')) {
    function site_data()
    {
        return \App\Models\SiteData::first();
    }
}

if (!function_exists ('social')) {
    function social()
    {
        return \App\Models\Social::first();
    }
}

if (!function_exists ('contact')) {
    function contact()
    {
        return \App\Models\Contact::first();
    }
}

bestmomo left a reply on Helper Function • 2 weeks ago

Why not simple like that :

if (!function_exists ('sections')) {
    function sections()
    {
        return \App\Models\Section::all();
    }
}
...

bestmomo left a reply on Helper Function • 2 weeks ago

I have updated my answer.

bestmomo left a reply on How To Access Public Path Image • 2 weeks ago

$output = '
        <td><img height="50" src="' . url("/imageslogo-1.png") . '" alt="Image"/></td>
  '

bestmomo left a reply on Helper Function • 2 weeks ago

The simple way is to create an app/helper.php file for all your helper functions and load it with composer :

"autoload": {
    "classmap": [
        "database/seeds",
        "database/factories"
    ],
    "files": [
        "app/helpers.php"
    ],
    "psr-4": {
        "App\": "app/"
    }
},

In your helper file you set your helper methods, for example :

<?php

if (!function_exists ('currentRoute')) {
    function currentRoute(...$routes)
    {
        foreach ($routes as $route) {
            if (request ()->url () == $route) {
                return ' active';
            }
        }
    }
}

bestmomo left a reply on Helper Function • 2 weeks ago

Why do you extend Controller to make an helper ?

bestmomo left a reply on Get Google Places • 2 weeks ago

bestmomo left a reply on How To Access Public Path Image • 2 weeks ago

I dont understand how you manage your code. Why dont you use Blade for this ?

8th September, 2018

bestmomo left a reply on Laravel 5.7 Email Confirmation • 2 weeks ago

Now I've got it ;)

bestmomo left a reply on Laravel 5.7 Email Confirmation • 2 weeks ago

@staudenmeir

Right, I made copy and paste to have link and got &amp; , thanks ;)

7th September, 2018

bestmomo left a reply on Laravel 5.7 Email Confirmation • 2 weeks ago

Yes I did all that is said in doc : implements MustVerifyEmail in User and 'verify' => true in routes.

bestmomo started a new conversation Laravel 5.7 Email Confirmation • 2 weeks ago

Hello,

Just testing Laravel 5.7 today and set the email confirmation on a fresh installation. I get the email, click on link and only get a 403 page.

Looks like hasValidSignature used by ValidateSignature return false but I dont know why...

Any idea ?

bestmomo left a reply on How To Turn Off Auto Login Users ? In Laravel 5.7 • 2 weeks ago

Hello

Override register function that showed you @OriOn in your RegisterController.

30th August, 2018

bestmomo left a reply on Database Realtionships • 3 weeks ago

Hello,

I think you should have a look at documentation, starting there.

23rd August, 2018

bestmomo left a reply on WithTrashed • 1 month ago

Do you use the Illuminate\Database\Eloquent\SoftDeletes trait ?

22nd August, 2018

bestmomo left a reply on Call To A Member Function Where() On Null • 1 month ago

There is something not logical...

When you write :

History::find('item_id')

You get only 1 row... what about the where ?

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

You can only do that with raw query as said @36864 . Look at MySQL documentation.

bestmomo left a reply on Image Upload With Original Name In Laravel 5.6 • 1 month ago

When you say "in database" do you mean in users table ? Because you dont use getClientOriginalName on it...

bestmomo left a reply on Icons & Animations • 1 month ago

FontAwesome 5.2 is great and worth upgrading with nice SVG.

bestmomo left a reply on Blog Website • 1 month ago

Sometimes an example is also good.

17th August, 2018

bestmomo left a reply on Display A Video On Forum • 1 month ago

@jlrdw

I'm not really easy with english so I rather spend time on french forums. I forgot that paginator ^^.

bestmomo left a reply on Display A Video On Forum • 1 month ago

You may try pcloud.com

bestmomo left a reply on Best Way To Process $request Data From Data Submitted On Form With Foreach Loop Table • 1 month ago

Hello,

Looks like you need a cartesian product with arrays (like there : https://stackoverflow.com/questions/6311779/finding-cartesian-product-with-php-associative-arrays).

Another way is to use collections with crossJoin.

bestmomo left a reply on Use Same Request In Web Route And API Route With Different Controllers But Get Same Result In Non Validate Requests • 1 month ago

From documentation :

If the validation rules pass, your code will keep executing normally; however, if validation fails, an exception will be thrown and the proper error response will automatically be sent back to the user. In the case of a traditional HTTP request, a redirect response will be generated, while a JSON response will be sent for AJAX requests.

6th March, 2018

bestmomo left a reply on RefreshDatabase Trait • 6 months ago

Ok, thanks to answer ;)

bestmomo left a reply on RefreshDatabase Trait • 6 months ago

abstract class TestCase extends BaseTestCase
{
    use CreatesApplication, RefreshDatabase;

    /**
     * Authentification.
     *
     * @return void
     */
    protected function auth($id) 
    {
        $user = User::find($id);

        $this->actingAs($user);
    }
}

bestmomo started a new conversation RefreshDatabase Trait • 6 months ago

Hello,

I use RefreshDatabase trait in Testcase.php but this doesn't work, not hit on trait and no database refresh.

I use this in phpunit.xml :

<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>

This was working on a previous project but not my new one, I use Laravel 5.6.

17th February, 2018

bestmomo left a reply on Eloquent Relation To Get Many To Many Items • 7 months ago

Hello,

You can get that with whereHas :

$blogs =  Blog::whereHas('tags', function ($q) use ($tag) {
     $q->where('tags.tag', $tag);
})->get();

bestmomo left a reply on How To Get Url From Database ? • 7 months ago

Hello,

You can use parse_url : http://php.net/manual/en/function.parse-url.php

18th January, 2018

bestmomo left a reply on Upgrade Laravel Version • 8 months ago

The best way for upgrades is to start with a fresh install and copy all custom files and partial codes. It's longer but so cleaner !

Edit Your Profile
Update

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