acacha

acacha

at TORTOSA

TORTOSA

Member Since 3 Years Ago

Experience Points 34,750
Experience
Level
Lessons Completed 424
Lessons
Completed
Best Reply Awards 0
Best Answer
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.

22 May
7 months ago

acacha left a reply on Adding An Admin Template

Laravel 5.6 is compatible. So nothing special to do...

27 Apr
8 months ago

acacha left a reply on Anybody Using Vuetify?

There is a new Laravel Frontend preset for this:

https://github.com/laravel-frontend-presets/laravel-vuetify

Check the demo page here:https://laravel-vuetify.acacha.org/

15 Oct
1 year ago

acacha left a reply on How To Install Permanently Vue Dev-tools In Chrome Used By Laravel Dusk

Oh man yes I know this link! Thanks! What I've asked is how to install permanently because every time you rerun the test de Vue.js devtools dissapears.

14 Oct
1 year ago

acacha started a new conversation How To Install Permanently Vue Dev-tools In Chrome Used By Laravel Dusk

Anyone knows how to install permanenty vue-devtools on Chrome used by Laravel Dusk?

31 Aug
1 year ago

acacha left a reply on How To Disable Headless Mode In Laravel 5.5 (Dusk 2.0)?

I overwrite driver method with:

/**
     * Create the RemoteWebDriver instance.
     *
     * @return \Facebook\WebDriver\Remote\RemoteWebDriver
     */
    protected function driver()
    {
        $options = (new ChromeOptions)->addArguments([
            '--disable-gpu',
            '--headless'
        ]);

        return RemoteWebDriver::create(
            'http://localhost:9515', DesiredCapabilities::chrome()->setCapability(
                ChromeOptions::CAPABILITY, $options
            )
        );
    }

But I only want to disable headless for debugging methods so I wonder if there is any other option like:

php artisan dusk --no-headless or something similar.

acacha started a new conversation How To Disable Headless Mode In Laravel 5.5 (Dusk 2.0)?

Now Laravel 5.5 uses Dusk 2.0 with headless mode active by default. Anybody know how to change this to execute Laravel Dusk tests like before (seeing the browser opening and executing tests)?

24 Feb
1 year ago

acacha started a new conversation A Laravel 5 Package For OAuth Social Login/Register Implementation Using Laravel Socialite And (optionally) AdminLTE Laravel Package

Hey forum users,

I'd like to introduce you a new Laravel package https://github.com/acacha/laravel-social

It use Socialite to configure Social login/register with only a single command.

Thanks!

21 Feb
1 year ago

acacha left a reply on Simple Vue Hot Reload With Laravel 5.4 And Mix

An outside Laravel what? I mean I don't have mix laravel helper outside Laravel...

11 May
2 years ago

acacha started a new conversation Factory Function Or Class Syntax Sugar In Javascript?

I learn about Factory Functions with this video

https://www.youtube.com/watch?v=ImwrezYhw4w"Factory functions video

And I learn about class syntax in https://laracasts.com/series/es6-cliffsnotes/episodes/9

The video recommends to use factory functions instead of classe syntax using this example:


class Dog {
  constructor() {
    this.sound = 'woof'
  }
  talk() {
    console.log(this.sound)
  }
  const sniffles = new Dog()
  sniflees.talk() // ok  outputs: "woof"

 $('button.myButton').click(sniffles.talk)

Last line could not work as expected without Binding:

$('button.myButton').click(sniffles.talk.bind(sniffles))

... if you don't know it or don't remeber about it it could be very difficult to debug...

And I see other people (https://medium.com/javascript-scene/how-to-learn-es6-47d9a1ac2620#.5v6yodpoe | https://vimeo.com/69255635) recommending not to use class syntax. So what is you opinion? Any recommendation?

11 Feb
2 years ago

acacha started a new conversation Speed Up You Laravel Development Workflow Illuminating Packages With Acacha Llum

Form whom it may concern:

I create a lot of new Laravel projects every week with my students in classroom. In most of the projects Laravel debugbar and other packages are a must so we repeat a lot of operations when starting new projects.

So I created a Laravel package for installing this tools with a single command inspired in Laravel spark tool see too at:

https://github.com/acacha/llum

You can:

composer global require acacha/llum
laravel new app
cd app
llum debugbar

or for Laravel Ide helper

llum idehelper

Or

llum devtools

For booth. Also you can:

llum boot

This installs Laravel Debugbar, idehelper, create and configure sqlite database and launch your laravel app in your default browser.

I hope this could be useful for somebody!

19 Jan
2 years ago

acacha started a new conversation Ubuntu Dnsmasq Wildcard *.app To 192.168.10.10 And 127.0.0.1 Do .dev

It's easy in Ubuntu because dnsmasq-base is installed by default so create file:

 $ sudo editor /etc/NetworkManager/dnsmasq.d/laravel_homestead.conf

Add the following lines:

# General sites (Apache)
address=/.dev/127.0.0.1

# Laravel Homestead (Vagrant)
address=/.app/192.168.10.10

Dnsmasq have to be killed because this:

$ ps aux | grep dnsmasq

Take note of dnsmasq PID and execute:

$ sudo kill -9 PID_DNSMASQ

Then restart network-manager:

$ sudo service network-manager restart

Now wilcards are activated:

$ ping whatever.app

resolves to 192.168.10.10 and:

 $ ping whatever.dev

resolves to 127.0.0.1

29 Dec
3 years ago

acacha left a reply on How To Set UP? PHPStorm(latest) + Homestead PHP7+ Xdebug

More info:

https://github.com/laravel/framework/issues/11594

Xdebug is by design removed from Laravel Homestead so it seems we have folks to install by hand.

acacha left a reply on How To Set UP? PHPStorm(latest) + Homestead PHP7+ Xdebug

sudo pecl install xdebug

Does not work

acacha left a reply on How To Set UP? PHPStorm(latest) + Homestead PHP7+ Xdebug

Same problem here no xdebug on Homestead 4.0

28 Dec
3 years ago

acacha left a reply on How To Modify Config Folder File

Lazy artisan it seems to me a really good tool/idea and I think something similar would be very useful at Laravel by default!

acacha left a reply on How To Modify Config Folder File

@ohffs thanks for your comments! I understand and agree with you concerns about modifing config files. I will check lazy-artisan.

I also found:

https://github.com/rtablada/package-installer/blob/master/src/Rtablada/PackageInstaller/PackageInstaller.php

Actually what I was looking for is a easy way to modify PHP config files to help me automate some tasks.

acacha left a reply on How To Modify Config Folder File

@ohffs @deringer let me expose and example I think it could be useful to "dinamically/programatically" modify config file:

Command line execution something like artisan custom commands.

For example I'm tired every time I've to install a new laravel service provider from a package, everytime we do the same adding a provider to providers array i config/app file. Imagine how could would be:

$ php artisan provider:add "\App\MyProvider"

So anyone now have a recommendation of hot to easily modify Laravel config files programatically?

24 Dec
3 years ago

acacha left a reply on Demo App

Task Scheduling in Laravel: https://laravel.com/docs/master/scheduling

03 Dec
3 years ago
25 Nov
3 years ago

acacha started a new conversation Check For Existence Of On Delete Cascade Before Massive Deleting?

Hi,

Is there any way to check if a table have a foreign key restriction with ON DELETE CASCADE? I'm trying to delete programatically all relations but if first I could check for existence of on delete cascade I could avoid the massive delete.

22 Nov
3 years ago

acacha left a reply on Vue: Using Templates From External File

Finally I used Browserify with partialify to require external files like css o js using node.js style (using require). See example at:

https://github.com/vuejs/vue-browserify-example

I prefer using a folder for each component than vueify aproach (an unique file for every component). Partialify give me more flexibility structuring my components and having css, js, html mixed in one file it's a bit confusing for editors like PHPStorm.

30 Oct
3 years ago
29 Oct
3 years ago

acacha started a new conversation Vue: Using Templates From External File

I doesn't achive to work using a template as a external file with:

Is that possible?

18 Oct
3 years ago

acacha left a reply on Step By Step Guide To Installing Socket.io And Broadcasting Events With Laravel 5.1

For whom It may concern and Step By Step tutorial (sorry in catalan!) at:

http://acacha.org/mediawiki/Laravel_Broadcasting_Events#Redis

Using Supervisor to ensure server execution.

08 Oct
3 years ago

acacha left a reply on Laravel 5.1 - Bootstrap Template

For whom it may concern with:

https://github.com/acacha/adminlte-laravel

A Laravel 5 package that switchs default Laravel scaffolding/boilerplate to AdminLTE template you can revocer the previous Scaffolding in Laravel with Bootstrap and AdminLTE template!

07 Oct
3 years ago

acacha left a reply on Middleware To Show Custom Error Pages

So I propose:

<?php

namespace PrivacyDriver\Exceptions;

use Exception;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

class Handler extends ExceptionHandler
{
    /**
     * A list of the exception types that should not be reported.
     *
     * @var array
     */
    protected $dontReport = [
        HttpException::class,
    ];

    /**
     * Report or log an exception.
     *
     * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
     *
     * @param  \Exception  $e
     * @return void
     */
    public function report(Exception $e)
    {
        return parent::report($e);
    }

    /**
     * Render an exception into an HTTP response.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Exception  $e
     * @return \Illuminate\Http\Response
     */
    public function render($request, Exception $e)
    {
        if ( env('APP_WHOOPS', false) ) {
            //WHOOPS is ACTIVE
            if ($e instanceof ModelNotFoundException) {
                $e = new NotFoundHttpException($e->getMessage(), $e);
            }

            if ($this->isHttpException($e)) {
                return $this->toIlluminateResponse($this->renderHttpException($e), $e);
            } else {
                if (config('app.debug'))
                {
                    return $this->renderExceptionWithWhoops($e);
                }
            }
        } else {
            //WHOOPS NOT ACTIVE => Same as before adding Whoops
            if ($e instanceof ModelNotFoundException) {
                $e = new NotFoundHttpException($e->getMessage(), $e);
            }
        }
        return parent::render($request, $e);
    }

    /**
     * Render an exception using Whoops.
     *
     * @param  \Exception $e
     * @return \Illuminate\Http\Response
     */
    protected function renderExceptionWithWhoops(Exception $e)
    {
        $whoops = new \Whoops\Run;
        $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler());

        return new \Illuminate\Http\Response(
            $whoops->handleException($e),
            method_exists($e,'getStatusCode') ? $e->getStatusCode() : 200 ,
            method_exists($e,'getHeaders') ? $e->getHeaders() : array()
        );
    }
}

Base on current version of Handler Laravel file:

https://github.com/laravel/laravel/blob/master/app/Exceptions/Handler.php

acacha left a reply on Middleware To Show Custom Error Pages

Lines:

$e->getStatusCode(),
$e->getHeaders()

can be buggy is exception doesn't have this methods for example BadMethodCallException. This type of exceptions could be throwed at Tests or using CLI

26 Sep
3 years ago

acacha started a new conversation How To Improve Laravel Views Performance When Using Multiple Times Same View File Or Howto Avoid Repeating Expensive Read File Operation

First of all I'm not asking about alternative ways of how to achieve the same result for example code proposed. I know there is better ways to do that.

The example code provided below is only for forcing Laravel to read multiple times the same view file (resources/views/hello.blade.php)

The example code:

Route::get('/testperformance3', function () {

    $faker = Faker\Factory::create();

    $ouput  = "";

    for ($i = 1; $i <= 5000; $i++) {
        $test = View::make('hello',["name" => $faker->firstName])->render();

        $ouput = $ouput . $test;
    }

    echo $ouput;
});

Where hello view is:

<div> Hello {{ $name }}</div>

The performance of this code is not very good because Laravel is executing multiple times and include operation for evaluating blade compiled view as you can see on evaluatePath method in PhpEngine.php file (https://github.com/illuminate/view/blob/master/Engines/PhpEngine.php)

protected function evaluatePath($__path, $__data)
    {
        $obLevel = ob_get_level();

        ob_start();

        extract($__data);

        // We'll evaluate the contents of the view inside a try/catch block so we can
        // flush out any stray output that might get out before an error occurs or
        // an exception is thrown. This prevents any partial views from leaking.
        try {
            include $__path;
        } catch (Exception $e) {
            $this->handleViewException($e, $obLevel);
        } catch (Throwable $e) {
            $this->handleViewException(new FatalThrowableError($e), $obLevel);
        }

        return ltrim(ob_get_clean());
    }

In my example case $data passed to view is changing every loop iteration (so I can't cache/save view result at first time). The expensive operation is at line:

 include $__path;

But in this example the path is the same over all loop iterations.

The question: Any idea how to improve Laravel to avoid repeating the same include operation again an again maybe caching the result when path is the same.

For whow it may concern I'm trying to improve Sleeping Owl admin performance because it's a case where a lot of view operation are made with the same view file when retrieving lists of items. Tou can see more infor at discuss:

https://laracasts.com/discuss/channels/laravel/how-to-improve-performance-when-calling-same-view-multiple-times

19 Sep
3 years ago

acacha left a reply on Testing A 403 Response Status After Submiting A Form In Laravel 5.1

Ok I found a possible solution:


try {
            $this->actingAs($user)
                ->withSession(['applocalemodel' => 'ca'])
                ->visit('/admin/regulations/create')
                ->type('Norma de prova no funcionarà', 'name')
                ->press('Guardar');
        } catch (\Exception $e) {
            $this->assertContains ("Received status code [403]",$e->getMessage());
        }

acacha left a reply on Testing A 403 Response Status After Submiting A Form In Laravel 5.1

Sorry I've tried that before and is not working:

There was 1 failure:

1) AuthorizationTest::testAuthorizationOnModels
A request to [http://privacydriver.app/admin/regulations] failed. Received status code [403].

/home/vagrant/Code/GlobalsDD/PrivacyDriver/vendor/laravel/framework/src/Illuminate/Foundation/Testing/CrawlerTrait.php:259
/home/vagrant/Code/GlobalsDD/PrivacyDriver/vendor/laravel/framework/src/Illuminate/Foundation/Testing/CrawlerTrait.php:177
/home/vagrant/Code/GlobalsDD/PrivacyDriver/vendor/laravel/framework/src/Illuminate/Foundation/Testing/CrawlerTrait.php:199
/home/vagrant/Code/GlobalsDD/PrivacyDriver/vendor/laravel/framework/src/Illuminate/Foundation/Testing/CrawlerTrait.php:941
/home/vagrant/Code/GlobalsDD/PrivacyDriver/vendor/laravel/framework/src/Illuminate/Foundation/Testing/CrawlerTrait.php:928
/home/vagrant/Code/GlobalsDD/PrivacyDriver/tests/AuthorizationTest.php:43
/home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:148
/home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:100

Caused by
exception 'Symfony\Component\HttpKernel\Exception\HttpException' in /home/vagrant/Code/GlobalsDD/PrivacyDriver/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:882
Stack trace:
#0 /home/vagrant/Code/GlobalsDD/PrivacyDriver/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(21): Illuminate\Foundation\Application->abort(403, '', Array)
#1 /home/vagrant/Code/GlobalsDD/PrivacyDriver/app/Providers/AuthServiceProvider.php(445): abort(403)
#2 [internal function]: PrivacyDriver\Providers\AuthServiceProvider->PrivacyDriver\Providers\{closure}(Object(PrivacyDriver\Models\Regulation\Regulation))
18 Sep
3 years ago

acacha started a new conversation Testing A 403 Response Status After Submiting A Form In Laravel 5.1

I'm stucked how can I test I expect a response code status of 403 (because my app control user permisions on creating model regulation in example and returns a 403 if user is not allowed to create a regulation):

$this->actingAs($user)
            ->withSession(['applocalemodel' => 'ca'])
            ->visit('/admin/regulations/create')
            ->type('Norma de prova no funcionarà', 'name')
            ->press('Guardar')
            ->?????????????();

What I've to put on ??????????? to test a response code of 403?

acacha left a reply on Using Facades From Variable

Thanks! You read my mind I already have done it!

17 Sep
3 years ago

acacha left a reply on Using Facades From Variable

Of course! Thank you that's resolve the problem!

acacha started a new conversation Using Facades From Variable

I don't know if this is possible:

foreach (["Regulation","RegulationBox"] as $value) {
            $value::saving(function($model)
            {
                if (Gate::denies('create', $model)) {
                    abort(403);
                }
            });
        }
'''

Previous code doesn't works (Regulation class not exists error has been thowed). What I'm trying to do is to register multiple save model events for multiple models (in the example two Eloquent Models Regulation and RegulationBox).


16 Sep
3 years ago

acacha left a reply on How To Improve Performance When Calling Same View Multiple Times

I write and Issue to Sleeping Owl:

https://github.com/sleeping-owl/admin/issues/237

but if I found a solution will try to make a PR.

My example is in a private github repo. But Sleeping Own code is:

https://github.com/sleeping-owl/admin-lte-template/blob/master/src/views/default/display/datatables.blade.php

This is the main view for datatables display. As you can see

@foreach ($collection as $instance)
                <tr>
                    @foreach ($columns as $column)
                        <?php
                            $column->setInstance($instance);
                        ?>
                        {!! $column !!}
                    @endforeach
                </tr>
            @endforeach

With that if you have 100 rows an 10 columns 1000 loops are executed on code line:

{!! $column !!}

Not every column is the same type and different dinamic values applies for same type columns. If columns if of type String:

https://github.com/sleeping-owl/admin/blob/development/src/SleepingOwl/Admin/Columns/Column/String.php

This line of code executes the code:

/**
     * @return string
     */
    function __toString()
    {
        return (string)$this->render();
    }

at parent String class:

https://github.com/sleeping-owl/admin/blob/development/src/SleepingOwl/Admin/Columns/Column/BaseColumn.php

And render is calling make:view:

/**
     * @return View
     */
    public function render()
    {
        $params = [
            'value'  => $this->getValue($this->instance, $this->name()),
            'append' => $this->append(),
        ];
        return view(AdminTemplate::view('column.string'), $params);
    }

see https://github.com/sleeping-owl/admin/blob/development/src/SleepingOwl/Admin/Columns/Column/String.php

where column.string is a simple view:

<td>{{ $value }} {!! $append !!}</td>

acacha left a reply on How To Improve Performance When Calling Same View Multiple Times

I answer to myself. I know is a stupid example but I've implemented and tested using Laravel cache. For reference may could help somebody:

'''php

Route::get('/testperformance', function () {

$ouputString  = "";

$test = Cache::get("hello_view",null);

for ($i = 1; $i <= 10000; $i++) {
    if ($test == null) {
        $test = View::make('hello')->render();
        Cache::add("hello_view",$test, 10);
    }

    $ouputString = $ouputString . $test;
}

echo $ouputString;

}); '''

This executes really fast.

acacha left a reply on How To Improve Performance When Calling Same View Multiple Times

@jekinney Forgetting Laravel for a moment if you did this I'd expect it to be 10s alone from 10,000 calls.

I tested your example and you are Right. Is not a a problem in make:view. There are to many I/O read file operations (moreover my example is running in homestead a virtual machine with and additional penalty in I/O operations)

@jekinney So the issue is why is it calling the same views over and over. That seems to be a bug in the Sleeping Owl to me.

I agree with you the only possible improvement is hacking Sleeping Owl to avoid repeating same operation again and again.

Thanks!

acacha left a reply on How To Improve Performance When Calling Same View Multiple Times

@ phildawson did you try my example /testperformance ? The views have only a div with any dynamic data and when I tried with 5000 loops execution time is 4.86s ans with 10000 it tooks 9.6s. It seems a lot of time for me.

With Sleeping Owl using datatables display with 322 with 11 rows it tooks at least (322x11=3542) actually a more with headers ans other views (in my case exactly 3698 views). In this case it tooks (20 seconds with debugbar enabled and 9.7 seconds without still a lot). In any case performance is becoming linear worse with number of rows. I also use with() method and Eager Loading reducing the number of queries to a reasonably number (14 queries)

I never use before a cache system. Could you give me and example how to cache the "toy example" I propose?

acacha left a reply on How To Improve Performance When Calling Same View Multiple Times

NOTE: I know I can put View::make('hello')->render() outside the loop and call it only once. The example is a toy example but when I use some libraries like https://github.com/sleeping-owl/admin sometimes a lot of views are called so is interesting knowing in any alternative way.

acacha started a new conversation How To Improve Performance When Calling Same View Multiple Times

Imagine a code like:

Route::get('/testperformance', function () {

    $ouputString  = "";
    for ($i = 1; $i <= 10000; $i++) {
        $ouputString = $ouputString . View::make('hello')->render();
    }

    echo $ouputString;
});

You can test how performance is linear affected by incrementing loop size (for example using 20000 tooks double time to execute page http://myapp.app//testperformance ).

The question is: any way to increment performance in this case?

I think the problem is time spent in I/O disk operations reading the view file. Taking into account is always the same field it could not be cached in any way?

30 Jul
3 years ago

acacha left a reply on Laravel 5.1 Scaffold?

Maybe someone could find interesting laravel:

https://github.com/acacha/adminlte-laravel

How to "reinstall" scaffold and also changing it to admin-lte is explained at README.md

25 May
3 years ago

acacha left a reply on Which Laravel Admin Panel Should I Use?

Maybe AdminLTE could be a good starter point for you:

https://almsaeedstudio.com/

And you could be interested in:

https://github.com/acacha/adminlte-laravel

A Laravel 5 package that switch default Laravel scaffolding/boilerplate to AdminLTE template

acacha started a new conversation Tool For Automation Of Package Installation

Hi all,

I've been searching for a tool to automate Laravel Packages installation avoiding to manually editing config/app.php file every time I install a Laravel package with composer.

I've found

https://github.com/terion-name/package-installer

but It doesn't seems to work an las commit is from August 2014 (maybe not supporting Laravel 5?)

Any recommendation?

Thanks,