Moe

Moe

Member Since 5 Years Ago

Experience Points 26,100
Experience Level 6

3,900 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 368
Lessons
Completed
Best Reply Awards 6
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.

12 Sep
4 days ago

Moe left a reply on Js History.pushState

It look like a caching problem.

fixed it by making a second route pointing to the same controller.

Route::get('/tickets', '[email protected]')->name('ticket.index');
Route::get('/api/tickets', '[email protected]')->name('api.ticket.index');

Moe started a new conversation Js History.pushState

I'm building a filter for an overview of tickets, these tickets are loaded with ajax. When I check some boxes in the filter menu, I will change the URL without reloading.

history.pushState(null,null,this.uri);

This is no problem! But after that when i show a ticket and return to the overview page, i get an ajax response and not the regular page.

This is my index function on my controller:

public function index(TicketFilters $filters)
    {
        $tickets = Ticket::filter($filters)->get();

        if (request()->expectsJson()) {
            return $tickets;
        }

    .....

        return view('tickets.index', compact('tickets', 'channels', 'statuses'));
    }

What's the problem?

27 Aug
2 weeks ago

Moe left a reply on Foreign Key Error

How can it be that simple!

Moe started a new conversation Foreign Key Error

Keep getting an error, and I don't see what's wrong.

code:

Schema::create('channels', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('parent_id')->unsigned()->nullable();
            $table->string('name');
            $table->timestamps();
});

Schema::table('channels', function (Blueprint $table) {
            $table->foreign('parent_id')->references('id')->on('channels');
});

error:

SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL: alter table `channels` add constraint `channels_parent_id_foreign` foreign key (`parent_id`) references `channels` (`id`))
15 Aug
1 month ago

Moe left a reply on Email Host

Nice, they have recently added this functionality

Moe left a reply on Email Host

I also need a mailbox

Moe started a new conversation Email Host

Hi,

I'm using digital ocean to host my websites. But i'm still searching for a good e-mail host platform. Which one do you use?

Grtz!

30 May
3 months ago

Moe left a reply on Component Props And Url

@EDOC - Thanks!

Moe left a reply on Component Props And Url

as in the error above it returns http://site.test/post

Moe left a reply on Component Props And Url

@MAVERICKCHAN - The problem is in de URL string. It looks like the special chars are not allowed.

Moe left a reply on Component Props And Url

@MAVERICKCHAN - It's just as example. There is a closing tag!

Moe started a new conversation Component Props And Url

Is there a way to pass an URL as parameter for a vue component?

<edit-post-modal :categories="{{ $categories }}" :post="{{ $post }}" :actionPath="{{ route('post.store') }}">

results in error

invalid expression: Unexpected token : in
http://site.test/post

  Raw expression: :actionpath="http://site.test/post"
20 Sep
11 months ago

Moe left a reply on Mysql

You can add this without any problems.

13 Apr
1 year ago

Moe left a reply on Is Necessary To Create Model For Every Table?

Like you say, it's not necessary to create models for your pivot tables.

Here you can find al the needed information.

28 Mar
1 year ago

Moe left a reply on Primary Key

From the docs

Eloquent will also assume that each table has a primary key column named id. You may define a protected $primaryKey property to override this convention. In addition, Eloquent assumes that the primary key is an incrementing integer value, which means that by default the primary key will be cast to an int automatically. If you wish to use a non-incrementing or a non-numeric primary key you must set the public $incrementing property on your model to false. If your primary key is not an integer, you should set the protected $keyType property on your model to string.

class Pemesanan extends Model { 
    protected $table = 'pemesanan'; 

    protected $primaryKey = 'No_Pemesanan';
}

Moe left a reply on Reload A Component

Make use of custom events.

The example in the documentation is pretty clear for me.

20 Mar
1 year ago

Moe left a reply on Transactions

You need to use DatabaseMigrations instead of DatabaseTransactions

19 Mar
1 year ago

Moe left a reply on Where Are You All From?

Belgium

14 Mar
1 year ago

Moe left a reply on Multiple Templates With Different Styles

fix it with props

<app :css="pathToStylesheet">
12 Mar
1 year ago

Moe left a reply on Mobile Application Solution?

There is no problem, because the vue components return normal html code.

See this view documentation.

19 Aug
2 years ago

Moe started a new conversation Polymorphic Eager Loading

This is my problem.

I'm trying to grab all activities on the activity table and eager load the subject.

models:

  • activity (polymorphic)
  • favourite (polymorphic)
  • route
  • wall
return Activity::with('subject')->latest()->get();

It works well for the route and wall table, but the favourite table is also polymorphic and must return objects with route and wall subjects in it. Because the route and wall model don't have a subject method, it's not possible to do something like this:

return Activity::with(['subject', 'subject.subject'])->latest()->get();

I tried to fix it by adding the $with attribute at the favourite model, but that returns an internal server error. (I guess it's something with a loop)

Is there a way to do an extra with only for the subject type App\Favourite?

17 Aug
2 years ago

Moe left a reply on Eager Loading Polymorphic Nested Relations?

You already figured out how to handle this? I am dealing with the same issue.

17 Mar
2 years ago

Moe left a reply on Migration Error

Do you drop the table in you down method of your migration file?

    public function down()
    {
        Schema::drop('voter_attandances');
    }
24 Feb
2 years ago

Moe left a reply on [5.4] Npm Run Watch Not Working

Run "npm run watch" on your local machine helped for me!

16 Jan
2 years ago

Moe left a reply on Vagrant Up SSH Issues

Strange, I updated my Virtualbox but it wasn't 5.1.12.

Now it works!

Thanks both!

15 Jan
2 years ago

Moe started a new conversation Vagrant Up SSH Issues

I'm trying to start a new project, but it looks like vagrant doesn't like that idea. Every time I run "vagrant up" it get's stuck on the SSH part of the process. Nothing changed on my dev machine, so i don't understands what's the problem.

Other people with the same issues?

For the record, I use the per project homestead installation

23 Dec
2 years ago

Moe started a new conversation Add Data To Props Data

Is there a way do add some extra data into an objects array within a Vue component?

example input:

array:2 [▼
  0 => array:3 [▼
    "id" => 5
    "token" => "QbOilQ"
    "name" => "Samsonbury"

  ]
  1 => array:3 [▼
    "id" => 6
    "token" => "t4PGiO"
    "name" => "South Angelicaton"
  ]
]

example result after adding some data:

array:2 [▼
  0 => array:3 [▼
    "id" => 5
    "token" => "QbOilQ"
    "name" => "Samsonbury"
    "checked" => false
  ]
  1 => array:3 [▼
    "id" => 6
    "token" => "t4PGiO"
    "name" => "South Angelicaton"
    "checked" => false
  ]
]
29 Jul
3 years ago

Moe left a reply on Homestead - MariaDB

Ok, i replaced the homestead folder (vendor/laravel/homestead) with a clone of the master repo and now it works!

@bashy: Thank you for showing me the way!

Moe left a reply on Homestead - MariaDB

I don't work with the vagrant box, I just have an instance for each project.

☁  homestead [master] git pull
Already up-to-date.

Moe started a new conversation Homestead - MariaDB

Yesterday I've tried to make a Homestead Server with MariaDB installed on it. I just followed the documentation but it will not work. Every time i run vagrant up, I receive the next log

==> default:  mariadb-server : Depends: mariadb-server-10.1 (= 10.1.16+maria-1~trusty) but it is not going to be installed
==> default: E
==> default: :
==> default: Unable to correct problems, you have held broken packages.
==> default: /tmp/vagrant-shell: line 42: /etc/mysql/my.cnf: No such file or directory
==> default: sed: can't read /etc/mysql/my.cnf: No such file or directory
==> default: /tmp/vagrant-shell: line 48: mysql: command not found
==> default: Failed to restart mysql.service: Unit mysql.service not found.
==> default: /tmp/vagrant-shell: line 51: mysql: command not found
==> default: /tmp/vagrant-shell: line 52: mysql: command not found
==> default: /tmp/vagrant-shell: line 53: mysql: command not found
==> default: /tmp/vagrant-shell: line 54: mysql: command not found
==> default: Failed to restart mysql.service: Unit mysql.service not found.
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

Who knows whats going wrong?

16 Nov
3 years ago

Moe left a reply on Finfo::buffer()

Problem fixed by updating the package spatie/laravel-medialibrary

Moe started a new conversation Finfo::buffer()

An ajax call to this method

public function sortPhotos($id, Request $request)
{
        $portfolio = Portfolio::findOrFail($id);

        DB::transaction(function () use ($portfolio, $request) {
            foreach ($request['image'] as $k => $photo) {
                $photo = $portfolio->media()->findOrFail($photo);

                $photo->update(['order_column' => $k]);
            }
        });

        return 'Done';
}

returns the next error:

ErrorException in MimeType.php line 26:
finfo::buffer() expects parameter 1 to be string, resource given

I don't have any clue what can be the problem.

12 Oct
3 years ago

Moe left a reply on Policy On Create

No one?

09 Oct
3 years ago

Moe started a new conversation Policy On Create

With the code below i will check if a user has the rights to create a new post object, but even when I return TRUE the link will not show up. What am I doing wrong?

view:

@can('create-post')
    <a>new post</a>
@endcan

PostPolicy.php

<?php

namespace App\Policies;

class PostPolicy
{
    public function create()
    {
        return TRUE;
    }
}

AuthServiceProvider:

<?php

namespace App\Providers;

use Illuminate\Contracts\Auth\Access\Gate as GateContract;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;

class AuthServiceProvider extends ServiceProvider
{
    /**
     * The policy mappings for the application.
     *
     * @var array
     */
    protected $policies = [
        Post::class => PostPolicy::class,
    ];

    /**
     * Register any application authentication / authorization services.
     *
     * @param  \Illuminate\Contracts\Auth\Access\Gate  $gate
     * @return void
     */
    public function boot(GateContract $gate)
    {
        parent::registerPolicies($gate);
    }
}
````

24 Sep
3 years ago

Moe left a reply on Flash Message When Validation Fails (using FormRequests)

@MThomas how did you fixed it, by checking for errors in the controller?

10 Sep
4 years ago

Moe left a reply on Route::list And Authorization

So if you will grant access to all abilities, you are screwed and can't use "php artisan route:list" anymore?

09 Sep
4 years ago

Moe left a reply on Publishing Posts In The Future On A Specific Date And TIme.

Write a console command that gets the posts that should be published "today" and let it mail to they who will receive information like that. Next you schedule this command once a day.

Moe started a new conversation Route::list And Authorization

I implemented some authorization into my project. But now the route:list command gives the following error: "This action is unauthorized"

BaseController.php

...
    public function __construct()
    {
        parent::__construct();
        
        $this->authorize('admin');
    }
...

AuthServiceProvider.php

...
    public function boot(GateContract $gate)
    {
        parent::registerPolicies($gate);

        $gate->before(function ($user, $ability) {
            if ($user->isAdmin()) {
                return true;
            }
        });
    }
...

Is there a way to ignore the authorization for route:list?

03 Sep
4 years ago

Moe started a new conversation FormBuilder And Json Data

I followed next lesson https://laracasts.com/lessons/managing-mass-user-settings and tried to make it work with the FormBuilder.

Is there a way to put a setting of the json field into a formfield?

This will not work

{!! Form::text('settings[address]', null, ['id' => 'address', 'class' => 'form-control', 'required']) !!}
02 Sep
4 years ago

Moe left a reply on SoftDelete And Cascade

@pmall that does the trick!

Moe left a reply on SoftDelete And Cascade

Yeah it make sense, but it should be nice that when the "deleted_at" field of the parent is set, that that same field of his child's will also be set when the relation is set "cascade on delete".

Moe left a reply on SoftDelete And Cascade

I already have that, but it does not work when using softdeletes.

Moe started a new conversation SoftDelete And Cascade

Is there a way to 'delete' (softdelete) or 'set null' related models when deleting (softdelete) the parent model automatically?

31 Aug
4 years ago

Moe left a reply on Validation: Unique Combination

@pmall ok this works, but only when i use it like this

return ['name' => 'required|unique:clients,name,' . $this->clients . ',id,user_id,' . Auth::id()];

Thanks @pmall and @veve286

Moe left a reply on Validation: Unique Combination

@pmall it works on the create action, but not when i update.

Moe started a new conversation Validation: Unique Combination

I don't have any clue how to implement the unique validation with additional where clauses

public function rules()
    {
            return ['name' => 'required|unique:clients,name,NULL,' . $this->get('id') . ',user_id,' . Auth::user()->id];
    }

The rule from above gave me the next error: "The name has already been taken."

I'm not sure that i understand it very well, but this rule should validate if the combination of name and user_id is unique.

It should be nice if it's one rule for create and update.

25 Aug
4 years ago

Moe left a reply on Authentication Based On Url

You don't need 2 logins, just have 1 and redirect based on the return param like i mentioned above.

When you're not logged in:

domain.com/backend   => domain.com/login?return=http://domain.com/backend
domain.com/product/test-product  => domain.com/?return=http://domain.com/product/test-product

Moe left a reply on Authentication Based On Url

You can do it like Jeffrey is doing it on this site, redirect back to the page where you came from:

https://laracasts.com/login?return=https://laracasts.com