EventFellows

EventFellows

Member Since 3 Years Ago

Experience Points 78,295
Experience Level 16

1,705 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 408
Lessons
Completed
Best Reply Awards 69
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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.

07 Oct
1 year ago

EventFellows left a reply on Using A Theme For Laravel Spark - Any Experiences Or Recommendations?

I have started using https://vuetifyjs.com/ which is great but rahter a vue based framework with tons of great components but not a theme for spark.

08 Sep
1 year ago

EventFellows left a reply on Issue Using Moment Timezone In Vue Components

I tried your solution but did not get it to work: Error always was "Uncaught TypeError: window.moment.tz.guess is not a function"

Here is what worked in my setup for future reference for others:

window.moment = require('moment-timezone/builds/moment-timezone-with-data');

I have put it in behind the require('spark-bootstrap'); in the app.js file and ran gulp

07 Aug
2 years ago

EventFellows left a reply on Events Vs Jobs, Am I Join It Right?

It is mainly a question of coupling /decoupling your code.

If you fire an event, the firing class "has no knowledge about what will happen then" (as Jeffrey often puts it).

A listener would be the counterpart for an event. So the listener listens and triggers whatever you want to happen (it could be a job that you trigger).

Jobs are mainly good for excecuting tasks that cause a delay in execution at a later time.

So your setup is ok, but there are others ways, too.

06 Aug
2 years ago

EventFellows left a reply on Using A Theme For Laravel Spark - Any Experiences Or Recommendations?

Not much progress on my side on this. I have started to play around with vuetifyjs (which is not a theme but comes with many nice components).

Anyone else having recommendations regarding theme?

19 Jul
2 years ago

EventFellows left a reply on Where Do You Put The Application Logic?

I agree with @tykus. It really depends on the size and scope of what you do. For some parts of logic there are very common places like e.g. Policies for Authentication.

EventFellows left a reply on Using ->with()

I would suggest to reconsider WHY you want this, that sounds like a very uncommon design decision.

It is a relationship so it should be accessible via that relation.

But if you really wanted you can build it using a setup with __get() -> magic function

EventFellows left a reply on Can I A Fire Event After Specific Time?

If you do not depend on accuracy to the second, yes.

Say you have a feedback form that should be open for 2 weeks and after that you want to send all collected feedbacks to the admin -> that would work.

Say you have users do a quick problem solving thest that runs 60 seconds -> that would not work.

18 Jul
2 years ago

EventFellows left a reply on Can I A Fire Event After Specific Time?

Job would be one way, but be aware that this will not be accurate to the seconds depeding on your queue setup.

I would probably suggest to calculate the time when that that time is over.

$minutes = 25;
$endOfQuestionTime = Carbon::now()->addMinutes($minutes);

Then you can compare if that timestamp is in the past ('$endOfQuestionTime < Carbon::now()') - you can also make the calculation the other way round of course.

but you still need to run that check (you can also do that in the frontend, depending on what should happen after that time)

17 Jul
2 years ago

EventFellows left a reply on Error When Trying To Sum Collection

Sum normally expects a variable for which field you want to have the sum.

If I get your structre right shouldn't this work?

$invoice->bill->paid;

Or can an invoice have different bills?

14 Jul
2 years ago

EventFellows left a reply on Vue Child Component: Prop Object Passed By Reference

Yep, you would typically avoid mutating a prop directly (i believe Vue dev tools tells you about that, too)

Here is what you can do:

Simply assign the prop passed into the child component to another variable like this:

Vue.component('task-form', {
    props: {
    initialTask: {
        type: Object,
      required: true
    }   
  },
    data() {
    return {
            task: this.initialTask
    }
  },
08 Jul
2 years ago

EventFellows left a reply on Runs Very Slow If There Is An Error And Says Memory Exhausted

have you defined the correct tablenameon your model?

EventFellows left a reply on Disable Timestamps In Pivot Tables

just remove the '->withTimestamps()'. that is only for the pivot.

whether or not you have timestamps on permission table is independant from that.

EventFellows left a reply on An Artisan Command Doesn't Dispatch A Job Async

are you sure you have the correct 'queue=database' setting on the relvant .env file? .env normally is not on git repo.

EventFellows left a reply on How To Create A New Laravel Project With Another Folder??

just install it again and give it a different name. that will give you the laravel standard structure and is completely independant from your first innstall.

EventFellows left a reply on Form Is Not Showing The Btn Bootstrap Class

why do you have this?

{!! ... {{

that does not look familiar.

06 Jul
2 years ago

EventFellows left a reply on CATCH MAILABLE ERRORS

Yeah, got that. But still, understanding why it does not work is step 1, then you know what you need to change to make it work in step 2.

05 Jul
2 years ago

EventFellows left a reply on Laravel Auth - Added Registration Fields, Not Accepting Null Values

sounds like you are building on something that you have not created yourself.

make a global search in your code for 'The business name must be' and see where that is defined.

EventFellows left a reply on CATCH MAILABLE ERRORS

try catch only catches if an exception is thrown somewhere.

but code can also fail without an exception thrown.

have you tried to use a Mail::to?

what happens if you just hardcode your details. does it work then?

EventFellows left a reply on Laravel Auth - Added Registration Fields, Not Accepting Null Values

you have to make the field ->nullable() when you define the field for the table on themigration file.

02 Jul
2 years ago

EventFellows started a new conversation Conditionally 'require()' Files In Build Process

Hi peers, I am really stuck here but I believe there is a simple solution that I just don't see at the moment. Appreciate your help on this. I am not so familar with what happends behind the scenes in Elixir exactly.

I have a pretty standard 5.3 setup that uses Elixir (gulp) to build an app.js file requiring different js files into the build process.

It essentially is setup like this.

require('./js-file-1');
require('./js-file-2');
require('./js-file-3');

require('./js-file-only-in-dev-environment');

BUT I need to conditionally require some files that only get required on development builds - so it is depending on the build environment.

I typically run export NODE_ENV=production && gulp --production which sets process.env.NODE_ENV = 'production' (based on a recommendation from @Jeffrey on some other discussion here)

BUT THIS WON'T WORK because this variable seems to only be available WITHIN the build process but NOT in the files that are concatenated during the build process:

require('./js-file-1');
require('./js-file-2');
require('./js-file-3');

if (process.env.NODE_ENV !== 'production') {
    require('./js-file-only-in-dev-environment');
}

SO, simple question: How can I conditionally require a js file in build process?

EventFellows left a reply on Seeding Not Possible (says That File Is Missing)

Can you post your entire error message, please.

Also: if migrating or seeding fails it is often a good idea to manually wipe out your database to and only then try again (partially migrated database often throws new errors)

23 Jun
2 years ago

EventFellows left a reply on Which PHP Framework Is More Suitable For An Enterprise Project?

And for someone looking for some facts about relevance - a look at google trends gives a quite clear answer on what to use...

That should also be very convincing argument to any boss! Just show the graphs ;-)

https://trends.google.com/trends/explore?q=laravel,yii,zend,symfony

21 Jun
2 years ago

EventFellows left a reply on HasManyThrough Problem

the relation is for ONE instance and not for a collection.

This should work.

return $abc->first()->mprs;

Alternatively you can loop through your collection with foreach.

EventFellows left a reply on Which Eloquent Relationship ?

share your code please. that makes thinhs alot easier.

EventFellows left a reply on On-demand Delivery Startup, Should Use Existing LaravelAdmin Module Or Start From Scratch?

most of them use js, vue or jquery. so you might also want to consider one of the frontend frameworks if vue

  • buefy
  • vue-material
  • element-ui
  • vuetify

EventFellows left a reply on Best Practice?

check out the video about adapter pattern here on laracasts. it tells you what and how to do it.

EventFellows left a reply on Laravel - SQLSTATE[23000]: Integrity Constraint Violation: 1452 Cannot Add Or Update A Child Row: A Foreign Key Constraint Fails

normally your error exactly tells you what values it is trying to insert, but that part is misding in your post...

20 Jun
2 years ago

EventFellows left a reply on Custom Sidebar

Nope.

You create a service provider to bind your service into the Laravel IoC Container (which is essentially the $app variable)

And if you then 'resolve your class' out of the service container (for example by typehinting it on a controller) it gets newed up automatically.

Here is a simple example, I have a Helper.php

<?php

namespace App\Helpers;

class Helper
{
    /**
     */
    public function sayHello()
    {
        return 'Hello';
    }
}

And I have a HelperServieProvider.php

<?php

namespace App\Helpers;

use App\Helpers\Helper;
use Illuminate\Support\ServiceProvider;

class HelperServiceProvider extends ServiceProvider
{

    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {
        //
    }

    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->bind('helpers', function()
        {
            return $this->app->make(Helper::class);
        });
    }
}

I bind it to the config/app.php into the providers array

/*
 * Package Service Providers...
 */
App\Helpers\HelperServiceProvider::class,

Run php artisan clear-compiled to clear things up for the changes to take effect.

Now you can try dd(app('helpers')) anywhere where the 'IoC' container is available (e.g. in a controller).

You can also use it in constructor injection like this:

    public function __construct(Helper $helper)
    {
        $this->helper= $helper;
    }

And now you can call any function in your helper class like this:

$returnedResult = $this->helper->yourFunctionInHelperClass();

// In example case
$returnedResult = $this->helper->sayHello();    // 'Hello'

Don't forget to import your classes with the use statement on top of file.

EventFellows left a reply on Anybody Using Vuetify?

Vuetify looks great, indeed.

But just to mention: there are otheres to discover, too (hard to make an informed decision)

https://github.com/vuejs/awesome-vue#responsive

Especially Vue-Material and element Ui seem very similar.

EventFellows left a reply on Route Not Going Where It's Supposed To

I don't know your 'caffeinated module' but that should not alter the way laravel treats the order of routes.

Just get them into the right order and it should work.

19 Jun
2 years ago

EventFellows left a reply on Sending An Email To Multiple Users

what is not working? looks ok despite hardcoding the admin in that method.

you can also put in an email directly to the CC.

you might want to think about queing for performance reasons.

EventFellows left a reply on How To Create Model Relation On Array Field

have a look at the documentation. it tells you how to use it with example.

EventFellows left a reply on Can I Change The Text Colour In Sweet Alert Box When Call Alert Inside A Controller?

Check your Alert Class and see what arguemnts the error method accepts.

EventFellows left a reply on Route Not Going Where It's Supposed To

Try to comment out this section Route::get('/{category}/{slug}' and it shoudl work.

If that is the case it is a question of order. Laravel will return the first route that matches the pattern.

EDIT

I did not read all the way to the end, sorry.

Just put your Route::resource('admin/menus', 'MenusController'); above the other routes in the same file. Or, if it is in different files make sure the order in which the files are loaded is changed (more complicated)

EventFellows left a reply on Custom Sidebar

Well, then just do the following:

  • Create a new folder within App by the name of Something
  • Within that folder create a Something.php file that contains class Something and implement any method you like
  • also in that folder create a SomethingServcieProvider.php (use artisan make for it to get the correct setup)
  • go to your config/app.php and register the Service Provider there as all other service providers are registered (the order matters, most likely there is a place that says, 'do it here for packages')
  • run php artisan clear-compiled and composer dump-autoload

You should be able to use your Something class e.g. in a controller via constructor injection now.

So now all your functionlity is 'encapsulated in your something folder'.

EventFellows left a reply on Vue Powered Collapsable Sidebar Menu

Anyone?

Maybe even using vuetifyjs or any other of the responsive fronend packages mentioned here: https://github.com/vuejs/awesome-vue#responsive

EventFellows left a reply on How To Create Model Relation On Array Field

You'd have to use the ->whereIn() method but really not recommended for the reason also @Bramr stated.

EventFellows left a reply on Homestead

I remember that this pages also included detailed instruction on how to setup homestead on different machines.

I blieve you have to register, but it has a free version: https://learninglaravel.net/laravelbook

I found it quite easy to understand way back (they might have changed it since then)

EventFellows left a reply on Laravel Batch Insert With Multiple Relations.

Do you mean, 3000 rows in database or 3000 tables?

If rows, that should not be any issue, maybe some seconds of runtime I would guess... And you only need to run it once not for user requests.

EventFellows left a reply on Can I Change The Text Colour In Sweet Alert Box When Call Alert Inside A Controller?

swal({
  title: "HTML <small>Title</small>!",
  text: "A custom <span style="color:#F8BB86">html<span> message.",
  html: true
});

EventFellows left a reply on Laravel 5 How To Store The Publish Timestamps When User Click The Publish Button

Depending on what other options a user has you might also be able to just use the existing updated_at timestamp which reflects the last time the DB entry was changed - and setting it to 'published' is a change.

But that depends on your setup. If a user can also edit your post and he edits an published post and keeps it published, the field would contain the last edited timestamp.

If you need a sperate column go with @CodeByRay's suggestion, but I'd use Carbon (Read up on it if you are not familar, it's quick and easy and makes your life much easier)

public function published($id)
{

    $post = \App\Post::find($id);
    $post->published_at = Carbon::now();
    $post->save();

    return redirect('/');

}

You have to $casts your published_at field to carbon, then.

EventFellows left a reply on Can I Change The Text Colour In Sweet Alert Box When Call Alert Inside A Controller?

there is an 'html' property that you need to set to true if you want to use html on SweetAlert.

But that is needed both for calling from controller and from js directly.

EventFellows left a reply on Laravel Batch Insert With Multiple Relations.

Why would you not loop over each user to handle the whole 'migrating of data' for a user in one go and then proceed with the next?

This way, you could just abort if something goes wrong and fix it.

17 Jun
2 years ago

EventFellows left a reply on Custom Sidebar

a service provider is just a way to encapsulate some service or functionality and register it with laravel.

you don't have to use it in this case, you could also use a config file for example or just define your menu items on a property of the menu class.

EventFellows left a reply on Laravel Directory Not Created

please format your code in readable way and state your question. link is below input field.

EventFellows left a reply on How To Create Model Relation On Array Field

You probably could but the question is: WHY would you want to do that?

That sounds like using the database in a not very databasey way... What are you trying to achieve?

EventFellows left a reply on Passing In A String Not An Instance

Well you typehint this hasPermission(Permission $permission) so whenever you call that function it will require an instance of Permission.

So if you call hasPermission('create_venue') this will not work because you pass in a string.

Assuming you have a permissions table and a Permission model try this:

$permission = Permission::where('your_collumn_name', 'create_venue')->first();
return $user->hasPermission($permission);

```
15 Jun
2 years ago

EventFellows left a reply on Route Parameters With Named Route

what is your question?

a route parameter and a query string are two fundamentally different things...