KarolGil

KarolGil

Member Since 1 Year Ago

Experience Points
35,470
Total
Experience

4,530 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
327
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    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 Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 8
35,470 XP
Mar
27
1 week ago
Activity icon

Awarded Best Reply on 512 Bytes IE V5+

Check max_input_varsin your server using phpinfo().

Activity icon

Replied to 512 Bytes IE V5+

Check max_input_varsin your server using phpinfo().

Mar
24
2 weeks ago
Activity icon

Awarded Best Reply on Input Request

$request->merge(['lang' => config('global.default_locale')]);
Activity icon

Replied to Input Request

$request->merge(['lang' => config('global.default_locale')]);
Activity icon

Started a new Conversation Input Request

Hi

Is it possible to sign the protected property of an object?

    public function handle($request, Closure $next)
    {
        if ($request->filled('lang')) {
            $tmpRow = TableName::where('locale', '=', $request->input('lang') )->first();
            if ( !$tmpRow ) {
                $request->lang = config('global.default_locale');
            }
        }

        return $next($request);
    }

I mean checking if the 'lang' parameter value is one of the values given in the database, and if not to change the value in the request to the default language of the page. I wanted to do this through midellware that it worked globally, not that I had to overwrite every method on the site.

Mar
23
2 weeks ago
Activity icon

Started a new Conversation JSON

Hi

How can I check globally if a given incoming request is in JSON format?

And if it isn't, convert the request to JSON and pass it on.

json-> json-> next ...
text-> json-> next ...
Mar
20
2 weeks ago
Activity icon

Replied to Visual Math Editor

@rodrigo.pedra Can http://mathdox.org/formulaeditor/ send data to the database freely and read from the database, so that I have formatted mathematical formulas?

http://www.imatheq.com/corpsite/index.html is a good idea, I'm just looking for something cheaper, because there the server license costs $ 19k.

Activity icon

Replied to Visual Math Editor

@tisuchi I was also looking for a plugin from LaTeX, but I haven't found anything that would suit me.

Activity icon

Started a new Conversation Visual Math Editor

Hi,

I am looking for a wysiwyg editor + visual editor for mathematics, apparently like http://www.wiris.com/en/mathtype, only with a license so that users can use it on the site. Can you recommend something?

I want a clickable editor.

Activity icon

Started a new Conversation 512 Bytes IE V5+

Hi

Has anyone encountered such a mistake? Because it cuts off my request, even though it is received from outside using POST.

<!-- IE friendly error message walkround.        
     if error message from server is less than   
     512 bytes IE v5+ will use its own error     
     message instead of the one returned by      
     server.                                 -->

error:

								<td align="center">
											You don't have permission to access
											<STRONG>
                          domain.com/api/simpleSearch?token=...&lang=pl&typeId=2&specializationId=6&points=%5B%7B%22lat%22:%2252.37500682814036%22,%22lng%22:%2221.11587017774582%22%7D,%7B%22lat%22:%2252.372431022637635%22,%22lng%22:%2221.121646650135514%22%7D,%7B%22lat%22:%2252.365712015647915%22,%22lng%22:%2221.13611683249474%22%7D,%7B%22lat%22:%2252.3558926733053%22,%22lng%22:%2221.157335452735424%22%7D,%7B%22lat%22:%2252.343350889915556%22,%22lng%22:%2221.180674694478512%22%7D,%7B%22lat%22:%2252.332302432540594%22,%22lng%22:%2221.199268773198128%22%7D,%7B%22lat%22:%2252.323686969558885%22,%22lng%22:%2221.208430193364617%22%7D,%7B%22lat%22:%2252.31171736550212%22,%22lng%22:%2221.217942647635937%22%7D,%7B%22lat%22:%2252.29684241149753%22,%22lng%22:%2221.225005574524403%22%7D,%7B%22lat%22:%2252.28039228492925%22,%22lng%22:%2221.23498607426882%22%7D,%7B%22lat%22:%2252.26005600830964%22,%22lng%22:%2221.246289908885952%22%7D,%7B%22lat%22:%2252.2362089164092%22,%22lng%22:%2221.254288591444492%22%7D,%7B%22lat%22:%2252.207093435991645%22,%22lng%22:%2221.257329881191254%22%7D,%7B%22lat%22:%2252.
                        </STRONG>
										</td>
Mar
10
4 weeks ago
Activity icon

Started a new Conversation Returning An Error

Hi

Why can Laravel return an error as html instead of as json? And how to fix it?

Mar
07
1 month ago
Activity icon

Awarded Best Reply on Access Denied For User

Thanks for the help.

The problem was in the queue cache.

Solution: php artisan queue:restart

https://laravel.com/docs/5.8/queues#queue-workers-and-deployment

Activity icon

Replied to Access Denied For User

Thanks for the help.

The problem was in the queue cache.

Solution: php artisan queue:restart

https://laravel.com/docs/5.8/queues#queue-workers-and-deployment

Activity icon

Started a new Conversation Laravel Admin Panel

Hi,

What Laravel admin panel do you use and recommend?

Mar
06
1 month ago
Activity icon

Replied to Access Denied For User

@snapey I suspect the queue, but I will be able to check it in a few hours.

Activity icon

Replied to Access Denied For User

@sti3bas Yes, but it still doesn't work. Do you still have any idea?

Activity icon

Replied to Returning An Error In JSON Instead Of 500

@armancodes Could you write me a cover how to choose to look or send a link with a tutorial?

Activity icon

Started a new Conversation Returning An Error In JSON Instead Of 500

Hi,

Can you write general error returns? Ie. that Laravel instead of returning 500 error should be returned in JSON format. Regardless of where in the code the error occurs.

Activity icon

Started a new Conversation Access Denied For User

Hi,

Laravel 5.8

I changed the username in the env file:

from
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=dbname
DB_USERNAME=dbusernameOld
DB_PASSWORD=pass

on
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=dbname
DB_USERNAME=dbusernameNew
DB_PASSWORD=pass

However, in logoch when starting cron I still see the old username and I get the error:

[2020-03-05 00:00:07] local.ERROR: SQLSTATE[HY000] [1045] Access denied for user 'dbusernameOld'@'localhost' (using password: YES) {"exception":"[object] (Doctrine\DBAL\Driver\PDOException(code: 1045): SQLSTATE[HY000] [1045] Access denied for user 'dbusernameOld'@'localhost' (using password: YES) at /path/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:31, PDOException(code: 1045): SQLSTATE[HY000] [1045] Access denied for user 'dbusernameOld'@'localhost' (using password: YES) at /path/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:27)
[stacktrace]
#0 /path/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php(67): Doctrine\DBAL\Driver\PDOConnection->__construct('mysql:host=loca...', 'dbusernameOld', 'password', Array)
#1 /path/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php(46): Illuminate\Database\Connectors\Connector->createPdoConnection('mysql:host=loca...', 'dbusernameOld', 'password', Array)
#2 /path/vendor/laravel/framework/src/Illuminate/Database/Connectors/MySqlConnector.php(24): Illuminate\Database\Connectors\Connector->createConnection('mysql:host=loca...', Array, Array)
#3 /path/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php(182): Illuminate\Database\Connectors\MySqlConnector->connect(Array)
#4 [internal function]: Illuminate\Database\Connectors\ConnectionFactory->Illuminate\Database\Connectors\{closure}()
#5 /path/vendor/laravel/framework/src/Illuminate/Database/Connection.php(919): call_user_func(Object(Closure))
#6 /path/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php(109): Illuminate\Database\Connection->getPdo()
#7 /path/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php(93): Illuminate\Database\Connection->createTransaction()
#8 /path/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php(23): Illuminate\Database\Connection->beginTransaction()
#9 /path/vendor/laravel/framework/src/Illuminate/Queue/DatabaseQueue.php(202): Illuminate\Database\Connection->transaction(Object(Closure))
#10 /path/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(253): Illuminate\Queue\DatabaseQueue->pop('default')
#11 /path/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(107): Illuminate\Queue\Worker->getNextJob(Object(Illuminate\Queue\DatabaseQueue), 'default')
#12 /path/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(102): Illuminate\Queue\Worker->daemon('database', 'default', Object(Illuminate\Queue\WorkerOptions))
#13 /path/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(86): Illuminate\Queue\Console\WorkCommand->runWorker('database', 'default')
#14 [internal function]: Illuminate\Queue\Console\WorkCommand->handle()
#15 /path/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(32): call_user_func_array(Array, Array)
#16 /path/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(90): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#17 /path/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(34): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#18 /path/vendor/laravel/framework/src/Illuminate/Container/Container.php(576): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#19 /path/vendor/laravel/framework/src/Illuminate/Console/Command.php(183): Illuminate\Container\Container->call(Array)
#20 /path/vendor/symfony/console/Command/Command.php(255): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#21 /path/vendor/laravel/framework/src/Illuminate/Console/Command.php(170): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#22 /path/vendor/symfony/console/Application.php(915): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#23 /path/vendor/symfony/console/Application.php(272): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#24 /path/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#25 /path/vendor/laravel/framework/src/Illuminate/Console/Application.php(90): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#26 /path/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(133): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#27 /path/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#28 {main}
"}

Does anyone have an idea why this can be so?

Feb
27
1 month ago
Activity icon

Started a new Conversation Change Default Path To Public Folder.

Hi

I have this directory structure for shared hosting.

/sites/site1
/sites/site2
/sites/site3

in the file:  /public/css/app.css mam taki kod:

src: url(/fonts/vendor/simple-line-icons/Simple-Line-Icons.eot?f33df365d6d0255b586f2920355e94d7);

src: url(/fonts/vendor/simple-line-icons/Simple-Line-Icons.eot?f33df365d6d0255b586f2920355e94d7) format("embedded-opentype"), 
url(/fonts/vendor/simple-line-icons/Simple-Line-Icons.woff2?0cb0b9c589c0624c9c78dd3d83e946f6) format("woff2"), 
url(/fonts/vendor/simple-line-icons/Simple-Line-Icons.ttf?d2285965fe34b05465047401b8595dd0) format("truetype"), 
url(/fonts/vendor/simple-line-icons/Simple-Line-Icons.woff?78f07e2c2a535c26ef21d95e41bd7175) format("woff"), 
url(/fonts/vendor/simple-line-icons/Simple-Line-Icons.svg?2fe2efe63441d830b1acd106c1fe8734) format("svg");
  
I get the error:
http://domain.com/fonts/vendor/simple-line-icons/Simple-Line-Icons.woff2?0cb0b9c589c0624c9c78dd3d83e946f6 net::ERR_ABORTED 404 (Not Found)

How can I change it?: http://domain.com/fonts/... on: http://domain.com/sites/site2/public/fonts/...

I am asking for any suggestion on how to do it without assigning url to path in the css file?

Feb
20
1 month ago
Activity icon

Replied to Laravel Pivot Multiple Table Condition

@sirhxalot

I understand, thank you for your help :)

Feb
19
1 month ago
Activity icon

Replied to Laravel Pivot Multiple Table Condition

@sirhxalot

In this example I also do everything in one query.

Join has such a minus that it cannot be used on models.

Feb
12
1 month ago
Activity icon

Awarded Best Reply on Laravel Pivot Multiple Table Condition

I did it this way.

Just add relationships on the model.

->whereHas('comment', function($query) {
    $query->where('comment.id', '>=',  100);
});

->whereHas('rate', function($query) {
    $query->whereIn('rate.id', [1,2,3]);
});
Activity icon

Replied to Laravel Pivot Multiple Table Condition

I did it this way.

Just add relationships on the model.

->whereHas('comment', function($query) {
    $query->where('comment.id', '>=',  100);
});

->whereHas('rate', function($query) {
    $query->whereIn('rate.id', [1,2,3]);
});
Activity icon

Started a new Conversation Laravel Pivot Multiple Table Condition

Hi,

// I have tables:
post: id, body
comment: id, body
rate: id, name

// Intermediate tables:
post_comment: id, post_id, comment_id
post_rate: id, post_id, rate_id

How can I download posts with comments and ratings for which comment_id> 100 and rate_id in [1,2,3]? Which are taken from intermediate tables (post_comment, post_rate);

Activity icon

Replied to Get Posts With User, Where User

@ahmeddabak @nakov Thank you for your help.

Activity icon

Started a new Conversation Get Posts With User, Where User

Hi

// I have tables:
User: id, name, email, age
Post: id, user_id, body

How to download posts together with the user of a given post. Where User->age is over 18?

Feb
10
1 month ago
Activity icon

Awarded Best Reply on Waavi Translation Get Data From Database

Data from the translator_translations table can be downloaded directly by the function:

trans ('validations.missing_name');

The solution also works:

class WhateverController {
     private $ languageRepository;

     public function __construct (LanguageRepository $ languageRepository) {
         $ this-> languageRepository = $ languageRepository;
     }

     public function give () {
         $ language = $ this-> languageRepository-> findByLocale (1); /* or -> findByLocale ('en'); */
     }
}

Source: https://www.reddit.com/r/laravel/comments/4vt329/nonstatic_method/

Activity icon

Replied to Waavi Translation Get Data From Database

Data from the translator_translations table can be downloaded directly by the function:

trans ('validations.missing_name');

The solution also works:

class WhateverController {
     private $ languageRepository;

     public function __construct (LanguageRepository $ languageRepository) {
         $ this-> languageRepository = $ languageRepository;
     }

     public function give () {
         $ language = $ this-> languageRepository-> findByLocale (1); /* or -> findByLocale ('en'); */
     }
}

Source: https://www.reddit.com/r/laravel/comments/4vt329/nonstatic_method/

Activity icon

Started a new Conversation Waavi Translation Get Data From Database

Hi,

I use Laravel 6.

How to use this package: https://github.com/LearnPHPaz/waavi-translation retrieve data from tables translator_languages and translator_translations from the database.

Feb
03
2 months ago
Activity icon

Replied to Laravel - InvalidArgumentException: Malformed UTF-8 Characters

@sinnbeck Thank you for your help. There were two reasons for this.

Activity icon

Awarded Best Reply on Laravel - InvalidArgumentException: Malformed UTF-8 Characters

        return response()->json([
            'error'=>false,
            'offers'=> $newData
        ], 200, [], JSON_INVALID_UTF8_SUBSTITUTE );

// and

$offer->user->surname = trim( mb_substr ( $offer->user->getOriginal('surname'), 0, 1, 'UTF-8') );
Activity icon

Replied to Laravel - InvalidArgumentException: Malformed UTF-8 Characters

        return response()->json([
            'error'=>false,
            'offers'=> $newData
        ], 200, [], JSON_INVALID_UTF8_SUBSTITUTE );

// and

$offer->user->surname = trim( mb_substr ( $offer->user->getOriginal('surname'), 0, 1, 'UTF-8') );
Activity icon

Replied to Laravel - InvalidArgumentException: Malformed UTF-8 Characters

@sinnbeck Depending on the records and parameters in the query. It works once and once it doesn't.

Activity icon

Started a new Conversation Laravel - Original Data From Model

Hi,

How can I get the original data? Because the attributes change my surname, and I don't know why.

      #attributes: array:5 [
        "id" => 2799
        "name" => "Катерина"
        "surname" => b"Ð"
        "photo" => null
        "photoThumbnail" => null
      ]
      #original: array:3 [
        "id" => 2799
        "name" => "Катерина"
        "surname" => "Середа"
      ]
Activity icon

Replied to Laravel Serialize Response

InvalidArgumentException: Malformed UTF-8 characters, possibly incorrectly encoded in file /var/www/vendor/laravel/framework/src/Illuminate/Http/JsonResponse.php on line 75

#0 /var/www/vendor/symfony/http-foundation/JsonResponse.php(50): Illuminate\Http\JsonResponse->setData(Array)
#1 /var/www/vendor/laravel/framework/src/Illuminate/Http/JsonResponse.php(31): Symfony\Component\HttpFoundation\JsonResponse->__construct(Array, 200, Array)
#2 /var/www/vendor/laravel/framework/src/Illuminate/Routing/ResponseFactory.php(99): Illuminate\Http\JsonResponse->__construct(Array, 200, Array, 0)
#3 /var/www/app/Http/Controllers/ApiController.php(215): Illuminate\Routing\ResponseFactory->json(Array)
#4 [internal function]: App\Http\Controllers\ApiController->simpleSearch(Object(Illuminate\Http\Request))
#5 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)
#6 /var/www/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\Routing\Controller->callAction('simpleSearch', Array)
#7 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Route.php(219): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(App\Http\Controllers\ApiController), 'simpleSearch')
#8 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Route.php(176): Illuminate\Routing\Route->runController()
#9 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php(681): Illuminate\Routing\Route->run()
#10 /var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(130): Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#11 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#12 /var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure))
#13 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(59): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#14 /var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Routing\Middleware\ThrottleRequests->handle(Object(Illuminate\Http\Request), Object(Closure), 60, '1')
#15 /var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(105): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#16 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php(683): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#17 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php(658): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#18 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php(624): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))
#19 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php(613): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#20 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(170): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#21 /var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(130): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#22 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#23 /var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#24 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#25 /var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#26 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#27 /var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closure))
#28 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(62): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#29 /var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#30 /var/www/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#31 /var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Fideloper\Proxy\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure))
#32 /var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(105): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#33 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(145): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#34 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(110): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#35 /var/www/public/index.php(55): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#36 {main}
Activity icon

Replied to Laravel Serialize Response

@manelgavalda I still have the same problem in the solution that you provided.

Activity icon

Started a new Conversation Laravel Serialize Response

Hi,

I have a code:

// Controller:  

$newData = $this->getOffersList($data, $request);

//  dd( mb_detect_encoding ( $newData[0]['description'] )); // "ASCII"

return response()->json([
    'error'=>false,
    'offers'=> $newData
]);

How can I exchange it for:

$newData = serialize($newData);

And send the data in response along with error = false?

Activity icon

Started a new Conversation Laravel - InvalidArgumentException: Malformed UTF-8 Characters

Hi,

Has anyone encountered such a mistake?

// Coding of the phpmyadmin database: utf8mb4_general_ci
// Database connection in phpmyadmin: utf8_unicode_ci
// Settings in Laravel:

'mysql' => [
    'driver' => 'mysql',
    'url' => env('DATABASE_URL'),
    'host' => env('DB_HOST', '127.0.0.1'),
    'port' => env('DB_PORT', '3306'),
    'database' => env('DB_DATABASE', 'forge'),
    'username' => env('DB_USERNAME', 'forge'),
    'password' => env('DB_PASSWORD', ''),
    'unix_socket' => env('DB_SOCKET', ''),
    'charset' => 'utf8mb4',
    'collation' => 'utf8mb4_unicode_ci',
    'prefix' => 'ai_',
    'prefix_indexes' => true,
    'strict' => false,
    'engine' => null,
    'options' => extension_loaded('pdo_mysql') ? array_filter([
        PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
    ]) : [],
],

Controller:

$newData = $this->getOffersList($data, $request);

//  dd( mb_detect_encoding ( $newData[0]['description'] )); // "ASCII"

return response()->json([
    'error'=>false,
    'offers'=> $newData
]);

Error:

InvalidArgumentException: Malformed UTF-8 characters, possibly incorrectly encoded in file /var/www/vendor/laravel/framework/src/Illuminate/Http/JsonResponse.php on line 75

The database offers in, inter alia, the following languages: English, Polish, Ukrainian etc.

Jan
23
2 months ago
Activity icon

Replied to How To Display Animals With All Informations?

@konstruktionsplan

You will not do this on this table structure.

To do what you want you should have. Change:

Animal-Table: id, name, animal_class_id, timestamps

To:

Animal-Table: id, name, animal_class_race_id, timestamps
Activity icon

Replied to Count Number Of Rows

@ahmeddabak

Chunk processes the data, but returns nothing.

Am I doing something wrong?

Activity icon

Replied to Count Number Of Rows

@ahmeddabak

$users->count() also returns 10 records instead of e.g. 20 000.

Activity icon

Replied to Count Number Of Rows

@ahmeddabak

I understand what the best answer is for. I changed it because the answer does not work exactly as I wanted.

Pages work as you wrote. However, how can I download the total number of records that meet the search criteria?

Because:

$users = \App\User::where('name', 'like', '%'.$request->name.'%')->chunk(10, function ($users, $page) {

    dd(count($users));
    
    foreach ($users as $user) {
         //
     }
});

dd() returns 10 records instead of e.g. 20 000.

Activity icon

Replied to Count Number Of Rows

@ahmeddabak

How can I check which piece of data is currently processed by the query?

Because chunk goes iteratively over all records 1-20,000.

So if I want a piece, e.g. 19 921 - 19 930, then in terms of performance it will not pass.

Activity icon

Replied to Count Number Of Rows

@ahmeddabak

You're right. Thank you for your help.

Activity icon

Replied to Count Number Of Rows

@ahmeddabak

How can I download a piece of data?

Eg.
chunk1 = records 0 - 10
chunk2 = records 11 - 20

because I need to send the results later using api.

Activity icon

Replied to Count Number Of Rows

@ahmeddabak

Good way.

But what if "// get all records matching a criteria" returns me, for example, 20 000 records.

And I take only 10 of it?

Activity icon

Replied to Count Number Of Rows

@bugsysha

When applying pagination I get the error: Unknown column 'distance' in 'having clause'

Is there any way to use 'skip' and 'take' instead of pagination and to get the number of all records that match the search criteria?

Activity icon

Replied to Count Number Of Rows

@sujancse

The limit only downloads me a certain number of records from the database. How can you still download all the records that match your search criteria?