Čamo

Member Since 5 Years Ago

Experience Points
3,960
Total
Experience

1,040 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
2
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.

  • Community Pillar

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

Level 1
3,960 XP
Jan
22
1 day ago
Activity icon

Started a new Conversation Uncaught ReferenceError: $ Is Not Defined

I have new Laravel 8 instalation and a little problem with js code. In js/bootstrap.js I have a code:

window.$ = require('jquery');
window._ = require('lodash');
window.axios = require('axios');

window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';

alert(window.$);

import './bootstrap';
import './components/alert';

webpack.mix.js creates the public/app.js file. But console throws me an error from components/alert.js which tries to use $ as jQuery. Also alert(window.$) does not run. Can somebody tell me what is wrong? Thanks.

Jan
21
2 days ago
Activity icon

Replied to Why Do All Generated Files Use Spaces For Indentation?

Spaces? The world is in the power of evil...

Jan
20
3 days ago
Activity icon

Replied to Laravel + Docker + Windows

Also the Sail runs as docker containers -> After Sail has been installed, you may run the sail:install Artisan command. This command will publish Sail's docker-compose.yml file to the root of your application:

Activity icon

Started a new Conversation Laravel + Docker + Windows

I am starting with Docker. As I see Laravel has docker container for new installation. But one of the requirements is to install WSL2 with Docker. WSL2 for Windows means to join insiders program for Windows and it means:

The experimental and early prerelease software and services made available to you in the Program might not be tested. You might experience crashes, security vulnerabilities, data loss, or damage to your device. ...

Do you have experience with running Laravel docker container on Windows? I have a Docker without WSL2 and it works. But Docker has some warnings about shared files between host and container....

What do you mean about it?

Dec
07
1 month ago
Activity icon

Replied to Form Submit With @csrf Throws 419 Expired Error

It seems it was some kind of deploy problem.

Activity icon

Started a new Conversation Form Submit With @csrf Throws 419 Expired Error

Hi, I have a simple register form with @csrf field inside but I am getting an 419 expired error on production. On local server it works well. I dont understand. Can somebody tell me please what is going on? Thanks.

PS The weird thing is that validation works.

Dec
03
1 month ago
Activity icon

Awarded Best Reply on Why This Join Return 11000 Results

$m = Manufacturer::select('manufacturers.*')
				->withTranslations( LanguageHelper::getLangId() )
				->with('image')
				->groupBy('manufacturers.id')
				->join('manufacturer_product', 'manufacturers.id', '=', 'manufacturer_product.manufacturer_id')
				->join('category_product', function($join) {
					$join->on('category_product.product_id', '=', 'manufacturer_product.product_id')
						->where('category_product.category_id', '=', $this->id);
				})->get();

groupBy() am I right?

Activity icon

Replied to Why This Join Return 11000 Results

Yes I saw it in debug bar. Is the groupBy the solution or is there a better way?

Activity icon

Replied to Why This Join Return 11000 Results

$m = Manufacturer::select('manufacturers.*')
				->withTranslations( LanguageHelper::getLangId() )
				->with('image')
				->groupBy('manufacturers.id')
				->join('manufacturer_product', 'manufacturers.id', '=', 'manufacturer_product.manufacturer_id')
				->join('category_product', function($join) {
					$join->on('category_product.product_id', '=', 'manufacturer_product.product_id')
						->where('category_product.category_id', '=', $this->id);
				})->get();

groupBy() am I right?

Activity icon

Started a new Conversation Why This Join Return 11000 Results

Hi, can somebody tell me please what is wrong with this join request to Manufacturer entity?


$m = Manufacturer::select('manufacturers.*')
	->withTranslations( LanguageHelper::getLangId() )
	->with('image')
	->join('manufacturer_product', 'manufacturers.id', '=', 'manufacturer_product.manufacturer_id')
	->join('category_product', function($join) {
		$join->on('category_product.product_id', '=', 'manufacturer_product.product_id')
			->where('category_product.category_id', '=', $this->id);
	})->get();

Log::debug($m->count());

DB tables: manufactures: id manufacturer_product: manufacturer_id, product_id product_category: product_id, category_id

The real count of manufacturers is 29. But the result count is 11000. I need to get all manufacturers which are joined via manufacturers_products to category.id. I dont want all relations but the unique entities. How to do it in Laravel?

Dec
02
1 month ago
Activity icon

Replied to Collection Map()

Not really. Try to change numbers to objects and then original collection will be modified.

Activity icon

Replied to Collection Map()

My bad, I forgot return in lambda. But the problem was and it really modifies original collection that if there are objects in collection they are modified.

Dec
01
1 month ago
Activity icon

Replied to Database + Eloquent Model Best Practice

Thanks a lot. This helped.

Activity icon

Replied to Database + Eloquent Model Best Practice

I though you mean DB joins. so now I am here with this stupid question.

Activity icon

Replied to Database + Eloquent Model Best Practice

I did not see the join for Eloquent in documentation. Where is it?

Activity icon

Replied to Collection Map()

Yes object behaves so. Ok now its clean. Tanks a lot.

Activity icon

Replied to Collection Map()

No I still dont understand. I forgot to return from lambda. But items in collection are affected.

Activity icon

Replied to Collection Map()

Ah I see it now. The collection is not modified but objects in there are.

Activity icon

Replied to Collection Map()

Yes you are right but this works. The original collection contains new field slug. So how is it possible cause I test it against $products typeof Collection and it is true.

Activity icon

Started a new Conversation Database + Eloquent Model Best Practice

Hi, I have a code which works well but I would like to know what is the best practice to do it. If the way in the code is ok or if it is overkill to call eloquent whereIn() and then build Eloquent entities and call paginate():

$productsIds = DB::table('products')
	->join('category_product', 'products.id', '=', 'category_product.product_id')
	->join('categories', 'categories.id', '=', 'category_product.category_id')
	->where('categories.slug', '=', 'tlaciarne')
        ->where('products.name', 'like', "$value")
	->select('products.id')
	->get()
	->pluck('id');

$products = Product::whereIn('id', $productsIds)
	->withTranslations(LanguageHelper::getLangId())
	->with('manufacturers')
	->with('image')
	->latest()
	->paginate(20);
Activity icon

Replied to Collection Map()

This is my code:

$products = DB::table('products')
	->leftJoin('products_texts', 'products.id', '=', 'products_texts.product_id')
	->leftJoin('files', 'products.image_id', '=', 'files.id')
	->select('products.name', 'files.name as url', 'products_texts.name as t_name')
	->where('products_texts.name', 'like', "%$value%")
	->limit(10)
	->get();

	$products->map(function ($item, $key) {
	    $item->slug = Product::slugify($item->name);
	});
Activity icon

Started a new Conversation Collection Map()

Hi, a documentation https://laravel.com/docs/8.x/collections#method-map about collections says the map() method does not modify original collection and to do this we should use transform() method. But is seems it is not true in v 8.0. Map() modifies original collection and returns damaged collection where all items are null. So what is going on there?

Nov
30
1 month ago
Activity icon

Replied to SQL Exists Query Does Not Return Relevant Result

One question. What should be the right way to make this query? Can I make a DB inner join get products ids and then call

Product::whereIn('id', $ids);

with necessary relations? Is it ok or not?

Activity icon

Replied to SQL Exists Query Does Not Return Relevant Result

Thank you $category->products() works.

Activity icon

Replied to SQL Exists Query Does Not Return Relevant Result

What the hell is it? It is about 50 000 model on homepage.

Activity icon

Replied to SQL Exists Query Does Not Return Relevant Result

Ok so how many model retrieved from what?

Activity icon

Replied to SQL Exists Query Does Not Return Relevant Result

How to enable models tab in debugbar? First time I hear about models tab.

Activity icon

Replied to SQL Exists Query Does Not Return Relevant Result

But then I lost the Eloquent relations as objects .... I would like to avoid it.

Activity icon

Replied to SQL Exists Query Does Not Return Relevant Result

But this is not the issue.

Activity icon

Replied to SQL Exists Query Does Not Return Relevant Result

This should not be the problem cause table is in utf8_slovak_ci collation it means it is case insensitive. Also this command throws an error unknow column LOWER(name)

Activity icon

Started a new Conversation SQL Exists Query Does Not Return Relevant Result

I have a Laravel application with this Eloquent query:

$products = Product::where('name', 'LIKE', "%{$value}%")
    ->whereHas('categories', function($q) {
        $q->where( 'slug', 'tonery-cartridge' );
    })->with('manufacturer')
    ->with('sm_image')
    ->orderBy('created_at','DESC')
    ->take(10)
    ->get();

This code generates the sql command like:

select * from `products` where `name` LIKE '%can%' 
    and exists (
        select * from `categories` inner join `category_product` 
            on `categories`.`id` = `category_product`.`category_id` 
            where `products`.`id` = `category_product`.`product_id` 
            and `slug` = 'tonery-cartridge'
    )
order by `created_at` desc limit 10

I am sure there are products which name contains "can" string and which belongs to category with slug "tonery-cartridge". Why this query returns empty result? If I try to make inner join sql manually it works well as you can see on the screenshot here: https://stackoverflow.com/questions/65080957/sql-exists-query-does-not-return-relevant-result?noredirect=1#comment115057625_65080957

Nov
28
1 month ago
Activity icon

Replied to $kernel->handle(...) Takes Too Much Time

I forgot to write that problem is fixed. It was a bad sql query.

Activity icon

Awarded Best Reply on Route Type Hint Resolves Wrong

Ok I Have it. There is a definition in RouteServiceProvider::boot() for this parameter name.

Activity icon

Replied to Route Type Hint Resolves Wrong

Ok I Have it. There is a definition in RouteServiceProvider::boot() for this parameter name.

Activity icon

Started a new Conversation Route Type Hint Resolves Wrong

Hi, I have a controller with method expecting two parameters. First one $manufacturer is type hinted but second one $categroy should be raw string.

class BrandController extends Controller
{
	public function show(Brand $brand, $category)
	{
		...
	}
}

The route for this controllet looks like:

Route::get('/brand/{brand}/{category}', '[email protected]')->name('brand.show');

This results in 404 not found cause application tries to inject TransCategory model to the second parameter. I dont understand why this happend if parameter $category is not type hinted. What is going on at the background?

Nov
27
1 month ago
Activity icon

Started a new Conversation $kernel->handle(...) Takes Too Much Time

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()
);

I have a problem with long application loading. The problem seems to be in the code above in index.php. Can anybody tell me where could be the problem?

Nov
19
2 months ago
Activity icon

Replied to Class 'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider' Not Found

I needed to reinstall it and now it works. Someone did dirty remove of this library and it stop working. Now it is ok. Thanks.

Activity icon

Started a new Conversation Class 'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider' Not Found

Hi, I need to install IdeHelperServiceProvider but I am getting error Class 'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider' not found from composer dum-autoload. Also php artisan does not show ide helper command although I have it in composer and I can see it in vendor directory. What am I doing wrong?

Nov
11
2 months ago
Activity icon

Started a new Conversation Swift_RfcComplianceException Address In Mailbox Given [] Does Not Comply With RFC 2822, 3.6.2.

I have a simple code to send two emails.

dd(trim($email), trim(config('mail.from.address')));
Mail::to(trim(config('mail.from.address')))->send(new OrderStatusForm($this,$status,$attachment, false));
Mail::to(trim($email))->send(new OrderStatusForm($this,$status,$attachment, true));

Both email addresses in dd() are valid. But both lines with Mail::to() throw me an error Swift_RfcComplianceException Address in mailbox given [] does not comply with RFC 2822, 3.6.2. I dont understand. What is wrong with that?

Nov
09
2 months ago
Activity icon

Replied to Base Table Not Found During Composer Install

Ok but what if I need to run this code e.g. as cron which sends an emails? This line for views is not the only reason of this error. There are also something like

$settings = GlobalSettings::all();
...
Config::set('mail', $config);

which wants to set config variables...

Activity icon

Replied to Base Table Not Found During Composer Install

As I found out it triggers AppServiceProvider::boot() method (dont understand why on composer install...) and there is a line

	view()->share('currency', app('activeCurrency')->symbol);

How can I remove it from boot() or where to store this call properly?

Activity icon

Replied to Base Table Not Found During Composer Install

Any progress in this issue? I have the same problem. SQL triggers while composer install. I dont understand why.

Nov
03
2 months ago
Activity icon

Replied to Instagram For Laravel

What it means? Whole Instagram is deprecated or whole api is deprecated? Here I dont se anything about it https://developers.facebook.com/docs/instagram-basic-display-api/getting-started

Activity icon

Started a new Conversation Instagram For Laravel

Hi there I need to choose best package for instagram api implementation. Can you give me a hint? The best package I found is abandoned. Other packages can to compare to it.

Thnak you.

Oct
30
2 months ago
Activity icon

Replied to How Do I Send The View Back To Ajax In Laravel

@ramjithap Thanks a lot. It made my day.

Activity icon

Replied to Migration Does Not Change Column Name

Cause much more interesting is that Laravel migration does not allow this operations. Its really weird and I need to understand things. Its is my nature. There is no reason to throw errors on this....