bestmomo

Experience

378,310

450 Best Reply Awards

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

6th March, 2018

bestmomo left a reply on RefreshDatabase Trait • 1 month ago

Ok, thanks to answer ;)

bestmomo left a reply on RefreshDatabase Trait • 1 month 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 • 1 month 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 • 2 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 ? • 2 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 • 3 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 !

17th January, 2018

bestmomo left a reply on Repositories • 3 months ago

Looks weird, check the typo, sometimes there is a hidden stuff...

bestmomo left a reply on Repositories • 3 months ago

Try a composer dumpautoload

16th January, 2018

bestmomo left a reply on Laravel Localization For Long Strings • 3 months ago

Maybe this package can help : https://github.com/Waavi/translation

12th January, 2018

bestmomo left a reply on Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException No Message Error • 3 months ago

Hello,

Are you sure you use good verbs in your forms ?

11th January, 2018

bestmomo left a reply on Get All Artisan Commands • 3 months ago

Thanks,

I tried but it's a long Symfony trip...

bestmomo started a new conversation Get All Artisan Commands • 3 months ago

Hello,

To get all Artisan commands we can use the all inherited from symfony with Àrtisan::all()`. But with this method we dont get the custom packages commands.

Does someone knows a simple way to get them to avoid searching in symfony ? Thanks...

10th January, 2018

bestmomo left a reply on Force Https Laravel 5.5 • 3 months ago

Why not use htaccess ? Something like that :

   RewriteCond %{HTTPS} !=on

   RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

17th November, 2017

bestmomo left a reply on Laravel Remember Me Checkbox Not Working • 5 months ago

From documentation :

If you are using the built-in **LoginController** that is shipped with Laravel, the proper logic to "remember" users is already implemented by the traits used by the controller.

16th November, 2017

bestmomo left a reply on Best Way To Generate Page Titles? • 5 months ago

Another way I use to get some automatism :

I have a config for titles based on routes names :

<?php

return [

    'admin' => 'dashboard',
    'users' => [
        'index' => 'usersGestion',
        'edit' => 'userEdit',
    ],

   ...

And lang files for translations :

<?php

    'titles' => [
        'dashboard' => 'Dashboard',
        'usersGestion' => 'Users Gestion',
        'userEdit' => 'User Edition',
        'contactsGestion' => 'Contacts Gestion',

    ...

Then in a view composer :

$title = config('titles.' . Route::currentRouteName());
$title = __('admin.titles.' . $title);

$view->with(compact('title', '...));

So in layout just set :

{{ $title }}

And it works :)

8th September, 2017

bestmomo left a reply on How Create Nested Relationship Over Three Models • 7 months ago

In your controller something like that :

$treatment = Treatment::with('products')->find($treatment_id)

bestmomo left a reply on How Create Nested Relationship Over Three Models • 7 months ago

So when you edit a treatment you must eager load all the products and you can access the pivot...

bestmomo left a reply on How Create Nested Relationship Over Three Models • 7 months ago

But you edit a treatment that can have many products ?

bestmomo left a reply on [L 5.3] Api Route 405 Method Not Allowed • 7 months ago

Are you sure POST is a correct verb for an API ?

bestmomo left a reply on How Create Nested Relationship Over Three Models • 7 months ago

Sounds weird, as you need same informations for show and edit.

bestmomo left a reply on Adding/Removing Database Columns • 7 months ago

Hi,

Why not simply call the Artisan commande ?

bestmomo left a reply on How Create Nested Relationship Over Three Models • 7 months ago

Not sure of your queries, but looks like in this case it's rather :

$treatment->pivot->units_per_interval

bestmomo left a reply on How Create Nested Relationship Over Three Models • 7 months ago

I dont see the diffrence between show and edit about this attribute.

7th September, 2017

bestmomo left a reply on How Create Nested Relationship Over Three Models • 7 months ago

Why not simply add a column amount in product_preatment pivot (withPivot) ?

bestmomo left a reply on How Create Nested Relationship Over Three Models • 7 months ago

Hi,

I dont understand the difference between Treatments and Prescriptions.

bestmomo left a reply on I Am Unable To Use PHP Math Class In A Laravel Controller • 7 months ago

Just use log10(val).

6th September, 2017

bestmomo left a reply on Localization Set A Locale • 7 months ago

The locale setted with setLocale is only for the current request as any config parameter.

3rd September, 2017

bestmomo left a reply on Eloquent Relation Scopes? • 7 months ago

Hi,

Why not a method in Product model ?

public function firstPhoto()
{
    return $this->belongsToMany('App\Photo')->first();
}

bestmomo left a reply on Posting Without Clicking The Captcha Loses Old Data • 7 months ago

It's a good way to move your memory forward ;)

bestmomo started a new conversation Laravel 5.5 Example • 7 months ago

For information I've posted a new repository with a simple Laravel 5.5 blog example for tutorial with authentication (with email confirmation), roles, articles, tags, search, nested comments, messages, simple localization, administration, medias, multi users files management, application tests...

Hope it may help...

26th May, 2017

bestmomo left a reply on Use And Namespace • 10 months ago

Hello,

Composer generate an array in vendor/composer/autoload_classmap.php. So PHP can find the classes with a use.

15th May, 2017

bestmomo left a reply on [Package] Artisan Commands For Language Strings • 11 months ago

Sorry, I forgot to put the link.

bestmomo started a new conversation [Package] Artisan Commands For Language Strings • 11 months ago

Hello,

When you have all your base strings in your project you have no way to easily get them to create a JSON file for a locale. You have to check all files...

So, as i didn't find a package to help me, I made some artisan commands to automatise that. And now I share them in a package.

Hope it'll be helpfull.

4th May, 2017

bestmomo left a reply on Route Error • 11 months ago

Hello,

Which PHP version do you use ?

bestmomo left a reply on Dusk : Interact With CKEditor • 11 months ago

@dnlcorrea

Nice, it works ;)

bestmomo left a reply on Dusk : Interact With CKEditor • 11 months ago

Thanks I'm going to try your code ;)

19th April, 2017

bestmomo started a new conversation Dusk : Interact With CKEditor • 1 year ago

Hello,

All in title, I cant interact with CKEditor body read or write.

Is someone knows how to do that...

20th March, 2017

bestmomo left a reply on Dusk : Click A Font Awesome Icon • 1 year ago

@alenabdula

Thanks for answer but I tried it and error is :

Facebook\WebDriver\Exception\UnknownServerException: unknown error: Element is not clickable at point (184, 927)

This error is commented there. So I must get a descendant element.

bestmomo started a new conversation Dusk : Click A Font Awesome Icon • 1 year ago

Hi,

I'm struggling with Dusk. I try to $browser->click(...) on a font awesome icon but I cant find a good selector to get it.

My code is classic :

<a id="comment-edit13" href="#" class="editcomment">
    <span class="fa fa-fw fa-pencil fa-lg pull-right" title="Edit comment">
    </span>
</a>

There is creation of a before pseudo-element in span for the icon, so looks like selector must be something like #comment-edit13 span::beforebut I get :

Facebook\WebDriver\Exception\NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"body #comment-edit13 span::before"}

Maybe I miss something...

11th March, 2017

bestmomo left a reply on Installing Laravel • 1 year ago

Hello,

On Windows try Laragon, it's not a virtual machine but it's perfect for Laravel.

27th February, 2017

bestmomo left a reply on Adding A Condition To Authentication - 5.3 • 1 year ago

@iHmD

I think it is implied but you're right ;)

bestmomo left a reply on Creating REST API With More Actions Other Than Usual CRUD. • 1 year ago

@ka.hazem

You just get parameters in your controller :

public function show($frequency, $lead) {
    ...

5th February, 2017

bestmomo left a reply on Laravel Email Authentication Package • 1 year ago

You should have done it a little earlier because I also did one. You have another approach for fresh project. I like it.

bestmomo left a reply on Package For Email Confirmation • 1 year ago

Thanks

bestmomo started a new conversation Package For Email Confirmation • 1 year ago

As I didn't find a good package for email confirmation I made my own, hope it may help other people.

5th January, 2017

bestmomo left a reply on Laravel 5.3 Example • 1 year ago

Not big changes in controllers, just send back a JSON response.

21st December, 2016

bestmomo left a reply on How Do I Create A Custom 404 / Error Page? • 1 year ago

@altafneva

Looks like a server requirements issue. Check this list.

30th November, 2016

bestmomo left a reply on Laravel 5.3 Example • 1 year ago

Thanks, but not sure to understand your question.

25th November, 2016

bestmomo left a reply on Does `get(1)` Do The Same As `first()` Or `take(1)` ? • 1 year ago

What is the error ? With first and take(1) you get a model and with get() you get a collection.

23rd November, 2016

Edit Your Profile
Update

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