tha07

tha07

Member Since 1 Year Ago

Experience Points
2,550
Total
Experience

2,450 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
20
Lessons
Completed
Best Reply Awards
0
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.

Level 1
2,550 XP
Aug
11
2 months ago
Activity icon

Started a new conversation Editing An Already Happened Transaction

I'm building an online grocery app which records the inventories and sales.

I want to include the update sales transaction feature.

when recording sales transaction I create a sales record with the products that purchased., and also deduct the product available count in the database.

But in the update transaction, the counts needed to be changed again? I'm a bit confused. How to handle this? Or my approach wrong?

Jun
26
3 months ago
Activity icon

Started a new conversation Saving Multiple Records In One To Many

I have users table and addresses table which has an one to many relationship.

When a user is created users details and address(multiple addresses each having postal code, street, city etc) details are needed to be added to the two tables.

So 1. Create user, 2. Add addresses referencing the created user_id.

I have done the first step.

    $user->name = $request->input('name');
    $user->contact = $request->input('contact');
    $user->email = $request->input('email');
    $user->save();

How can I do the second one.

addresses table

    id | user_id | postal_code | city | street

addresses request example

    [
        {"postal_code" : "test a", "city" : "test aa", "street":"test aaa" },
        {"postal_code" : "test b", "city" : "test bb", "street":"test bbb" },
        ...
    ]

Thank you!

Apr
13
6 months ago
Activity icon

Started a new conversation Validating Nested Array Of Objects

I have a nested array of objects that each object needed to be validated. The request array look like this.

{
    "total" : 250.00,
    "merchant_id" : 1,
    "discount" : 0,
    "items" :  {
        [id: 1, quantity: 25, notes: "some string A"],
        [id: 2, quantity: 10, notes: "some string B"],
        [id: 3, quantity: 5, notes: "some string C"]
    }
}

I know how to validate a nested array. but this has array of objects that each one needed to be validated. how can this be done through Laravel?

Feb
26
7 months ago
Activity icon

Replied to Using UUIDs Over Auto Increment

@DARIUSIII - Thank you. I'll check this out :)

Activity icon

Replied to Using UUIDs Over Auto Increment

@BOBBYBOUWMANN - Thank you. Yep. I have not done in any projects. Maybe I should start from this one :)

Activity icon

Started a new conversation Using UUIDs Over Auto Increment

I have an admin and guest interface in my application. If I want to implement UUIDs only for guest interfaces what is the approach? Or do I need to stick with auto increment IDs. (Guest interfaces will only include "get" requests)

Feb
24
7 months ago
Activity icon

Replied to Prompt To Change Password If Default Password

@ORION - Hi Orion. I have guest and admin user types. will it not be a problem when dealing with several user types?

Activity icon

Started a new conversation Prompt To Change Password If Default Password

I'm creating a function to check the authenticated users password with the app's default password and prompt user to change password.

I think the best way is to do it via a middleware. But was not able to achieve it.

How can I check it from a middleware and redirect user to a specific route to force to enter a password

Jan
12
9 months ago
Activity icon

Started a new conversation My First Big App - Controller Issue

Hi, I'm new to Laravel and loving it. I'm on my way to create my first big app for a laboratory. I'm in the plan stage and have this issue.

I have planned several tables. customers, tests, customer_tests, test_properties, customer_test_property_results

Example for a test is "high blood pressure". Each test have several properties like white blood cell count, red blood cell count with there necessary max values and min values. this properties vary according to the test.

After customer register for a test and the test is done by the lab, the test results are entered by the app. I will create this form with every test property to enter there respected values.

The problem is How can I validate the form data? The form values are varying with each test types. So the controller function which test data results are validating don't know what test is coming to do the validations. Is there any dynamic way to do this?

Oct
01
1 year ago
Activity icon

Started a new conversation Problem In Structuring Models, Controllers And Tables

Let's say I have Clients and Tests tables. A client will register for many tests. And keep registering for the same test again. So I create a client_test table. The normal procedure I use is creating a model called ClientTest and also a controller for model as ClientTestController. Also a route named clienttest to implement the crud functionalities for the table.

Is it the best practice or is there any better way to handle it?

Sep
29
1 year ago
Activity icon

Replied to Route For Different User Types

Thank you :)

Activity icon

Started a new conversation Route For Different User Types

I have a project that is been setup for middleware as this way. This routes are available only for role 1 user role. I want them available for both role 1 & 2 user roles.

I tried adding 'auth', 'Role:1', 'Role:2' but it didn't work

my routes\web.php file

Route::group(['prefix' => ADMIN, 'as' => ADMIN . '.', 'middleware'=>['auth', 'Role:1']], function() {
    Route::get('/', '[email protected]')->name('dash');
    Route::resource('users', 'UserController');
    Route::resource('businesses', 'BusinessController');
});

my App\Http Kernal File

protected $routeMiddleware = [
    ...
    'Role' => \App\Http\Middleware\Role::class,
];

my App\Http\Middleware Role File

public function handle($request, Closure $next, $role)
    {

        // Not Logged
        if (!Auth::check()) {
            return redirect('/login');
        }

        // Not allowed
        if ($request->user()->role != $role) {
            return abort(404);
        }

        return $next($request);
    }
Sep
28
1 year ago
Activity icon

Replied to Can You Explain This Code

Thank you very much

Activity icon

Replied to Can You Explain This Code

what is the $role here?

Activity icon

Replied to Can You Explain This Code

In Kernal.php I have,

protected $routeMiddleware = [
    ...
    ...
    'Role' => \App\Http\Middleware\Role::class,
];

In Role.php I have,

public function handle($request, Closure $next, $role)
    {
        // Not Logged
        if (!Auth::check()) {
            return redirect('/login');
        }

        // Not allowed
        if ($request->user()->role < $role) {
            return abort(404);
        }
        return $next($request);
    }
Activity icon

Started a new conversation Can You Explain This Code

I have this code in the routes web file. I find it difficult to understand.

Route::group(['prefix' => 'admin', 'as' => 'admin'. '.', 'middleware'=>['auth', 'Role:0']], function() {
    Route::get('/', '[email protected]')->name('dash');
    Route::resource('users', 'UserController');
});

Does it mean that the Role 0 users only have the access to the following Routes?

Sep
22
1 year ago
Activity icon

Replied to $ Is Not Defined - Jquery Not Found

thank you for your feedbacks. I think I should read more about mix. Actually this is a template. I go this error while compiling it. Manged to solve it by importing jquery in the app.js file like this.

import $ from 'jquery';
window.jQuery = $;
window.$ = $;
Activity icon

Replied to $ Is Not Defined - Jquery Not Found

@hollyit

here how my bootstrap.js file looks like.

import './masonry';
import './charts';
import './popover';
import './scrollbar';
import './search';
import './sidebar';
import './skycons';
import './vectorMaps';
import './chat';
import './datatable';
import './datepicker';
import './email';
import './fullcalendar';
import './googleMaps';
import './utils';
import './sweetalert2';
import './select2';

so you're telling that i have to add jquery to this file?

Activity icon

Replied to $ Is Not Defined - Jquery Not Found

It still doesn't work

Activity icon

Started a new conversation $ Is Not Defined - Jquery Not Found

In my Laravel project (laravel 5.6) I installed Jquery from npm. Then I added it to webpack.mix.js.

mix.webpackConfig(webpack => {
    return { plugins: [new webpack.ProvidePlugin({
                $: "jquery",
                jQuery: ["jquery", "$"],
                "window.jQuery": "jquery",
                Popper: ["popper.js", "default"]
            })] };
});

after compiling the assets and trying to use jquery it shows

"Uncaught ReferenceError: $ is not defined"

I am using my custom JavaScript file after loading the mix file in my view.

<script src="{{ mix('/js/app.js') }}"></script>
<script type="text/javascript" src="/js/tests/tests.js"></script>

In my custom JavaScript file I added the following code to check Jquery.

$("#myCheckButton").click(function(e) {
  console.log(test);
});

I tried changing the webpack.min.js webPackconfig settings but was not able to solve it. Most questions like this recommended to put the custom js files after the mix. I think I got it right in my case