macmotp

Electronic Engineer at larastars.com

Hire Me

Experience

24,495

0 Best Reply Awards

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

11th September, 2017

macmotp left a reply on Optional Sass Import • 1 week ago

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 • 1 week ago

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

17th November, 2016

macmotp left a reply on Stream Socket Enable Crypto Error Laravel • 10 months ago

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.

22nd July, 2015

macmotp left a reply on L5 Creating API With Pagination - Issue • 2 years ago

@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())
    ]);
 }

12th February, 2015

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

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?

27th November, 2014

macmotp left a reply on Larabook Ch 27 - Functional Test SignUpCept Fatal Error • 2 years ago

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...

24th November, 2014

macmotp left a reply on [L5] Sessions Don't Persist • 2 years ago

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 • 2 years ago

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 • 2 years ago

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

23rd November, 2014

macmotp started a new conversation [L5] Sessions Don't Persist • 2 years ago

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

21st November, 2014

macmotp left a reply on [L5] Persists Language And NotHttpFoundException • 2 years ago

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 • 2 years ago

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 • 2 years ago

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); }

20th November, 2014

macmotp left a reply on Localization Series • 2 years ago

+1

7th November, 2014

macmotp left a reply on L5 Creating API With Pagination - Issue • 2 years ago


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 • 2 years ago

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

4th November, 2014

macmotp left a reply on Where Are You All From? • 2 years ago

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

19th October, 2014

macmotp started a new conversation Coda 2.5 IDE, What Do You Think? • 2 years ago

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/

15th October, 2014

macmotp left a reply on Little Margin Issue • 2 years ago

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

macmotp started a new conversation Little Margin Issue • 2 years ago

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 :)

25th September, 2014

macmotp left a reply on Homestead And Subdomains • 2 years ago

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!';
    });
});

24th September, 2014

macmotp started a new conversation Homestead And Subdomains • 2 years ago

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

Edit Your Profile
Update

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