Konstruktionsplan

Member Since 1 Year Ago

Hamburg

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
96
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
Jan
10
1 week ago
Activity icon

Replied to CURL-Massacre 🩸

Now I have pushed everything up and get at least already halfway something "right". Oddly enough, it now tells me that I am unauthorized. With terminal it now also no longer works.

But the keys are stored correctly.

Illuminate\Http\Client\Response {#494 ▼
  #response: GuzzleHttp\Psr7\Response {#529 ▼
    -reasonPhrase: "Unauthorized"
    -statusCode: 401
    -headers: array:15 [▼
      "Date" => array:1 [▶]
      "Server" => array:1 [▶]
      "X-Powered-By" => array:1 [▶]
      "X-Robots-Tag" => array:1 [▶]
      "Link" => array:1 [▶]
      "X-Content-Type-Options" => array:1 [▶]
      "Access-Control-Expose-Headers" => array:1 [▶]
      "Access-Control-Allow-Headers" => array:1 [▶]
      "Vary" => array:1 [▶]
      "Content-Type" => array:1 [▶]
      "X-Varnish" => array:1 [▶]
      "Age" => array:1 [▶]
      "Via" => array:1 [▶]
      "Content-Length" => array:1 [▶]
      "Connection" => array:1 [▶]
    ]
    -headerNames: array:15 [▶]
    -protocol: "1.1"
    -stream: GuzzleHttp\Psr7\Stream {#527 ▶}
  }
  #decoded: null
  +"cookies": GuzzleHttp\Cookie\CookieJar {#508 ▶}
  +"transferStats": GuzzleHttp\TransferStats {#530 ▶}

Edit:

In the WooCommerce description is somehow still passed the "wp_api" and "version". Do I have to (and can I) pass that via Laravel as well?

require __DIR__ . '/vendor/autoload.php';

use Automattic\WooCommerce\Client;

$woocommerce = new Client(
    'https://example.com',
    'consumer_key',
    'consumer_secret',
    [
        'wp_api' => true,
        'version' => 'wc/v3'
    ]
);
Activity icon

Replied to CURL-Massacre 🩸

Laravel and WooCommerce runs on the same local machine. But your post 🖤 got me thinking. Yes, it may be that the terminal can fire a successful cURL statement to the local environment, but I shouldn't assume that an application can as well. I'll push the store to a live server and would test it again and get back to you if necessary.

Thanks for this thought! :)

Jan
09
2 weeks ago
Activity icon

Replied to CURL-Massacre 🩸

Hi, big thank you for the explanation! I have now tried it with BasicAuth. Unfortunately this does not work. But I get correct results via the conosole.

curl https://playground-wordpress.site/wp-json/wc/v3/orders -u ck_3345f111b028e182d49feeca982815c6b3dacebe:cs_eaa8618793277f5eb4c17625dace0969bdd50a81

The keys don't matter for now, since it's all local.

My try with Laravel:

$response = Http::withBasicAuth(
     'cs_eaa8618793277f5eb4c17625dace0969bdd50a81', 'ck_3345f111b028e182d49feeca982815c6b3dacebe')
    ->get('http://playground-wordpress.site/wp-json/wc/v3/orders');

dd($response);

Output:

Illuminate\Http\Client\Response {#494 ▼
  #response: GuzzleHttp\Psr7\Response {#529 ▼
    -reasonPhrase: "Not Found"
    -statusCode: 404
    -headers: array:6 [▶]
    -headerNames: array:6 [▶]
    -protocol: "1.1"
    -stream: GuzzleHttp\Psr7\Stream {#527 ▶}
  }
  #decoded: null
  +"cookies": GuzzleHttp\Cookie\CookieJar {#508 ▶}
  +"transferStats": GuzzleHttp\TransferStats {#530 ▶}
Activity icon

Replied to CURL-Massacre 🩸

As said. The site did not help me because there are no exampels that are close to reality. At least as far as this problem is concerned.

Jan
08
2 weeks ago
Activity icon

Started a new Conversation CURL-Massacre 🩸

Hello!

So slowly I'm getting desperate. I have a simple cURL command. There is a URL and after "-u" a "CONSUMER_KEY" and a "CONSUMER_SECRET".

Via the terminal it works wonderfully. How do I implement this in PHP with Laravel. The documentation just tells me nothing and helps 0.

So I hope someone here knows a simple method to fire a simple command and return its response.

Thanks.

Jan
06
2 weeks ago
Activity icon

Started a new Conversation Best🪡Way

Hello

Output

Stroman, McDermott and Mueller: 150
Considine-Osinski: 54
Stroman, McDermott and Mueller: 59
Kirlin-Blick: 195

Controller:

Playground::join('number', 'playground.hash', '=', 'earnings.hash')->orderBy('number.id', 'DESC')->get();

I want to see only one player, but the points should be counted together. Any idea how best to do this in Laravel? 🎉

Thanks

Dec
30
3 weeks ago
Activity icon

Replied to Right ✨Update-Queries.

That's what I'm going to do. Thanks!

I used to fetch the ID via the request, pass it in where and then it was done. But I want to get better. :D

Activity icon

Replied to Right ✨Update-Queries.

Thanks for this hint, which I certainly did not come up with....

Is there anyone who can explain this to me again in detail? For example, do I put in ->where($client) or something like that?

But thanks for your......... "help".

Activity icon

Started a new Conversation Right ✨Update-Queries.

Hello!

When I initiate a class, the method "Update" is created automatically:

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\Client  $client
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, Client $client)
    {
        //
    }

I don't quite understand why $request and $client are passed as parameters. What would the an input field in HTML, the route in web.php and the correct notation have to be to make an update?

Thanks! 🍰

Dec
17
1 month ago
Activity icon

Replied to Livewire 😒don't Work...

Hey.

Unfortunately, no logs are thrown. Could it be that Livewire 2 is not yet compatible with Laravel 8?

Activity icon

Started a new Conversation Livewire 😒don't Work...

Hello.

Always the same error that has been with me for weeks and for which I can not find a solution.

Completely empty installation of Laravel 8 ✅. TailwindCSS 2 installed and working ✅

But if I do the only two steps that Livewire wants:

composer require livewire/livewire
@livewireStyles
@livewireScripts

Then only this comes in the browser:

@livewireStyles @livewireScripts

Why doesn't it interepret this? It worked fine with Livewire 1....so a crap.

Dec
15
1 month ago
Activity icon

Started a new Conversation Skipping 😳PSR4

Whenever I do "composer update" it comes up gaaanz. Any idea how to solve this? 🤔

Thanks.

Class Livewire\Exceptions\CannotBindToModelDataWithoutValidationRuleException located in ./vendor/livewire/livewire/src/Exceptions/CannotBindToModelDataWithoutValidationRuleException 3.php does not comply with psr-4 autoloading standard. Skipping.
Class Livewire\Exceptions\CannotUseReservedLivewireComponentProperties located in ./vendor/livewire/livewire/src/Exceptions/CannotUseReservedLivewireComponentProperties 3.php does not comply with psr-4 autoloading standard. Skipping.
Class Livewire\Exceptions\ComponentNotFoundException located in ./vendor/livewire/livewire/src/Exceptions/ComponentNotFoundException 3.php does not comply with psr-4 autoloading standard. Skipping.
Class Livewire\Exceptions\CorruptComponentPayloadException located in ./vendor/livewire/livewire/src/Exceptions/CorruptComponentPayloadException 3.php does not comply with psr-4 autoloading standard. Skipping.
Class Livewire\Exceptions\MethodNotFoundException located in ./vendor/livewire/livewire/src/Exceptions/MethodNotFoundException 3.php does not comply with psr-4 autoloading standard. Skipping.
Class Livewire\Exceptions\MissingFileUploadsTraitException located in ./vendor/livewire/livewire/src/Exceptions/MissingFileUploadsTraitException 3.php does not comply with psr-4 autoloading standard. Skipping.
Nov
27
1 month ago
Activity icon

Replied to Tailwind Part ✌🏻

Now only errors if i try to run "npm run dev", after "npm install" ofc. :(

(Use `node --trace-warnings ...` to show where the warning was created)
(node:8036) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:8036) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Activity icon

Replied to Tailwind Part ✌🏻

Hey. I run "npm run dev".

My package.json:

{
    "private": true,
    "scripts": {
        "dev": "npm run development",
        "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --config=node_modules/laravel-mix/setup/webpack.config.js",
        "watch": "npm run development -- --watch",
        "watch-poll": "npm run watch -- --watch-poll",
        "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --disable-host-check --config=node_modules/laravel-mix/setup/webpack.config.js",
        "prod": "npm run production",
        "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --config=node_modules/laravel-mix/setup/webpack.config.js"
    },
    "devDependencies": {
        "axios": "^0.19",
        "cross-env": "^7.0",
        "laravel-mix": "^5.0.1",
        "lodash": "^4.17.19",
        "resolve-url-loader": "^3.1.0",
        "vue-template-compiler": "^2.6.12"
    },
    "dependencies": {
        "autoprefixer": "^10.0.2",
        "postcss": "^8.1.10",
        "tailwindcss": "^2.0.1"
    }
}
Nov
26
1 month ago
Activity icon

Started a new Conversation Tailwind Part ✌🏻

Hello. ✨

How do I install Tailwind v. 2 ? The instructions are not quite conclusive for me.

Install:

npm install tailwindcss postcss autoprefixer

resources/css/app.css:

@tailwind base;
@tailwind components;
@tailwind utilities;

webpack.mix.js:

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

ℹ️Output in public/css/app.css:

@tailwind base;
@tailwind components;
@tailwind utilities;
Nov
10
2 months ago
Activity icon

Started a new Conversation "Old" Auth-Mechanisms

Hello.

I'm a little confused now, what "auth mechanisms" there are in Laravel, away from Jetstream.

Actually, I would only have the "old" Auth option, but then with Tailwindcss instead of Bootstrap.

Would that be possible?

Thanks

Nov
08
2 months ago
Activity icon

Replied to Redirect Away

"htt"//youtube.link

Thanks! :)

Activity icon

Replied to Redirect Away

<a href="{{$youtube->youtube_link}}" target="_blank">Hello :) </a>

Not working. :(

Activity icon

Started a new Conversation Redirect Away

Hello.

I just want to get a link from the database, e.g. a YouTube link, and when I click on it I don't want /mypage.com/jdfskn to open, but the page in a new tab.

With redirect()->away() this does not work.

Oct
29
2 months ago
Activity icon

Replied to Stock In 📻Buttons.

Now I copied yours 1:1 and inserted my values and now it works. I had CSRF in it.

Don't find the error in my code, but thanks to you it works! :)

Activity icon

Replied to Stock In 📻Buttons.

    <p class="inline-block text-2xl"><input type="hidden" name ='questions[0][question_id]' value="Bird?">Bird?</p>
            <p class="text-2xl"><input type="radio" name="questions[0][answer]" value="1"> 🦜 <input type="radio" name="questions[0][answer]" value="2"> 🐥</p>
            
            <p class="inline-block text-2xl"><input type="hidden" name ='questions[1][question_id]' value="Take one">Take one</p>
            <p class="text-2xl"><input type="radio" name="questions[1][answer]" value="1"> 👋🏻 <input type="radio" name="questions[1][answer]" value="2"> ✨</p>

Cant find it. 🤔

Activity icon

Replied to Stock In 📻Buttons.

array:2 [▼
  0 => array:2 [▼
    "question_id" => Bird?"
    "answer" => "1"
  ]
  1 => "✨"
]

But we are slowly getting closer! :D Thanks!

Activity icon

Replied to Stock In 📻Buttons.

Migration:

    public function up()
    {
        Schema::create('birdy', function (Blueprint $table) {
            $table->id();
            $table->integer('player');
            $table->text('question');
            $table->integer('answer');
            $table->timestamps();
        });
    }

Views:

         <p class="inline-block text-2xl"><input type="hidden" name ='questions[0]question_id' value="Bird?">Bird?</p>
            <p class="text-2xl"><input type="radio" name="questions[0]answer" value="1"> 🦜 <input type="radio" name="questions[0]answer" value="2"> 🐥</p>
            
            <p class="inline-block text-2xl"><input type="hidden" name ='questions[1]question_id' value="Take one.">Take one.</p>
            <p class="text-2xl"><input type="radio" name="questions[1]answer" value="1"> 👋🏻 <input type="radio" name="questions[1]answer" value="2"> ✨ </p>
            

Controller:

  public function store(Request $request)
    {
        /* Dont work, i comment in for the testing
        $this->validate($request,[
            'questions.*.question' => 'required',
            'questions.*.answer' => 'required'
        ]);
        */
        
        dd($request->questions);
        
        foreach ($request->questions as $question) {
            DarkMatter::create([
                'player' => 1, // Here i need the value from first Question
                'question' => $question['question'],
                'answer' => $question['answer'],
            ]);
        }
        
    }
Activity icon

Replied to Stock In 📻Buttons.

 dd($request->questions);
array:1 [▼
  0 => "1"
]

Ehm. And now? I need something like this:

array:1 [▼
  'Take a bird.' => "1"
]

So i can save the Question and the Answer. :)

Activity icon

Replied to Stock In 📻Buttons.

Unfortunately I cannot yet imagine how the store method in the controller for this frontend looks like.

Do you happen to have a tip for me? :)

Activity icon

Replied to Stock In 📻Buttons.

Thanks for the detailed answer.

I have the problem that the questions do not come from the database, but are fixed in the code. So they have no ID. :(

Activity icon

Replied to Stock In 📻Buttons.

Great Idea! That will works!

More ideas for the best solution?

Wait a moment:

Will it work with multiple questions?

Activity icon

Replied to Stock In 📻Buttons.

Sure! :)

My Frontend:

<p class="inline-block text-2xl">Take a bird.</p>
<p class="text-2xl"><input type="radio"> 🦜 <input type="radio" class="ml-10"> 🐥</p>

And i want to store like:

id, question, answer, created_at, updated_at

Activity icon

Started a new Conversation Stock In 📻Buttons.

Hello friends! ✨

Actually a very simple task. I have a

tag, there is a question formulated. Underneath are the answers. I want it to store the question AND the answers in a line in the database. How do I do that exactly?

I get the answers in, but I don't get the question, because it is a

-tag. If I do a hidden-input, there is no assignment to the answers.

I hope someone knows the best solution for this.

Thanks. 🖤

Oct
07
3 months ago
Activity icon

Started a new Conversation Philosophical 🎈Punctuation

Hello friends!

The only difference I know is that the double quotes would interpret a variable. The single quotes are for the string output.

So why do so many people use double quotes when they want to output strings?

Greez from Germany! 👋🏻

Oct
05
3 months ago
Activity icon

Replied to Livewire ✨ Problem

Thanks! Fixed HTML, but not work. :(

Activity icon

Replied to Livewire ✨ Problem

No, but its fresh installation of laravel + livewire


<!DOCTYPE html>
<html lang="de">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
        <title>Site</title>
        @livewireStyles
        <link rel="stylesheet" href="css/app.css">
    </head>
         <body class="bg-purple-200">
    <div class="container">
        Test
    </div>
</body>
 
    <livewire:scripts />
</html>

The only code...

Activity icon

Replied to Livewire ✨ Problem

Hey.

No reaction. 😔

Activity icon

Started a new Conversation Livewire ✨ Problem

Hello friends!

So on local it works great, but on live it's all you get:

@livewireStyles
Test
@livewireScripts
Sep
14
4 months ago
Activity icon

Replied to Laravel 8 Password Reset

config('queue.batching.table', 'job_batches'),

One coma too much at the end.

Sep
10
4 months ago
Activity icon

Replied to Thanks Livewire...

It is strange that only the component does not work. With all others it works and although I have a layout file, it shows me the styles but without content.

Activity icon

Started a new Conversation Thanks Livewire...

Hello. Simple workflow not working in v2.

Component:

    /**
     * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function render()
    {
        return view('livewire.editjuice');
    }

Route:

Route::get('/saft-editieren/{juice:slug}', EditJuice::class)->name('edit');

View:

<div>
    Hello
</div>

Result: Empty site...

Sep
09
4 months ago
Activity icon

Replied to Controller?!?!

Thanks! It works, but do you know why it was done?

Activity icon

Started a new Conversation Controller?!?!

Hello!

(Laravel 8)

Controller:

<?php

namespace App\Http\Controllers;

class HomeController extends Controller
{
    public function index()
    {
     dd("drin");
    }
}

Route:

// Root
    Route::name('home.')->group(function () {
        Route::get('/', '[email protected]')->name('index');
});
Target class [HomeController] does not exist.

WTF?

Aug
27
4 months ago
Activity icon

Replied to Multi 🧵Bindings.

Fix it:

$subjuice = JuiceMix::with('mainJuice1', 'mainJuice2')->where('id', '=', $juiceMix->id)->get();
      #attributes: array:10 [▶]
      #original: array:10 [▼
        "id" => 4
        "title" => "Fantasy"
        "juice1" => 3
        "juice2" => 2
        "slug" => "fantasy"
        "favorite" => 0
        "description" => "Fantasy"
        "rating" => 2
        "created_at" => "2020-08-27 13:09:37"
        "updated_at" => "2020-08-27 13:09:37"
      ]
      #changes: []
      #casts: []
      #classCastCache: []
      #dates: []
      #dateFormat: null
      #appends: []
      #dispatchesEvents: []
      #observables: []
      #relations: array:2 [▼
        "mainJuice1" => App\Juice {#1283 ▶}
        "mainJuice2" => App\Juice {#1285 ▶}
Activity icon

Replied to Multi 🧵Bindings.

Model:

class JuiceMix extends Model
{
    public function mainJuice1()
    {
        return $this->belongsTo(Juice::class, 'juice1');
    }


    public function mainJuice2()
    {
        return $this->belongsTo(Juice::class, 'juice2');
    }

    public function mainJuices()
    {
        return collect([$this->mainJuice1, $this->mainJuice2]);
    }
}

Controller:

 $subjuice = JuiceMix::with('mainJuice1', 'mainJuice2')->first();
 dd($subjuice);

The first juice is unfortunately still at "null".

Activity icon

Replied to Multi 🧵Bindings.

  #relations: array:2 [▼
    "juice1" => null
    "juice2" => App\Juice {#1284 ▼
      #connection: "mysql"
      #table: "juices"
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:12 [▶]
      #original: array:12 [▼
        "id" => 2
        "title" => "s2"
        "brand_id" => 1
        "genre_id" => 1
        "slug" => "s2"
        "favorite" => 0
        "description" => "sfsdf"
        "alcohollevel" => null
        "rating" => 3
        "created_at" => "2020-08-25 19:37:20"
        "updated_at" => "2020-08-25 19:37:20"
        "deleted_at" => null
      ]

One Juice is here, but juice1 is null! 😭

Activity icon

Replied to Multi 🧵Bindings.

This is probably bewitched! ✨

[null,null]
Activity icon

Replied to Multi 🧵Bindings.

@silencebringer

First of all: Woow! Thanks for the great help! 👍🏻

Unfortunately I only get the IDs in the database column "juice1" and "juice2".

1

2

Is there something missing?

Activity icon

Started a new Conversation Multi 🧵Bindings.

Hello Friends! 👋🏻

The following situation:

I have a juice that has been mixed from two different juices. We call it the "main juice". What does the model have to look like if I want to show the „main juices" of the „sub juice"?

Databasestructure of "subjuices"

id, title, juice1, juice2, descriptions & the timestamps

Thanks and a juicy day! 🧃

Aug
26
4 months ago
Activity icon

Started a new Conversation Guzzle-Error?

Hey!

Client error: `GET http://dashboard.site/hook/kunde` resulted in a `404 Not Found` response: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width= (truncated...)

If i try

$client = new GuzzleHttp\Client();
$client->get('http://dashboard.site/hook/kunde');

But i can call http://dashboard.site/hook/kunde localy!

Aug
24
4 months ago
Activity icon

Replied to Recursive ♻️Factorial

Hey @sinnbeck

But only in Laravel, right? Plain PHP wouldn't catch that? 🤔

Activity icon

Replied to Recursive ♻️Factorial

@michaloravec

"I've heard about recursion many times, but until now I didn't call the function again and again, because the thing with the "Allowed memory size" without the if-block scared me!"

If I don't catch an error somewhere, it will crash on a live server, but it will not paralyze it. But if I start an "infinite call", it will crash much more, right?

Activity icon

Replied to Recursive ♻️Factorial

Hello friends!

The more code, the better, even if it is not the same code, right?

What @ravish posted seems to me to be a method in a class, while mine is a function. But of course the same in principle.

The question was whether the recursion itself is "clean code". :)

Aug
23
5 months ago
Activity icon

Started a new Conversation Recursive ♻️Factorial

Hello again! 👋🏻

This code I have written and understood. The idea came to me when I tried to solve it with a "for" loop.

Is that a "clean code"? I've heard about recursion many times, but until now I didn't call the function again and again, because the thing with the "Allowed memory size" without the if-block scared me! 👻

Thanks! 💜

function recursive_factorial($int) {
  	if ($int == 0) {
	   return 1;
	}
  
	return recursive_factorial($int-1) * $int;
}

print_r(recursive_factorial(5)); // 1 * 2 * 3 * 4 * 5
120