ksungcaya

ksungcaya

Member Since 4 Years Ago

Experience Points 28,505
Experience Level 6

1,495 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 295
Lessons
Completed
Best Reply Awards 8
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.

06 Feb
2 years ago

ksungcaya left a reply on Best Approach To Get Permissions In An Acl

there's a good package that uses laravel's native ACL. you might want to look at this

https://github.com/spatie/laravel-permission

02 Feb
2 years ago

ksungcaya left a reply on Issue With Boolean Field When Migrating With Mysql

@bigboss

tried just now. I have a migration like this

public function up()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->boolean('is_logged_in')->nullable()->default(0);
        });
    }

and I've quickly run this in tinker

factory(App\User::class)->create(['is_logged_in' => null]);

it creates a user record with NULL value on is_logged_in field and not **0**. Not sure about the difference of their behavior but on my understanding, as long as a field is not nullable you wont be able to insert a null value on it. And in database perspective null value is different from an int or string value.

ksungcaya left a reply on Cannot Override FROM Mail Address

If you're using Mailable class you can modify from on the build() method.

look here: https://laravel.com/docs/5.4/mail#writing-mailables

ksungcaya left a reply on Issue With Boolean Field When Migrating With Mysql

@bigboss I think because you're boolean field is not nullable hence the error when you're trying to put null value on it.

btw I have to correct my answer although putting a value in the checkbox will do the trick, you can simplify your creation if you use has method rather than casting it to boolean like this.

Client::create([
    'name' => request('name'),
    'phone' => request('phone'),
    'has_whatsapp' => request()->has('has_whatsapp')
]);

ksungcaya left a reply on Issue With Boolean Field When Migrating With Mysql

boolean will be converted to tiny int so using it is fine.

Try putting a value attribute on your checkbox like 1 or true. And if you want to make sure, before saving it, cast the value to boolean..

Client::create([
    'name' => request('name'),
    'phone' => request('phone'),
    'has_whatsapp' => (bool) request('has_whatsapp')
]);
01 Feb
2 years ago

ksungcaya left a reply on Carbon "overflow" Dates

if you're using subMonths you might want to call subMonthsNoOverflow method. Not sure if the order of call matters but it returns the instance so you could experiment.

I haven't tried it but I think it would work.

31 Jan
2 years ago

ksungcaya left a reply on Laravel/scout Installation Error

version 3.0.0 of laravel/scout requires laravel 5.4 dependencies. You might want to update your composer.json to use version 2.0.2 of laravel scout if you're using laravel 5.3.

"laravel/scout" : "^2.0",

ksungcaya left a reply on Model Factory Seeding Not Working In Laravel 5.4.

@somenet77 have you tried putting it in the DatabaseSeeder class instead? Is the BlogTableSeeder namespaced?

30 Jan
2 years ago

ksungcaya left a reply on Model Factory Seeding Not Working In Laravel 5.4.

By default, php artisan db:seed looks for DatabaseSeeder class which is in database/seeds folder. If you want to run all your seeds put the call of the seeder class in the run method of DatabaseSeeder class.


<?php

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $this->call(BlogTableSeeder::class);
        // your other seeder classes
    }
}

or if you want to specifically run your BlogTableSeeder, run the seeder command like this:

php artisan db:seed --class="BlogTableSeeder"
26 Jan
2 years ago

ksungcaya left a reply on Help Optimizing My Eager Load

are you running your code inside a loop? what about the parent_id relationship? The query seems to be comparing with a parent_id but your code did not pass any parent_id parameter.

ksungcaya left a reply on Run Migrations To Another Database Doesn't Seem To Work With 5.4

could you show your connections config in database.php?

ksungcaya left a reply on Can't Getting Access Token Passport Oauth/token

does your redirect_uri exists? and what's the output when you dd($response_body); ? what do you get from $response? do you have curl enabled?

24 Jan
2 years ago

ksungcaya left a reply on Passport Login Failed Response 500 Internal Server

500 error could be the code or server breaking.

If you provided wrong credentials in passport it will return this response:

{
  "error": "Unauthenticated."
}

ksungcaya left a reply on Call To Undefined Method RouteNotificationFor() While Sending Email To Multiple Users

When sending notifications via the mail channel, the notification system will automatically look for an email property on your notifiable entity. You may customize which email address is used to deliver the notification by defining a routeNotificationForMail method on the entity:

https://laravel.com/docs/5.3/notifications#customizing-the-recipient

Can you confirm if the friends collection has email property on each entity? otherwise you should create a routeNotificationForMail and return the property that holds the email value of the friend entity.

ksungcaya left a reply on Can't Getting Access Token Passport Oauth/token

If you followed this video you should have it running as expected.

https://laracasts.com/series/whats-new-in-laravel-5-3/episodes/13

Also I believe guzzle removed the json() method so what you could do to get the response is this

return json_decode((string) $response->getBody(), true);

and remove the Laravel53 route if it's not registered. :)

ksungcaya left a reply on How I Can Allow Users To Set Their Own Urls For RedirectTo And RedirectAfterLogout From Config Value

@giwrgos could be a different issue. Maybe it's not an intended route to be redirected to because the config says it points to core_game.admin-prefix.

Can't really help you with only those bits of codes. sorry.

23 Jan
2 years ago

ksungcaya left a reply on Can't Getting Access Token Passport Oauth/token

Is there really a route with Laravel53 prefix in your route list?

http://localhost:8000/Laravel53/oauth/token

ksungcaya left a reply on Set To Null $request->user Using Passport

I mean revoking the token by calling a DELETE request on this route:

/oauth/tokens{token_id}

ksungcaya left a reply on How I Can Allow Users To Set Their Own Urls For RedirectTo And RedirectAfterLogout From Config Value

why don't you assign the values in the constructor instead?

protected $redirectTo;
protected $redirectAfterLogout;

public function __construct()
{
    $this->redirectTo = config('core_game.login-prefix');
    $this->redirectAfterLogout = config('core_game.admin-prefix');
}
22 Jan
2 years ago

ksungcaya left a reply on Set To Null $request->user Using Passport

Maybe there's a better way but what if you logged out the user after doing the assertion for that specific user?

21 Jan
2 years ago

ksungcaya left a reply on API And Web Controller Method

You can check if it is ajax request with the request object like so:

public function store(CreateOrderRequest $request)
{
        
    $order = Order::create($request->all());

    //Store order into TB
    $order->save();

    if ($request->ajax()) {
        return response()->json($order);
    }
        
    //If submitted by web form redirect to an url
    return redirect('/oneway');
}
        

But if you know you're api is going to change some time in the future I suggest using a dedicated route with /api/{version} prefix on it. or if the api's consumer is only your application then I think you're good with your first approach.

ksungcaya left a reply on Storing Photos And Data From A Form At Same Time

There are two ways I'd do in this situation.

  1. Have a separate form for the event data and then redirect to adding photos of that event after event creation. Or maybe dropzone area won't appear until I created an event.

  2. Instead of automatically processing the queue of dropzone, defer the process and then when I submit the form, call the event creation method then respond with success and the event_id or something then on my javascript onSuccess append the event_id to each photo then start processing the queue.

http://www.dropzonejs.com/#config-autoProcessQueue

PS: Sorry for the pseudo codes. :)

19 Jan
2 years ago

ksungcaya left a reply on Checkbox Is Checked Validation

@go you're welcome. Please mark this thread as answered if your problem has been resolved. cheers!

ksungcaya left a reply on Requests & Rules

@toneee I updated the link. My bad. :D

ksungcaya left a reply on Checkbox Is Checked Validation

From laravel docs: https://laravel.com/docs/5.3/validation#creating-form-requests

/**
 * Store the incoming blog post.
 *
 * @param  StoreBlogPost  $request
 * @return Response
 */
public function store(StoreBlogPost $request)
{
    // The incoming request is valid...
}

maybe you could also try dumping the request data if the request contains the checkbox name.

Also try other acceptable values if it still doesn't work.

$acceptable = ['yes', 'on', '1', 1, true, 'true'];

ksungcaya left a reply on Checkbox Is Checked Validation

are you perhaps using FormRequest ? If so, you should type hint that on the route/controller method.

And make sure the authorize() method returns true always if you're not verifying anything before the validation.

ksungcaya left a reply on Return Response From Model?

To answer the original question, no it is not possible to return a response directly from the model.

If you're calling a method from a model that returns a response it will just return a response object to the controller.

ksungcaya left a reply on Return Response From Model?

why not use the validate method of the controller instead?


public function store(Request $request)
{
    $this->validate($request, [
        'email' => 'required|email',
    ]);

    // create model here
}

https://laravel.com/docs/5.3/validation#quick-writing-the-validation-logic

ksungcaya left a reply on Modify ResetsPasswords.php

If you're using 5.3 and you only want to modify one method, I think you can get away of overriding it in the ResetPasswordController.

Other options could be importing your own ResetsPasswords trait or creating your own ResetPasswordController. These options won't get overridden when you install the framework.

ksungcaya left a reply on Mail Configuration

have you tried restarting your server after changing .env config?

might as well run

php artisan config:clear

to clear the config cache.

ksungcaya left a reply on Loop Object Array In Blade

The error says the $books variable is an array and not a collection object. If you're looping through an array you can access the attributes like this:

$books['id'] //...

ksungcaya left a reply on How To Check InstanceOf $object In Blade Template?

instanceof checks the full class name. If your model has a namespace then you should use the fqdn of the class something like this:

$object instanceof App\Model

ksungcaya left a reply on How To Set Dynamic Route Prefix To All URL After User Logged Into The Application?

The link I gave has the answer that points to here

http://stackoverflow.com/questions/34616869/set-database-connection-and-language-dynamically-in-laravel/34617877#34617877

which gives the idea to create middleware to modify the request. I guess this is one option.

18 Jan
2 years ago

ksungcaya left a reply on How To Get The Last Child Of A HasMany Relationship For All Parents

i believe you can do an eager load when fetching the hives like so:

Hive::with('measures', function($query) {
    return $query->latest()->first();
})->get();

not 100% sure if that will work, not tested.

ksungcaya left a reply on How To Get The Last Child Of A HasMany Relationship For All Parents

App\Measure is only one-to-many relationship that means you wont be able to call measures() from a collection of $hives

ksungcaya left a reply on Laravel Homestead - Installation - Timeout

@safi24 please mark the thread as answered if your problem has been resolved. cheers!

ksungcaya left a reply on Laravel Homestead - Installation - Timeout

update your vagrant and virtualbox :)

02 Jul
4 years ago

ksungcaya left a reply on Rotate Images From Ios

If you are using an image manipulation package like intervention/image you can use its orientate() method.

// instantiate image with auto-orientation
$img = Image::make('foo.jpg')->orientate();

http://image.intervention.io/api/orientate