macmotp

macmotp

Member Since 4 Years Ago

Singapore

Electronic Engineer at Aspire Technologies

Experience Points 28,345
Experience Level 6

1,655 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 513
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.

24 Sep
1 year ago

macmotp started a new conversation Components Do Not Render Updated Mixin Data?

I have a global mixin used by several components. The mixin has an incremental number as data (a sort of global total number) and I want to show it into the other components. And this works perfectly, until I increment the "global" number but the components do not render the updated value.

This is a simplified version of the mixin:

export default {
        data() {
            return {
                number: 1
            }
        }
        methods: {
            increment() {
                this.number++;
            }
        }
    }

And this is a component using the mixin:

<template>
     <div>{{number}}</div>
</template>

<script>

    export default {

    data: {
            // it just shows the number
        },

    };
</script>

Let's say I render the component the first time: it will shows 1. Perfect. Than I call the increment method (from elsewhere): behind the scenes the number will be incremented to 2, but the component does not show 2, it is still fixed on 1.

Why does it not change, since it is bound as it shows 0 the first time?

11 Sep
1 year ago

macmotp left a reply on Optional Sass Import

Thank you @vanderb for the answer. That would work but it doesn't help my case. I will be more specific: I have a Sass project with variables and other files depending on those variables:

// project/main.sass

@import variables.sass
// other files based on variables
// project/variables.sass
$example-color: #fff

But since it will be published through npm, I want that Laravel users could import the whole library - like for Bootstrap if you create a new Laravel project:

// /resources/sass/app.scss

@import ../node_modules/project/main.sass

This will work, but I want them to update the variables without extracting the whole library, so my goal is:

// project/main.sass

@import variables

// HERE IS WHAT I NEED:
@import (optional) ../../resources/sass/override.sass

// other files based on variables
// project/variables.sass
$example-color: #fff

And for user Laravel projects:

// /resources/sass/app.scss

@import ../node_modules/project/project.sass
@import override.sass
// /resources/sass/override.sass
$example-color: #000

In this way, users can override variables without braking anything on the library. I hope this can clarify

macmotp started a new conversation Optional Sass Import

I recently had to import optional files in SASS. Apparently there is no way to do it like so:

@import optional_file !optional

or like in LESS

@import (optional) optional_file 

There is an issue on GitHub [here] (https://github.com/sass/sass/issues/779 ) but it has not being solved, and maybe it will never be.

Do you know if there is a workaround, preferably not using js or webpack?

Thank you

17 Nov
2 years ago

macmotp left a reply on Stream Socket Enable Crypto Error Laravel

I'm having the same problem here, using smtp.gmail.com in my config.mail file.

I found a workaround:

  1. Search for the vendor lib file \vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\StreamBuffer.php

  2. Search the method private function _establishSocketConnection()

  3. Paste (after $option declaration) $options['ssl']['verify_peer'] = FALSE; $options['ssl']['verify_peer_name'] = FALSE;

Now it works but it cannot be a good solution since you are editing a vendor file.

22 Jul
3 years ago

macmotp left a reply on L5 Creating API With Pagination - Issue

@thawheinthit I had this issue while L5 was still in beta. Anyway it totally works now: in your controller just add ->all() method after your collection when passing to the transformCollection function:


public function index(LessonTransformer $lessonTransformer)
 {
    $limit = Input::get('limit', 10);

    $lessons = Lesson::paginate($limit);

    return $this->respond([
   'lessons' => $lessonTransformer->transformCollection($lessons->all())
    ]);
 }

12 Feb
4 years ago

macmotp started a new conversation [L4.2] Caching Api Responses

Hello everyone,

I'm wondering if it is possible to cache the Json responses from my API, but I have absolutely no clue about it.

I need it because my database entries are hundred of thousands of lines and they could not be paginated.

Can anyone give me some hint please?

27 Nov
4 years ago

macmotp left a reply on Larabook Ch 27 - Functional Test SignUpCept Fatal Error

I found this error too. Trying to use Illuminate\Contracts\Mail\MailQueue and send an email with the queue function and it throws me a Maximum function nesting level exception. But if I use Illuminate\Contracts\Mail\Mailer everything works perfectly. I am using L5 and the error appears both in Homestead and in my local environment...

24 Nov
4 years ago

macmotp left a reply on [L5] Sessions Don't Persist

I found a solution for Middleware + Sessions: hope this may help somebody else.


app('session')->set('my_session', 'here_it_is');

macmotp left a reply on [L5] Sessions Don't Persist

I use Homestead 2.0, and sessions are enabled with "Registered save handlers" = "files user". I tried to use them in a Laravel 4.2 test project and they work perfectly, that's the weird thing.

macmotp left a reply on [L5] Sessions Don't Persist

I tried to use Session::save() but it doesn't work either...

23 Nov
4 years ago

macmotp started a new conversation [L5] Sessions Don't Persist

On my local environment Sessions are not persisting:

In the beginning of my routes I set to var_dump all the sessions and it returns what I'm expecting, as in the example here:


// routes.php use Illuminate\Support\Facades\Session; Session::put( 'trying_a_session' , 'it_doesnt_work' ); var_dump(Session::all());

But if i try to put a session anywhere else (controllers, middleware), it returns NULL. I didn't touch the config sessions.php file, it uses storage files. Does anybody know if this is a L5 issue? Cause I've read that somebody else had the same problem months ago. I never had any troubles about this with L4

21 Nov
4 years ago

macmotp left a reply on [L5] Persists Language And NotHttpFoundException

Thanks @bestmomo for your reply, I think I got the error. It looks like when I am redirecting, it loses the session... In fact I tried to use "return view" instead of "return redirect..." and it totally works!

macmotp left a reply on [L5] Persists Language And NotHttpFoundException

That's true, but I am not able to use App::setLocale(Session::get('lang', Config::get('app.locale'))); as in laravel 4.2 into global.php

macmotp started a new conversation [L5] Persists Language And NotHttpFoundException

Hello everyone,

can you please give me a tip on how to persists a language with Middleware?

This is my code but it doesn't persist the selected language.


class Language implements Middleware { /** * The Locale Language */ protected $lang; protected $availableLanguages = ['en','it']; /** * Create a new filter instance. * * @param $lang * @return \App\Http\Middleware\Language */ public function __construct($lang = 'en') { $this->lang = $lang; } /** * Set the language */ public function detectLang() { app()->setLocale($this->lang); } /** * @param \Illuminate\Http\Request $request * @param callable $next * @return \Illuminate\Http\RedirectResponse */ public function handle($request, Closure $next) { $uri = $request->getRequestUri(); foreach($this->availableLanguages as $language) { if($uri == '/languages/'.$language) { $this->lang = $language; Session::put('lang',$this->lang); $this->detectLang(); return redirect()->back(); } } return redirect()->back(); } }

Also, I saw the new directory structure: how can I use the file Exceptions/Handler.php, for example to catch a NotFoundHttpException? Previously I was using the Kernel.php as this:


try { return parent::handle($request); } catch(NotFoundHttpException $e) { return response()->view('pages.404', [], 404); }
20 Nov
4 years ago
07 Nov
4 years ago

macmotp left a reply on L5 Creating API With Pagination - Issue


class LessonTransformer extends Transformer { /** * @param $lesson * @return array */ public function transform($lesson) { return [ 'title' => $lesson['title'], 'description' => $lesson['description'] ]; } }

macmotp started a new conversation L5 Creating API With Pagination - Issue

I am trying to create an API with Laravel 5 and in order to refresh my memory for a good architecture I followed again the "Incremental APIs" series. Everything worked perfectly until I tried to paginate my results, this is the error I have (I duplicate my code for help using the same situation as Jeffrey did so you will find 'Lessons' and 'title'):

'''ErrorException in LessonTransformer.php line 12: Illegal string offset 'title'

at HandleExceptions->handleError('2', 'Illegal string offset 'title'', '/.../app/Transformers/LessonTransformer.php', '12', array('lessons' => 'http://.../api/v1/lessons/?page=2')) in LessonTransformer.php line 12'''

In my controller:

''' public function index(LessonTransformer $lessonTransformer) { $limit = Input::get('limit', 10);

    $lessons = Lesson::paginate($limit);

    return $this->respond([
        'lessons' => $lessonTransformer->transformCollection($lessons)
    ]);
}

'''

Only difference you can find is that I index the array with 'lessons' and not with 'data'. Also, I repeat, if in my controller I use Lesson::all() it works. it doesn't work the ->all() method though so I simply used ->toArray().

Hope someone can help, I don't know if it is my mistake or not, or if the issue is in L5

04 Nov
4 years ago

macmotp left a reply on Where Are You All From?

Coding while I am floating on my gondola in Venice, Italy

19 Oct
4 years ago

macmotp started a new conversation Coda 2.5 IDE, What Do You Think?

Hello everyone,

I want to ask if anyone has experiences with Coda 2, the IDE created by Panic Inc. Can it be a good alternative in your opinion? I use it for a while for web designing but they released a huge updated just few days ago. Here is the link for those who don't know it: http://panic.com/coda/

15 Oct
4 years ago

macmotp left a reply on Little Margin Issue

Thanks @bashy for the advice. There you go: http://imgur.com/rvUFatM

macmotp started a new conversation Little Margin Issue

I usually watch video on a smaller window (like 1024 px wide) and I found that there is a little issue on the buttons vertical alignment above the video (I would like to post a screenshot but I don't know how to do it). Btw the css of .lesson-meta>li with margin-right: 0.4em should fix it. Sorry for the meaningless post, I am just trying to help :)

25 Sep
4 years ago

macmotp left a reply on Homestead And Subdomains

Thank you @faisal_arbain and @bashy for your reply. When I submit the question I forgot to mention that I had already added the subdomain in the hosts file and used the sub-domain routing. My problem was related to an incorrect configuration of Homestead. Here is the solution:

1) add all the subdomains you need on /etc/hosts:

127.0.0.1 site.app
127.0.0.1 subdomain.site.app

2) map all the subdomains in the file Homestead.yaml pointing to the same root (this was the issue because I needed to run "vagrant provision" and not just "vagrant up"):

sites:
    - map: site.app
      to: /home/vagrant/site/public
    - map: subdomain.site.app
      to: /home/vagrant/site/public

3) use sub-domain routing in Laravel as follow:

$router->group(array('domain' => 'site.app'), function()
{
    get('/', function() {
        return 'main app!';
    });
});

$router->group(array('domain' => 'subdomain.site.app'), function()
{
    get('/', function() {
        return 'subdomain app!';
    });
});

24 Sep
4 years ago

macmotp started a new conversation Homestead And Subdomains

Hello everyone,

I am trying to use subdomains locally with Homestead and VM, but I really cannot find the correct way to implement it.

My target is to use, for example, subdomain.site.app and site.app separately accordantly with my routes.

I tried to setup the file Homestead.yaml with two separates maps but it is not working. I am wondering if anyone had tried this and if it is a nice idea for the purpose of using separate subdomains in a production environment (otherwise please let me know any other options).

Thank you,

Marco