trogne

trogne

Member Since 1 Year Ago

Experience Points 6,400
Experience Level 2

3,600 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 35
Lessons
Completed
Best Reply Awards 0
Best Reply
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.

04 Feb
2 months ago

trogne left a reply on Proper Way To Override Vendor Config

If using heroku "MemCachier", we need to change the vendor config file.

So it's not possible with lumen on heroku.

This is the default lumen vendor cache config for memcached :

        'memcached' => [
            'driver' => 'memcached',
            'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
            'sasl' => [
                env('MEMCACHED_USERNAME'),
                env('MEMCACHED_PASSWORD'),
            ],
            'options' => [
                // Memcached::OPT_CONNECT_TIMEOUT  => 2000,
            ],
            'servers' => [
                [
                    'host' => env('MEMCACHED_HOST', '127.0.0.1'),
                    'port' => env('MEMCACHED_PORT', 11211),
                    'weight' => 100,
                ],
            ],
        ],

And this is what we need for MemCachier :

'memcached' => [
    'driver' => 'memcached',
    'persistent_id' => 'memcached_pool_id',
    'sasl' => [
        env('MEMCACHIER_USERNAME'),
        env('MEMCACHIER_PASSWORD'),
    ],
    'options' => [
        // some nicer default options
        // - nicer TCP options
        Memcached::OPT_TCP_NODELAY => TRUE,
        Memcached::OPT_NO_BLOCK => FALSE,
        // - timeouts
        Memcached::OPT_CONNECT_TIMEOUT => 2000,    // ms
        Memcached::OPT_POLL_TIMEOUT => 2000,       // ms
        Memcached::OPT_RECV_TIMEOUT => 750 * 1000, // us
        Memcached::OPT_SEND_TIMEOUT => 750 * 1000, // us
        // - better failover
        Memcached::OPT_DISTRIBUTION => Memcached::DISTRIBUTION_CONSISTENT,
        Memcached::OPT_LIBKETAMA_COMPATIBLE => TRUE,
        Memcached::OPT_RETRY_TIMEOUT => 2,
        Memcached::OPT_SERVER_FAILURE_LIMIT => 1,
        Memcached::OPT_AUTO_EJECT_HOSTS => TRUE,

    ],
    'servers' => array_map(function($s) {
        $parts = explode(":", $s);
        return [
            'host' => $parts[0],
            'port' => $parts[1],
            'weight' => 100,
        ];
      }, explode(",", env('MEMCACHIER_SERVERS', 'localhost:11211')))
],

See https://www.memcachier.com/documentation/laravel

03 Feb
2 months ago

trogne started a new conversation Proper Way To Override Vendor Config

In Lumen, there's no app/config folder.

So, for a heroku site, when deploying, all changes that was made to vendor config folders will be lost.

Say I want "memcached" to be configured.

There's a "cache.php" under "vendor\laravel\lumen-framework\config".

How to I override "cache.php" ?

Will it work if I copy the "cache.php" to a new "config" folder under "app/" ?

trogne left a reply on Heroku Default Cache

oh, ephemeral, I see ! Thanks.

Just tried "CACHE_DATABASE=database" and it works on heroku !

trogne left a reply on Heroku Default Cache

How to use memcached on Lumen ?!?

There's instruction for laravel : https://devcenter.heroku.com/articles/laravel-memcache

But Lumen ?

trogne started a new conversation Heroku Default Cache

Locally I use "CACHE_DRIVER=file", and the cache works fine.

After deploying to heroku, I do get caching, with "Cache::rememberForever" and "Cache::remember".

However I cannot clear the cache.

php artisan cache:clear says "application cache cleared!", but it is not cleared.

Same result whether I us eor not, at heroku, config var "CACHE_DRIVER=file".

What is a simple solution to solve this ?

01 Feb
2 months ago

trogne left a reply on Redirect Post Request To Root, To Index.php

This change works ! :

    # location ~ \.php$ { 
    location ~ \.php$|/$ {

Now I can post to "myproject.local", "myproject.local/index.php", ""myproject.local/someroute"

31 Jan
2 months ago

trogne started a new conversation Redirect Post Request To Root, To Index.php

Because of CORS, I cannot make to root. So I want the request to switch to index.php.

Currently I can make a post request (with cors middelware), to "myproject.local/index.php". But I'd like to remove the "/index.php".

How do I do that ? In .htaccess ? In nginx config ?

Thanks in advance for providing a working example. I'm very confused with .htaccess and nginx conf file.

trogne left a reply on Solution To Axios.post Cors Problem

Unbelievable !

Cors is fully working if I post to something else than the root (/) :

$router->post('/something', '[email protected]');

Any idea on what causing "not allowed" for post request on "/" ?

trogne left a reply on Solution To Axios.post Cors Problem

Interesting test here :

LinkController.php :

    public function testcorsoptions()
    {
        return response('HIT!!!', 200);
    }

TEST 1 : In web.php :

$router->options('/', '[email protected]');

Using Postman :

"OPTIONS" request to http://myproject.local/ :

405 Not Allowed nginx/1.15.5

BUT!!! : TEST 2 :

In web.php :

$router->options('/something', '[email protected]');

Using Postman :

"OPTIONS" request to http://myproject.local/something :

Status 200 OK HIT!!!

So there's something bad about my root "/" !!! What ?

trogne left a reply on Solution To Axios.post Cors Problem

@ARTCORE - But I'm on Lumen, so it's different.

What I tried :

In web.php :

$router->options('/', '[email protected]');
$router->post('/', '[email protected]');

In bootstrap/app.php :

 $app->middleware([
     App\Http\Middleware\Cors::class,
 ]);

"handle" method in middleware not hit

"testcorsoptions" method not hit.

trogne left a reply on Solution To Axios.post Cors Problem

I don't have to set the 2 headers using Axios, because I see them in the post request by default :

Access-Control-Request-Headers access-control-allow-origin,content-type Access-Control-Request-Method POST

trogne left a reply on Solution To Axios.post Cors Problem

"provide Access-..." headers, where ?

With axios ? Or In Lumen ?

Before using "HandleCors" I was using this Middleware (by Alex Garrett) :

class Cors
{
    public function handle($request, Closure $next)
    {
        $headers = [
            'Access-Control-Allow-Origin' => '*',
            'Access-Control-Allow-Methods' => 'HEAD, GET, POST, PUT, PATCH, DELETE, OPTIONS', 
            'Access-Control-Allow-Headers' => 'Content-Type'
        ];
        
        if ($request->getMethod() === 'OPTIONS') {
            return response(null, 200, $headers);
        }

        $response = $next($request); //$response = $next(); //pas besoin du request ici    
        
        foreach ($headers as $key => $value) {
            $response->header($key, $value);
        }
        return $response;
    }
}
30 Jan
2 months ago

trogne started a new conversation Solution To Axios.post Cors Problem

What is a WORKING solution to the axios.post cors problem ?

I have cors setup in Lumen, with a cors middleware.

In my frontend, when I do "axios.post", I get "Not Allowed" for the preflight OPTIONS request.

I've tried Barryvdh\Cors\HandleCors , still not working.

Where's a working solution for this issue ?

29 Jan
2 months ago

trogne started a new conversation Change Vue Init Defaults Settings

When running "vue init", like "vue init webpack procjectname", there are defaults for the author name, project name, etc.

Where can I change those defaults ? I want to change my default name !

Thanks

27 Jan
2 months ago

trogne left a reply on Observer Not Hit

WOW!!! I found how to solve this :

I needed to move "Link::observe" inside a "boot" method in "AppServiceProvider".

    public function boot()
    {
        Link::observe(LinkObserver::class);
    }

Initailly, there was only a "register" method stub in there.

trogne started a new conversation Observer Not Hit

I have an observer, and it's not hit on update.

I even "die" in the "__construct". Even that is not hit.

In "AppServerProvider.php" :

    public function register()
    {
        die('this is hit');
        Link::observe(LinkObserver::class);
    }

The "die" works here. So I comment this line.

But then I add this "die" in LinkObserver :

    public function __construct()
    {
        die('HIT');
    }

In "LinkOberver.php", I have this :

    public function __construct()
    {
        die('HIT');
    }

This "die" is not even hit. Why ?

In LinkController, I have this :

        if (!$link->exists) {
            $link->save();
            //$link->update([  //refactored , moved to model observer
            //    'code' => $link->getCode(),
            //]);
        }

Upon save, the observer created method is not hit.

22 Jan
3 months ago

trogne left a reply on Create A Database With Pgadmin

I added my database name in "homestead.yaml", then provision.

Now database is there.

trogne left a reply on Create A Database With Pgadmin

For user "homestead", I see "create databases" set to "NO" in pgadmin properties.

What is the homestead root user for postgres ?

trogne started a new conversation Create A Database With Pgadmin

I use pgadmin to connect to homestead postgres.

However the option to create a new database is greyed out.

I can I solve this ?

20 Jan
3 months ago

trogne left a reply on Laravel - Vue, No Hot Reload

I'm trying without homestead. Just a local laravel project.

After running "npm run hot", if I go to "http://localhost:8080/js/bundle.js", I see "CANNOT GET".

18 Jan
3 months ago

trogne left a reply on Laravel - Vue, No Hot Reload

Thanks but that did not helped..

What I tried :

Added this to webpack.mix.js :

mix.options({
    hmrOptions: {
        host: 'localhost',
        port: '9000'
    }
}

Added "--port 9000" to package.json :

"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js --port 9000",

Replaced the link in welcome.blade.php :

 <script src="http://localhost:9000/js/app.js"></script>

My project is on my homestead vm, served on "vuexsingleboiler.local"

If I go to "http://localhost:9000/js/app.js", I get "Cannot GET".

Where is the bundled file created by npm run hot ?

15 Jan
3 months ago

trogne started a new conversation Laravel - Vue, Not Hot Reload

Why hot browser reload is not working with a laravel vue installation ?

If install a fresh vue app, the browser refresh on save with npm run dev.

But with the laravel vue installation, the browser does not refresh, either with npm run dev/watch/watch-poll/hot.

14 Jan
3 months ago

trogne left a reply on Laravel And Vue - Popper Error

I've removed the empty "popper.js.map" file and I'm now stuck with the "JSON.parse" error

trogne left a reply on Laravel And Vue - Popper Error

Not really. I want to fix the problem, not replace it with a 404

trogne started a new conversation Laravel And Vue - Popper Error

Only on firefox console (not in chrome), I see this on a new Laravel/Vue project :

Source map error: request failed with status 404 Resource URL: http://vuexsingleboiler.local/js/app.js Source Map URL: popper.js.map

This thread here does not have a working solution : https://laracasts.com/discuss/channels/elixir/laravel-mix-issue-popperjs-dependency-cannot-be-found-by-boostrap-4-beta

09 Jan
3 months ago

trogne started a new conversation Cannot Output Object Property

Why cannot output object property ?

export default {
    note: {title: 'One', body: 'Body one'}
}

I use note in another file.

I can output note as " { "note": { "title": "One", "body": "Body one" } } ".

So why "note.title" is undefined ?

04 Dec
4 months ago

trogne left a reply on Passing Vue.http Post Data

@KOALAMO - Great, thank you @

03 Dec
4 months ago

trogne started a new conversation Passing Vue.http Post Data

I can add data to an http post request, like this :

    Vue.http.post('auth/signup', {
        email: email,
        username: username,
        password: password
   })

On the backend, the $request is a json string.

Before Vue 2, I was able to add the data in a "data" property, like that :

    Vue.http({
        url: 'auth/signup/',
        method: 'POST',
        data: { email: email, username: username, password: password }
})

But that way, the request on the backend is empty.

Is it possible to use the second approach, with "method: 'POST'" ?

18 Nov
5 months ago

trogne left a reply on How To Hit The Api Route

Thank you @cronix, I'll check this out someday. Is it covered on a Laracasts course ?

17 Nov
5 months ago

trogne left a reply on How To Hit The Api Route

| | GET|HEAD | api/user | | Closure | api,auth:api |

trogne left a reply on How To Hit The Api Route

Yes, but hitting "api/user" gives me a 404.

What simple test I can do to this the callback ?

trogne started a new conversation How To Hit The Api Route

In routes, there's a "api.php" file.

How do I hit the callback ?

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});

Where is the "auth:api" middleware defined ?

09 Nov
5 months ago

trogne left a reply on Homestead IP

I see !

trogne started a new conversation Homestead IP

In my homestead guest, my IP is "192.168.10.10".

But on my guest, if I print the user IP, I see "192.168.10.1".

Why not 192.168.10.10 ?

trogne left a reply on How Does The "Route" Facade Object Can Access Methods Like "auth()" And "prefix()" ?

Oh!! The magic method "__callStatic" in Facade.php !

trogne started a new conversation How Does The "Route" Facade Object Can Access Methods Like "auth()" And "prefix()" ?

How does the "Route" facade object can access methods like "auth()" and "prefix()" ?

This works :

Route::auth();

But :

var_dump(get_class(new Route)); //Illuminate\Support\Facades\Route
$reflection = new ReflectionClass(new Route);
var_dump( $reflection->getMethods(ReflectionMethod::IS_STATIC ) );
die();

If I "reflect" on a Route facade object instance, dans dump the static methods, I do not see the "auth" method.

The Route facade extends Facade. If I don't extend, Laravel will try to reach the "prefix" method. Neither "prefix" nore "auth" is defined in Facade.php.

So, how does the "Route" facade object can access methods like "auth()" and "prefix()" ?

25 Aug
7 months ago

trogne left a reply on Blocked From Google Search, And Recaptcha Is Not Showing Up

Sorry for that unusual question.

I was not blocked on other browsers.

Deleting firefox cookies fixed my issue.

24 Aug
7 months ago

trogne started a new conversation Blocked From Google Search, And Recaptcha Is Not Showing Up

blocked from google search, and recaptcha is not showing up

?!?

So sending a question here, to see if this recaptcha will help, and it doesn't.

22 Aug
8 months ago

trogne left a reply on Global Scope Not Working

ok !!! Thread model, I said "withoutGlobalScope('active')" so that I don't read the excluded channels.

But now that my scope is in a class, I have to exclude the class :

return $this->belongsTo(Channel::class)->withoutGlobalScope(\App\Scopes\ChannelScope::class);

trogne left a reply on Global Scope Not Working

I see this in thread model :

    public function channel()
    {
        return $this->belongsTo(Channel::class)->withoutGlobalScope('active');
    }

The inline scope does not work if I remove withoutGlobalScope('active');

?!?

trogne left a reply on Global Scope Not Working

With the class scope, I cannot get the channel attributes inside the blade view.

I can get them if not using a class scope.

trogne started a new conversation Executing The Global Scope Class

My global scope is not executing.

The docs does not mention how to make the global class executing.

I have a Channel model, and I ChannelScope under App/Scopes :

class ChannelScope implements Scope
{
    /**
     * Apply the scope to a given Eloquent query builder.
     *
     * @param  \Illuminate\Database\Eloquent\Builder  $builder
     * @param  \Illuminate\Database\Eloquent\Model  $model
     * @return void
     */
    public function apply(Builder $builder, Model $model)
    {
        $builder->where('archived', false);
    }
}


The docs is totally uncleared as to what to add so that my "apply" method gets hit.

I ran composer dump-autoload.


19 Aug
8 months ago

trogne left a reply on Cannot Access New Folder Under Public

Just this :

Route::post('api/users/{user}/avatar', 'Api\[email protected]')->middleware('auth')->name('avatar');

And disabling this route doesn't give access to "avatars" folder.

This is so weird :

[email protected]:~/Code/council$ ls public/zavatars/
qbirhdaS6j9b9opILiJt0SpY1OXKesNbvVQYYyw4.jpeg
[email protected]:~/Code/council$ ls public/avatars/
ls: cannot access 'public/avatars/': Not a directory

Both directory are created the same way :

mklink /j public\zavatars storage\app\public\avatars
mklink /j public\avatars storage\app\public\avatars

trogne left a reply on Cannot Access New Folder Under Public

I created another junction , fodler "zavatars".

And it works.

It's as if there's a rule for folder "avatars" somewhere... ?!?

trogne left a reply on Cannot Access New Folder Under Public

But it IS a directory : ls public/ -l

drwxrwxrwx 1 vagrant vagrant 0 Aug 19 18:22 avatars

trogne left a reply on Cannot Access New Folder Under Public

The mklink works on another windows/homestead project.

But for my current project it's not working :

ls public/avatars/ ls: cannot access 'public/avatars/': Not a directory

trogne left a reply on Cannot Access New Folder Under Public

Oh, the file is avaible if I create a new dir.

The problem is this :

mklink /j public\avatars storage\app\public\avatars

That way I can't access the files !

How can I make the correct link ?

trogne left a reply on Cannot Access New Folder Under Public

They are readable/writable, same permissions as for the js and css folder.

If I move the image inside the js or css folder, the image is accessible.

Why it's not available if under a new folder ?