Lunah

Lunah

Member Since 5 Years Ago

Experience Points 9,790
Experience Level 2

210 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 87
Lessons
Completed
Best Reply Awards 1
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

13 Jun
4 days ago

Lunah started a new conversation Restricting API To Authorised Clients? (in Addition To User Auth)

Hey,

I have an API for iOS/Android app that was originally set up with simple user auth (user enters email/password, they get a token, it's stored in an iOS/Android app and passed along with all requests).

The API has since grown and has been re-written to be a bit more 'general purpose' and it can now be consumed by our admin backend tool to manage CRUD and other functions that power the service.

Even though the API is secured with tokens, has policies protecting CRUD abilities, it still worries me that anyone could literally fire up postman and start poking around.

My question is, is it worth trying to restrict the APIs usage to authorised devices... My initial thought process was set up 'client tokens' for each group of devices, so one for the iOS/Android apps, one for the admin backend... and then any requests that didn't have these tokens would not allow the API to be consumed, regardless of if the request contained auth tokens, basically an extra layer of security...

I looked around online and it isn't a well-received idea.

Any thoughts on this?

I should add that I'm well aware tokens can always be obtained, jailbroken apps have data extracted, particularly Android. I know that it can never be fully protected, it's all about making it difficult for the users.

If not tokens, then something else? or maybe I'm just being too paranoid?

Lunah left a reply on Nova Deplyoment Error

Have you added "laravel/nova": "~2.0" to the require section of composer.json?

I deployed mine using the other method: Downloaded the Nova source files, copied into the root of my project and added the repositories info to composer.json

https://nova.laravel.com/docs/2.0/installation.html#installing-nova

11 Jun
6 days ago

Lunah started a new conversation Horizon/Redis - Multiple Server Setup?

What is the best approach for using Redis and Horizon on multiple server setup?

We currently have our app installed on a single instance and about to deploy it to a load balanced infrastructure with 3 nodes.

This means 3 deployments of the code base, sharing a single database.

Should we delegate one node for queue management and scheduled tasks (one Redis db) or allow each server to independently manage their own queue (3 Redis dbs)?

I feel like using one REDIS DB would 'cleaner' .. but if that node ever went down it would prevent the app from functioning properly... so probably better to allow each server to manage their own queue?

25 Nov
6 months ago

Lunah left a reply on Blade Nl2br And A CSS Question

  1. This is fine, however, you can clean this up a little by extracting the nl2br() functionality to your model.
// Post.php


function getFormattedBodyAttribute()
{
    return nl2br($this->body);
}

Then you can simply do $post->formatted_body in your view`

You can, of course, call formatted_body anything you like.

  1. Impossible to say without seeing your CSS. Make sure your form is set to inline.

Lunah left a reply on Laravel Blade Form

The first uses the HTML & Form package to provide convenient methods of creating forms but has since been removed from Laravel. You would need this package (https://laravelcollective.com/docs/master/html) to have access to those methods, to be honest, this is an outdated way of creating forms, while it does provide some helpful functionality, it's nothing that can't be done quite easily using vanilla HTML or existing Laravel functionality.

The second is basic HTML.

The preferred way, in my opinion would be standard HTML with named routes for setting the action.

<form method="POST" action="{{ route('route.name') }}">
</form>
20 Aug
1 year ago

Lunah left a reply on Forge Alternatives

@cat24max no support at all. I've also sent in a couple of emails/messages. No reply.

The idea behind these deployment services is actually quite simple. The work going on behind the scenes is not as technical as it might seem. Sure, they're very polished and perfect if you don't want to write your own or waste time to mess with servers, however, we created our own basic platform within a few hours.

I didn't mind paying for Forge, some of the funds will go back into developing Laravel, but we didn't use it as much as we thought and with little to no OOB customisation of the deployment script it was not suitable for all of the servers we managed. Add in no support, we decided it was enough for us to develop our own. It's disheartening to be ignored when you're paying for the service, regardless of little the reply needs to be.

27 Mar
2 years ago

Lunah started a new conversation How Do You Work With Eloquent/database Interactions?

Hi, this is more of an opinion post rather than a question, and i'm sure a lot of the responses will be 'it depends' .. lets assume a basic application doing nothing fancy, with some regular CRUD methods where Eloquent is used.

I'm basically wondering how you usually work with them? In simple terms, where do they go..

A very simple example is straight into the controller.

class Controller
{
    public function store($request)
    {
        $model = new Model::insert();
        return $model;
    }
}

This can quickly become messy, hard to read for bigger applications and run the risk of duplicating code in areas.

I've tried and seen various other methods but seem to either over complicate things or have draw backs in some way.

One way I quite enjoyed doing it was Jobs (and I can appreciate this is probably not the intended use of Jobs).

Each job will have a single responsibility:

class Controller
{
    public function update(UpdateRequest $request)
    {
        try {
            $this-dispatchNow(new UpdateUser($request)); // app/Jobs/UpdateUser.php
        } catch(\Exception) {
        }
    }
}

Very simple, dispatch a job passing through the request (and any other dependencies).

A problem i found with this is that it does not eliminate the issue of duplicate code as jobs tend to rely on a single request.

Take for example an application that allows admins and users to update a User model.

Requests:

app\Http\Requests\Users\UpdateRequest app\Http\Requests\Admin\Users\UpdateRequest


`app/Jobs/UpdateUser.php` requires an instance of `app\Http\Requests\Users\UpdateRequest` so when I tried to use the same Job to update user from the admin area it will throw an exception as I am passing wrong the wrong request.

To get around this problem I created an app specific class that worked in a similar way to services but instead of passing through instances of models, requests, etc we would only pass through very specific data that was required.. so instead of `new UpdateUser(Request $request)` We would pass `new UpdateUser($request->all())` which obviously passes an array of data..

I quickly realised the draw backs of this. It almost feels like we're taking the application `outside` of Laravel. We can now longer make use of `$request->has('input)` $model->fill()->save();` .. basically just any of the little nice to haves that Laravel offers.

Finally i've seen a usecase where Eloquent code would be stored in Services and bound to Contracts.

I hope i've not rambled on too much, apologies for the long post.. would love to hear how others do these sort of tasks.


23 Feb
2 years ago

Lunah left a reply on Get Value From Component’s Slot Input

Thanks for the example. I can see it's just a case of adding formData to the parent instance and passing it as a prop.

Very helpful.

Thank you :)

Lunah left a reply on Get Value From Component’s Slot Input

@logaretm thanks for replying. Do you have a small use case? I don't fully understand the solution. Thanks

Lunah started a new conversation Get Value From Component’s Slot Input

Hi,

I am trying to use slots in a component to add optional filters in a component.

e.g. I have a form component which handles ajax requests. All form fields go inside the component and referenced with

But it looks like non of the data can be passed to the component from a slot, as apposed to a binding on the component element.

Component:

<template>
    <form class="form" :action="action" :method="method" v-on:submit.prevent="ajaxSubmit">
        <slot></slot>
    </form>
</template>

<script>
module.exports = {
    props: {
        action: {
            required: true,
            type: String
        },
        method: {
            default: 'post',
            required: false,
            type: String
        }
    },
    data() {
        return {
            formData: {}
        }
    },
    methods: {
        ajaxSubmit() {
            // Do ajax
        }
    },
}
</script>

Html:

<ajax-form action="#">

        <input type="text" name="name" v-model="formData.name">
        ...
        <button type="submit" class="btn btn-primary">Add Campaign</button>
</ajax-form>

Vue warn]: Property or method "formData" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option. (found in root instance)

Any suggestions? Thanks

21 Feb
2 years ago

Lunah started a new conversation Spark Untested With Webpack/mix On 5.4?

Rolling a new Spark app with Laravel 5.4 I've noticed the public/css/app.js that is shipped with Spark is from a previous version compiled with Gulp.

Adding versioning and re-compiling will compile with WebPack/Mix. I've updated references of js/app.js to mix('js/app.js') to use versioned files and it now throws error:

ReferenceError: Can't find variable: Vue

In fact, I noticed almost all of my scripts aren't working, even some basic jQuery.

Switching back to the shipped js/app.js fixes the problem.

As a result it looks like Spark is broken in 5.4 unless there is an easy fix? I'm willing to bet that the developers have not properly tested re-compiled assets using WebPack/Mix.

Anybody else ran into this problem?

16 Feb
2 years ago

Lunah left a reply on Laravel Mix Error

This is a generic error and can mean a number of things.

Try running the failing command manually:

node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

This should give you an actual error message.

Lunah started a new conversation Editing Existing Packages In Laravel 5.3+

Hi, I have extended a 3rd party package and the developer has requested I create a pull request so that he include my changes in the main package.. Great!

However I am struggling to approach the correct workflow in L5.3+

I need to be able to edit the package, see changes in a testing environment then be able to push it to my fork.

There has to be a fool proof method rather than the hacky solutions I can think of.

There is some talk of creating a workbench directory, clone into it and adding my repository under "repositories" under composer. However this is not working at all. The information appears to be outdated.

See here: https://laracasts.com/discuss/channels/general-discussion/how-to-contributing-to-existing-laravel-package and here: http://www.reddit.com/r/laravel/comments/2el65h/a_question_about_editing_packages/ck0syex

It seems that Illuminate\Workbench\Starter doesn't exist anymore.

13 Feb
2 years ago

Lunah left a reply on Laravel Mix Image Workflow.

Also interested in this. I've used image min packages but they all rely on gulp.

12 Feb
2 years ago

Lunah started a new conversation Essential Quals/experience For A PHP Developer?

Not really coding related, but I am looking for some advice.

I have been given the gift of time (and some money) to invest in some personal development, ideally to improve CV, but most importantly, improve my skill.

I generally work with PHP and front end technology.. HTML, CSS, jQuery .. trying to learn Vue. I only possess some small computing qualifications and a diploma in Web Development, I'm self taught for the most part.

In my position, what exactly would be the best way to invest time and money? What are employers looking for in 2017?

How beneficial would it be to attend Laracon or some other Laravel investment.. or maybe going back to basics and taking the Zend exam? Other than buying a shed load of books and studying I'm not sure what else is available to add value to a CV?

Thoughts? .. thanks :)

26 Jan
2 years ago

Lunah left a reply on Safely Execute A String Of PHP Code?

It's more of an internal system for our team, but I still want to protect it from abuse.

Here is a basic example of what I am trying to achieve: https://www.functions-online.com/json_encode.html

I could input an array, and have JSON returned. It also shows the PHP code that was executed.

There are lots of PHP sandboxes or function testers online so I can only assume there is a safe way to do it :)

Lunah started a new conversation Safely Execute A String Of PHP Code?

Hi,

This question may not be directly related to Laravel, it's more of a general PHP question.

I am looking for the safest way to execute a string of PHP code.

I believe this can be done with the eval() function.

In context; A user submits a form field which contains a block of PHP code, for example, an array:

array('a' => 1, 'b' => 2);

This would be submit as a string

$_POST['code'] = "array('a' => 1, 'b' => 2);";

If I wanted to convert this to json I could do something like.

$returnValue = '';
eval("\$returnValue = json_encode($_POST['code']);");
return $returnValue;

This should output {"a":1,"b":2}

I believe there are great security risks with this? Is there a safer way to do it?

tl;dr: Code is sent via form, evaluated and the typical output is returned.

side note: This is going into a Laravel project so maybe laravel offers a more convenient way to do it. probably not

Thanks