andyandy

Member Since 9 Months Ago

Experience Points
13,500
Total
Experience

1,500 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
55
Lessons
Completed
Best Reply Awards
1
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 3
13,500 XP
Apr
08
1 week ago
Activity icon

Replied to Designing Database, Are Pivot Tables A Good Or Bad Thing?

Thanks! All of you are suggesting same approach.

Activity icon

Started a new Conversation Designing Database, Are Pivot Tables A Good Or Bad Thing?

I'm creating Person. Which will have about 30 properties (spoken languages, hobbies, favorite foods, attended schools). And data will be selected from 30 tables -> first table containing all possible languages, second table containing all possible hobbies.... .

How to store it?

OPTION 1: should I create 30 pivot tables. For example hobby_user (id, user_id, hobby_id). And insert

1	|	1 |	98
2	|	1 |	117
3	|	1 |	208

OPTION 2: or should I just create inside table "Person" column "hobbies" and insert "diving|skating|painting".

First option seems better, but I worry about performance. There will be 10 000 - 100 000 persons. Each having a few records in each pivot table. Meaning each pivot table having at least 100 000 records.

OPTION 1: Generating a single Person profile would mean going through 30 pivot tables and searching for selected options and then going through 30 hobbies/food tables to get PrettyName for that ID.

OPTION 2: Generating a single Person profile would mean just displaying 30 columns, maybe expode() them by some separator.

Activity icon

Replied to Redirect After Failed Login In Laravel 8?

Works, thanks!!!

Also add:

use Illuminate\Support\Facades\RateLimiter;
Activity icon

Replied to Redirect After Failed Login In Laravel 8?

Yes, I'm using Breeze.

I have my own basic login form on homepage.

<form action="{{route('login')}}" method="POST">

But if I insert bad credentials, Laravel will redirect me back to homepage. I would like to be redirected at /login where Breeze can show error message and offer password reset.

Activity icon

Started a new Conversation Redirect After Failed Login In Laravel 8?

I have login form at example.com/ and when login fails, it will redirect back to example.com/.

I want instead redirect failed logins to example.com/login where user can ask for new password etc.

I'm finding only solutions for Laravel 5, I need Laravel 8.

Activity icon

Replied to View [layouts.guest] Not Found.

Yes, files I found via GIT have exactly same code as you posted. Thank you!

Activity icon

Replied to View [layouts.guest] Not Found.

I went back in time in GIT and found that folder. So i had to delete it.

Now it works.

Activity icon

Replied to View [layouts.guest] Not Found.

Yep, I did that.

Apr
07
1 week ago
Activity icon

Started a new Conversation View [layouts.guest] Not Found.

I'm using breeze as my login/register system. But when I try to access URL to register/login I will get:

View [layouts.guest] not found.

I have folder /auth/ with files like login.blade.php or register.blade.php.

But my project doesn't have folder /layouts/ with file guest.blade.php. Which seems to be a problem, as files like login.blade.php extend 'guest' by starting with:

<x-guest-layout>
...
...
...

Where do I get this file?

Mar
31
2 weeks ago
Activity icon

Started a new Conversation Eloquent Nested Where Inside Nested Where Inside Where

feed	|		amount
----------------------------------
eur		|		100
dollar	|		250
eur		|		3000
eur		|		5000
dollar	|		50

Choose EUR under 1000 and DOLLAR under 500.

Model::where((EUR && under 1000) or (DOLLAR && under 500))->where.............

I wrote it like this but it doesn't work:

        $query = Transaction::orderBy('date', 'DESC')->orderBy('feed', 'ASC')->where(function ($q) {
            $q->where(function ($a) {
                $a->where('feed', 'eur')->where('amount', '<', 1000);
            })->orWhere(function ($a) {
                $a->where('feed', 'dollar')->where('amount', '<', 500);
            });
        })->where.........................;
Mar
26
3 weeks ago
Activity icon

Replied to Find All 10-digit Numbers In String

Yes, yours is nicer.

Activity icon

Replied to Find All 10-digit Numbers In String

Might not be the best but works.

$results = [];
$input = 'abcd 1111111111 as1111111111d33333asda2222222222sdf33333333333333333333333333333333333(*)@&#&^@';
foreach(explode('-', preg_replace('/\D/', '-', $input)) as $number){
    if(strlen($number)==10){
        $results [] =$number;
    }
}
$results= array_unique($results);

var_dump($results);


Activity icon

Started a new Conversation Find All 10-digit Numbers In String

input:

abcd 1111111111 asd33333asda2222222222sdf33333333333333333333333333333333333(*)@&#&^@

expected output:

1111111111
2222222222
Mar
25
3 weeks ago
Activity icon

Started a new Conversation Redirect/401 On Fail Of ->middleware('can:accessBank');

I've created a gate accessBank. I like that I can use it in web.php to restrict access to some route and at the same time I can use it in blade (@can) to eg. show menu link.

But when UNauthorized user tries to access ROUTE->middleware('can:accessBank'); it will give him Laravel error, in debug mode (This action is unauthorized.) and in production (Whoops, looks like something went wrong.).

I would prefer redirect to home page. Or at least 401 page.

Mar
19
4 weeks ago
Activity icon

Awarded Best Reply on How To Code (html/css) This Type Of Design?

Yeah, so I did it with CSS Grid. Works great.

Activity icon

Replied to How To Code (html/css) This Type Of Design?

Yeah, so I did it with CSS Grid. Works great.

Activity icon

Started a new Conversation How To Code (html/css) This Type Of Design?

I need to code this.

https://i.imgur.com/i91AZIJ.jpg

It has to keep proportions/ratios of images/blocks when being resized. And has to be responsive.

I'm thinking maybe Grids? Or Flexbox? Maybe Bootstrap? But it seems more like a table?

I don't know.

Mar
09
1 month ago
Activity icon

Awarded Best Reply on Get Html Code Of Page And Parse Out Content Of <div Class="img-wrapper">

I have downloaded this file (a single file simple_html_dom.php is enough to make this work):

https://sourceforge.net/projects/simplehtmldom/files/

Simple example is here:

https://code.tutsplus.com/tutorials/html-parsing-and-screen-scraping-with-the-simple-html-dom-library--net-11856

And this code will get all DIVs with class "wrap", and then you can for example loop them and add into a variable:

        require('public/simple_html_dom.php');
        $html = new \simple_html_dom();
        $html->load_file('https://www.example.com/');
        $items = $html->find('div[class=wrap]');



        $result = '';
        $i = 0;
        foreach ($items as $item) {
            if ($i == 3) {
                break;
            } else {
                $i++;
                $result .= $item->innertext;
            }
        }

        return $result;

Activity icon

Replied to Get Html Code Of Page And Parse Out Content Of <div Class="img-wrapper">

I have downloaded this file (a single file simple_html_dom.php is enough to make this work):

https://sourceforge.net/projects/simplehtmldom/files/

Simple example is here:

https://code.tutsplus.com/tutorials/html-parsing-and-screen-scraping-with-the-simple-html-dom-library--net-11856

And this code will get all DIVs with class "wrap", and then you can for example loop them and add into a variable:

        require('public/simple_html_dom.php');
        $html = new \simple_html_dom();
        $html->load_file('https://www.example.com/');
        $items = $html->find('div[class=wrap]');



        $result = '';
        $i = 0;
        foreach ($items as $item) {
            if ($i == 3) {
                break;
            } else {
                $i++;
                $result .= $item->innertext;
            }
        }

        return $result;

Activity icon

Replied to Get Html Code Of Page And Parse Out Content Of <div Class="img-wrapper">

Really? What if given DIV contains another DIVS?

Activity icon

Replied to Get Html Code Of Page And Parse Out Content Of <div Class="img-wrapper">

That gets content of entire page. How do I get content of a single DIV?

Activity icon

Started a new Conversation Get Html Code Of Page And Parse Out Content Of <div Class="img-wrapper">

I want to load HTML code of https://www.example.com/ and get the content of the [div class="img-wrapper"]. I want raw data => I want all the HTML tags and texts inside as is in the code.

I've tried DOMXPath, DOMDocument etc. etc. It's either too stupid and can't handle HTML5 or too clever and is stripping all HTML tags inside that DIV.

Mar
05
1 month ago
Activity icon

Replied to Can I Simply Write To Laravel.log In My Script?

Log::debug() is enough for my purposes.

Thanks a a lot!

Activity icon

Started a new Conversation Can I Simply Write To Laravel.log In My Script?

For example I'm doing ajax call to controller. (and therefor can't easily debug what is going on in controller, without sending debug messages back to ajax and for example print them in console)

It is possible write debug texts from controller for example to Laravel.log? For example var_dump something in that file.

Mar
01
1 month ago
Activity icon

Replied to App.css/app.js Causing Extremely Slow Load

How do I properly do that?

Activity icon

Replied to App.css/app.js Causing Extremely Slow Load

App.css has 3.5MB alone. It is OK size for this file?

This is my default mix.

mix.js('resources/js/app.js', 'public/js').postCss('resources/css/app.css', 'public/css', [
    require('postcss-import'),
    require('tailwindcss'),
    require('autoprefixer'),
]);

Can somebody share size for comparison?

Activity icon

Started a new Conversation App.css/app.js Causing Extremely Slow Load

I made fresh install of Laravel + Breeze on localhost (everything OK). Then moved it to server (git clone/composer install). And there it is suffering from extremely long loading times (10 - 30 seconds). And it is caused by loading app.css and app.js (I checked it in Chrome Developer/Network).

I'm thinking, maybe because it is re-generate files on each load? Do I have to run some npm command on server too?

Feb
22
1 month ago
Activity icon

Awarded Best Reply on VSCODE Stopped Suggesting Models Names Etc.

OK, so I solved it by pressing CTRL + SHIFT + P and typing "Intelephense: Index workspace".

Activity icon

Replied to VSCODE Stopped Suggesting Models Names Etc.

OK, so I solved it by pressing CTRL + SHIFT + P and typing "Intelephense: Index workspace".

Activity icon

Replied to VSCODE Stopped Suggesting Models Names Etc.

I went in .git 1 week (guaranteed it was working back then) back and the problem is still the same.

Activity icon

Replied to VSCODE Stopped Suggesting Models Names Etc.

I'm tracking changes by git and recently I made only a few minor changes in Blade template and Controller. I didn't touch anything else.

Activity icon

Replied to VSCODE Stopped Suggesting Models Names Etc.

No.

It is old project that is working in the browser just fine.

Only VSCODE is not working on this project.

He underlining Controllers, Traits etc. Also is not hinting Models, Traits when typing.

Activity icon

Started a new Conversation VSCODE Stopped Suggesting Models Names Etc.

In !!ONE!! of my projects VSCODE stopped suggesting names of Models while I'm typing. (It also started underlining "Controller".)

https://i.imgur.com/ZOiBuO6.png

But the real problem is that it isn't hinting Models anymore so I can easily namespace insert them.

I didn't do anything major recently in this project. Just a few changes in blade. Created route + controller.

Feb
16
2 months ago
Activity icon

Awarded Best Reply on How To Make Dynamic Protected Attribute In Model?

I can do it in constructor


	public function __construct(array $attributes = [])
	{
		$this->product_id = time();

		parent::__construct($attributes);
	}
Activity icon

Replied to How To Make Dynamic Protected Attribute In Model?

I can do it in constructor


	public function __construct(array $attributes = [])
	{
		$this->product_id = time();

		parent::__construct($attributes);
	}
Activity icon

Started a new Conversation How To Make Dynamic Protected Attribute In Model?

To specify default values to insert into table I'm using:

	protected $attributes = array(
		'title' => 'Product name',
		'text' => 'Hello there',
		'img' => 'img.jpg',
	);

And I would like to make dynamic rule:

	protected $attributes = array(
		'product_id' => '', //make this equal to ID or at least dynamic (equal to time())
	);
Feb
14
2 months ago
Activity icon

Started a new Conversation Voyager In Different Language, How To Do It

I can't find any article about changing language in Voyager admin panel? I found language settings at config/voyager.php but that's about it.

But where do I take translated files? I didn't find anything in vendor/voyager. Does it take somehow data from Laravel translation pack and Laravel itself has to have installed/changed locale?

Feb
11
2 months ago
Activity icon

Started a new Conversation Sorting Array By Key + Sorting By Custom Order After

I have this array. Which at [1] holds another serialized() array.

array:80 [▼
  0 => array:3 [▼
    0 => 0
    1 => "a:2:{s:5:"Color";s:5:"Black";s:4:"Size";s:1:"L";}"
    2 => 47
  ]
  1 => array:3 [▼
    0 => 0
    1 => "a:2:{s:5:"Color";s:5:"White";s:4:"Size";s:1:"S";}"
    2 => 48
  ]
  2 => array:3 [▼
    0 => 0
    1 => "a:2:{s:5:"Color";s:4:"Pink";s:4:"Size";s:1:"M";}"
    2 => 49
  ]
  3 => array:3 [▼
    0 => 0
    1 => "a:2:{s:5:"Color";s:6:"Yellow";s:6:"Size";s:2:"XS";}"
    2 => 50
  ]

I want to:

  1. Order it by color.

  2. Then order by size (XS, S, M, L, XL, XXL).

Just reorder it. Don't change format of the data.

Sometimes Color/Size could be missing. Then order doesn't matter.

Black XS
Black S
Black M
Black L
Black XL

White XS
White S
White M
White L
White XL

Pink XS
Pink S
...
...
...
...

I spent on this more time than I'm willing to admit, I'm asking for help if somebody knows.

Activity icon

Awarded Best Reply on Generate All Possible Combinations Inside An Array

I found out, that it is called Cartesian product. And you can use for example this code.

https://gist.github.com/jwage/11193216

or this code

https://stackoverflow.com/questions/6311779/finding-cartesian-product-with-php-associative-arrays

I choose second one.

Activity icon

Replied to Generate All Possible Combinations Inside An Array

I found out, that it is called Cartesian product. And you can use for example this code.

https://gist.github.com/jwage/11193216

or this code

https://stackoverflow.com/questions/6311779/finding-cartesian-product-with-php-associative-arrays

I choose second one.

Activity icon

Replied to Generate All Possible Combinations Inside An Array

I didn't see a way how to use it.

Activity icon

Started a new Conversation Generate All Possible Combinations Inside An Array

I put together this array. And I need all possible combinations. I was thinking about it and Googling around, but I really don't know where to start.

"Wine" => array:3 [▶]
"Cars" => array:2 [▶]
"Books" => array:4 [▶]
"Panels" => array:5 [▶]
"T-shirts" => array:4 [▼
    "Color" => array:4 [▼
      0 => "Black"
      9 => "Pink"
      10 => "Grey"
      16 => "Blue"
    ]
    "Size" => array:5 [▼
      0 => "S"
      1 => "XL"
      2 => "M"
      3 => "L"
      14 => "XXL"
    ]
    "Sex" => array:2 [▼
      0 => "Female"
      1 => "Male"
    ]
    "Pocket" => array:1 [▼
      0 => "without pockets"
    ]
  ]

I need for example:

T-shirts:

Color: Black, Size: S, Sex: Female, Pocket: without pocket
Color: Pink, Size: S, Sex: Female, Pocket: without pocket
Color: Grey, Size: S, Sex: Female, Pocket: without pocket
Color: Blue, Size: S, Sex: Female, Pocket: without pocket

Color: Black, Size: M, Sex: Female, Pocket: without pocket
Color: Pink, Size: M, Sex: Female, Pocket: without pocket
Color: Grey, Size: M, Sex: Female, Pocket: without pocket
Color: Blue, Size: M, Sex: Female, Pocket: without pocket

...
...
...

Feb
04
2 months ago
Activity icon

Started a new Conversation Cutting Off String By Comma, But Not If It's In Brackets

I had elegant solution:

$string = 'Color: blue, Size: big';

$myString = explode(',', $string)[0];

//result is: Color: blue

But I would like to ignore commas inside brackets:

$string = 'Color: blue (or red, black, yellow), Size: big';

$myString = ??????????

//wanted result is: Color: blue (or red, black, yellow)

String is not always followed by "Size: big".

Feb
03
2 months ago
Activity icon

Replied to Need Help With GroupBy And Counting Results

Thank to all of you guys!!!!

Activity icon

Started a new Conversation Need Help With GroupBy And Counting Results

I already spent too much time on this. Could you help?

vehicle	|	color
------------------------
car			|	red
car			|	red
car			|	red
car			|	blue
bus			|	red
bus			|	red
bus			|	black

I want group it and count it. Result will be:

car	- 	red	-	3
car	- 	blue	-	1
bus	- 	red	- 	2
bus	- 	black	- 	1

Feb
02
2 months ago
Activity icon

Replied to Installing Package Over FTP, How Do I Go About That, Is It Even Possible?

Generally speaking. When I install it, all files will be in a single folder (eg. vendor/voyager)?

Or will it 'injects' itself all over the place into different folders and update some other files?

Activity icon

Started a new Conversation Installing Package Over FTP, How Do I Go About That, Is It Even Possible?

There is a running website on a Laravel. They asked me if I can setup an admin (Voyager). But there is an access only over FTP! How would I go about that? Download entire web (20 000 + files) over FTP. Install it at my PC. And then upload Voyager files back?

Are the files in a single folder (vendor/voyager) or will it be all over the place? And will it also affect (edit/overwrite) other files somewhere else? If anybody has an experience... .

I have to get back to them with yes/no. Thanks!