Crazylife

Member Since 4 Years Ago

Experience Points
12,860
Total
Experience

2,140 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
4
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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.

  • Community Pillar

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

Level 3
12,860 XP
Jun
11
1 day ago
Activity icon

Started a new Conversation Why Unable To Access The Global Function In Vuelidate Message?

I have a global translate function imported in my app.js.

export default {
    methods: {
        __(key, replace = {}) { ... }
	}
}

--

validations: {
        form: {
            name: {
                required: helpers.withMessage(this.__('common.name'), required),
            },
        }

It works fine in other method but i just can't use it to translate message in validations. It shows undefined __

I am using Vuelidate package and the error as shown below

Uncaught TypeError: Cannot read property '__' of undefined
    at Module../node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/app/views/auth/SignUpProfile.vue?vue&type=script&lang=js 
Jun
03
1 week ago
Activity icon

Replied to How To Setup Microservices In Laravel?

Alright, thanks guys for the valued feedback!

Jun
02
1 week ago
Activity icon

Replied to How To Setup Microservices In Laravel?

Alright, so meaning that if we can do it in monolithic way then it's better just stick to it for this cases. Where micro-services take places only if services can be independent and not belong to each other. Thus, will need to call multiple API just to get a single resource which is expensive.

But then if apply on login services, mail services... still acceptable? Is it because if the services too dependent on each others then it's better not to separated them "into smaller, multiple apps". Are we still allowed to like passing an id and get data from a service (e.g. to check user profile, user is a service and is independent)?

Activity icon

Replied to How To Setup Microservices In Laravel?

Sorry, maybe I am wrong.

From what i know here, let's take an example like simple blog app

I separated into 3 backend microservices which are posts, users, comments.

These 3 backend microservices are small laravel application.

In Posts service will consist only posts and user_id and everything just related to post. In Users service just basically to store the user details. In Comments service will consist only comment details and post id.

When i want to get a response with data of post, user, comment, then i need to call these services from my controller and return to my frontend.

CMIIW, I am not sure if this is right. Do you have any resources to share / sample output with description where can help to understand the implementation better if my concept was wrong. Appreciated it, thanks.

Activity icon

Replied to How To Setup Microservices In Laravel?

Great, thanks. I am not sure how big it will grows. But, definitely will more than Admin, customer, product & services, order etc.

So in this case, better to stick with laravel relations, and migrate to microservices if needed in future?

And running microservices could be quite expensive right?

And also would like to know how would it looks like if implemented as microservices. As what i know so far, every services is a laravel application then with it own database and store related data and using ID to connect each other. Am i right?

Activity icon

Started a new Conversation How To Setup Microservices In Laravel?

For example, I have a marketplace to sell my product and services.

I separated it into admin, customer, product & services, order, checkout, mail services... etc

Is it mean that each services is an laravel application then communicate with each other?

Means it's like duplication set of application from here, but database just store needed data and use api to get more info from other services?

I am new to it and still learning, hope to get feedback,, thanks

May
30
1 week ago
Activity icon

Replied to Encounter Issue When Install Dingo/api Package

yes, this is my composer.json

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "require": {
        "php": "^7.3|^8.0",
        "brick/money": "^0.5.2",
        "fideloper/proxy": "^4.4",
        "fruitcake/laravel-cors": "^2.0",
        "guzzlehttp/guzzle": "^7.3",
        "laravel/breeze": "^1.1",
        "laravel/framework": "^8.12",
        "laravel/passport": "^10.1",
        "laravel/socialite": "^5.2",
        "laravel/tinker": "^2.6",
        "league/fractal": "^0.19.2",
        "phpfastcache/phpfastcache": "^8.0",
        "raiym/instagram-php-scraper": "^0.11.1",
        "spatie/laravel-permission": "^4.0",
        "wulfheart/pretty_routes": "^0.2.0",
        "ylsideas/feature-flags": "^1.4"
    },
    "require-dev": {
        "barryvdh/laravel-debugbar": "^3.5",
        "facade/ignition": "^2.5",
        "fakerphp/faker": "^1.9.1",
        "laravel/sail": "^1.0.1",
        "mockery/mockery": "^1.4.2",
        "nunomaduro/collision": "^5.0",
        "phpunit/phpunit": "^9.3.3"
    },
    "autoload": {
        "psr-4": {
            "App\": "app/",
            "Database\Factories\": "database/factories/",
            "Database\Seeders\": "database/seeders/",
            "P1\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

Activity icon

Started a new Conversation Encounter Issue When Install Dingo/api Package

I am having issue installing dingo/api package.

This is the problem show

 Problem 1
    - Root composer.json requires dingo/api ^0.10.0 -> satisfiable by dingo/api[v0.10.0].
    - dingo/api v0.10.0 requires illuminate/routing 5.1.* -> found illuminate/routing[v5.1.1, ..., 5.1.x-dev] but these were not loaded, likely because it conflicts with another require.

I am using laravel 8 and PHP 8 for now.

May
27
2 weeks ago
Activity icon

Replied to How To Share Variable Within App.js And Other Js In Vue

ahh yes, my mistake but i encounter another issue as shown below. Is it something wrong with my progress bar?

app.js:385623 Uncaught TypeError: o is not a constructor
    at Object.install (app.js:385623)
    at Object.use (app.js:128209)
    at Module../resources/app/app.js (app.js:192449)
    at __webpack_require__ (app.js:423299)
    at app.js:423461
    at Function.__webpack_require__.O (app.js:423336)
    at app.js:423463
    at app.js:423465

Solved -- due to vue version issue

Activity icon

Started a new Conversation How To Share Variable Within App.js And Other Js In Vue

I have an issue on the var not defined when trying to separate the thing in another js. E.g.

This is my app.js

import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import globalComponents from "./global-components";
import utils from "./utils";
import "./libs";

// Import progressbar
require('./progressbar');

const app = createApp(App)
    .use(store)
    .use(router);

In my progressbar.js

import VueProgressBar from 'vue-progressbar';

app.use(VueProgressBar, {
    color: 'rgb(143, 255, 199)',
    failedColor: 'red',
    height: '4px',
    transition: {
        speed: '0.4s',
        opacity: '0.6s',
        termination: 300
    },
})

Just curious can i do it in this way? Or i can only achieve by putting them in app.js?

May
26
2 weeks ago
Activity icon

Replied to Error When Trying To Implement Laravel Translation Into Vuejs File

Oops, it should be fine now. Just my mistake on key. Thank you!

Activity icon

Replied to Error When Trying To Implement Laravel Translation Into Vuejs File

Yes, i fixed it with that way. But i am having another issue after that on the translation part. When i am calling this __('I am something') will return {'i_am_something': 'I am something'} instead of I am something. I am trying to translate my key.

May
25
2 weeks ago
Activity icon

Started a new Conversation Error When Trying To Implement Laravel Translation Into Vuejs File

I am encountering an issue when trying to implement laravel translation into vuejs

app.js:417882 Uncaught Error: ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: ./resources/app/translation.js
    at Object.set [as exports] (app.js:417882)
    at Module../resources/app/translation.js (app.js:191861)
    at __webpack_require__ (app.js:417794)
    at Module../resources/app/app.js (app.js:190194)
    at __webpack_require__ (app.js:417794)
    at app.js:417971
    at Function.__webpack_require__.O (app.js:417831)
    at app.js:417973
    at app.js:417975

My app.js

import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import globalComponents from "./global-components";
import utils from "./utils";
import "./libs";

// SASS Theme
import "./assets/sass/app.scss";

const app = createApp(App)
  .use(store)
  .use(router);

globalComponents(app);
utils(app);

app.mount("#app");

createApp(App).mixin(require('./translation'))

translation.js

module.exports = {
    methods: {
        /**
         * Translate the given key.
         */
        __(key, replace) {
            let translation, translationNotFound = true

            try {
                translation = key.split('.').reduce((t, i) => t[i] || null, window._translations[window._locale].php)

                if (translation) {
                    translationNotFound = false
                }
            } catch (e) {
                translation = key
            }

            if (translationNotFound) {
                translation = window._translations[window._locale]['json'][key]
                    ? window._translations[window._locale]['json'][key]
                    : key
            }

            _.forEach(replace, (value, key) => {
                translation = translation.replace(':' + key, value)
            })

            return translation
        }
    },
}

I am following the step here to implement laravel translation.

https://dev.to/4unkur/how-to-use-laravel-translations-in-js-vue-files-ia

Am i doing it wrongly? Or what did i missing out here?

Activity icon

Replied to User Will Be Logged Out After Deployment Made

Oh, thanks. But usually where do we placed the key besides storage? Can i create a same level dir with storage and load the key from there?

Activity icon

Started a new Conversation User Will Be Logged Out After Deployment Made

I have an issue where user always to be logged out after deployment.

I am using fix APP_KEY and laravel passport package.

Is it because public oauth and private oauth key file stored in storage always being cleared caused the issue?

May
21
3 weeks ago
Activity icon

Replied to How To Merge Array Object Nested Value?

oh ya, forgot to mention. Yes, i am doing it in vue js.

May
20
3 weeks ago
Activity icon

Started a new Conversation How To Merge Array Object Nested Value?

I have an array object which look like this

[{
	id: 1
    description: 'test parent'
    child: [{.id: 100, description: 'test child'  }]
}]

Another array object look like this

[{
id: 1
},
{
id: 100
}]

How can i merge the bottom array object into this

[{
id: 1,
description: 'test parent'
},
{
id: 100,
description: 'test child'
}
]

Activity icon

Started a new Conversation How To Group Country-state-city Based On Parent_id?

I am trying to group country, state, and city into one list.

The data stored as this format ... id, parent_id, name, type

1, null, "Singapore", "country" 
2, 1, "Singapore", "state"
3, 2, "Ang Mo Kio", "city"
4, 2, "Jurong West", "city"

The way i am using is looping the table where store the country-state-city.

$table = Table::all();

foreach($table as $t) {

	if($t->type === "country") {}
	if($t->type === "state") {}
	if($t->type === "city") {}

}

Is there an elegant way to achieve this?

Activity icon

Started a new Conversation How To Allow Only Single Root Node Being Selected, And Allowed Multiple Selection For Child Node On Vue-treeselect?

This is the package (https://vue-treeselect.js.org/) used for my dropdown.

I have a requirement where I want to have the user to select only one of the root nodes but one or multiple of child nodes. The dropdown has three levels.

<treeselect ref="treeselect" v-model="value" @select="handleSelect"
:options="options" :flat="true" :auto-deselect-descendants="true" :multiple="true" />

// js
handleSelect({ id }) {
        const { treeselect } = this.$refs
        const node = treeselect.getNode(id)
        let newValue

        if (node.isLeaf) {
            const { parentNode } = node
            if (parentNode && !treeselect.isSelected(parentNode)) {
                newValue = [  id ]
            }
        } else {
            newValue = [ id ]
            treeselect.traverseDescendantsBFS(node, descendant => {
                newValue.push(descendant.id)
            })
        }

        if (newValue) setTimeout(() => {
            this.value = newValue
        })
    },

For the current function, it only allowed to select one child.

My expected output

// e.g. 1
- [ ] a
      - [ ] aa
      - [ ] ab
- [x] b
      - [x] ba
      - [x] byebye
            - [x] byebye
            - [x] byebye

// e.g. 2
- [ ] a
      - [ ] aa
      - [ ] ab
- [ ] b
      - [ ] ba
      - [ ] byebye
            - [ ] byebye
            - [x] byebye

// e.g. 3
- [ ] a
      - [ ] aa
      - [ ] ab
- [ ] b
      - [ ] ba
            - [x] baa
            - [ ] bab  
      - [x] bb
            - [x] bba
            - [x] bbb

How should I enhance my function to achieve the following circumstances?

  • When root unchecked, the options under the root should be unchecked too
  • Only single root allowed to be selected, but allowed multiple selection for options under root
  • Old root result will be cleared, when new option selected not belong to the root
May
18
3 weeks ago
Activity icon

Replied to Call Seeder From Migration

Yeah, i am thinking that too. Just they are asking me to do it. I am questioning them same thing too, as long as i am preventing duplication data to be inserted then should be fine. There's will be hard if we are removing everything inserted where dependency was there. Actually the seeder here just act as new data insert like cities where i don't write again the query to insert the data where already implemented in seeder.

Activity icon

Replied to Call Seeder From Migration

Alright, thanks for the suggestion. But what if going to rollback the data insertion, is that make sense to remove the data inserted using down()? Myself don't think that make sense to do it.

May
16
3 weeks ago
Activity icon

Replied to Call Seeder From Migration

You mean here where we just run the seed command manually ourself instead made use migration command during deployment right?

Activity icon

Replied to Call Seeder From Migration

Because i need to add new country data into my table. Any better suggestion how can i do this?

Activity icon

Started a new Conversation Call Seeder From Migration

Anyone can guide me, if migration up() call a seeder, what should i actually do with the down()? Is it truncate the table?

    public function up()
    {
        // Call seeder
        Artisan::call('db:seed', [
            '--class' => 'BaseDataSeeder',
        ]);
    }
May
10
1 month ago
Activity icon

Replied to How To Write A Test Case For Generate PDF?

Yes, it works fine for my previous test on generate PDF.

I am using DOMPDF

Oh, what i mean is to check the value passed into pdf e.g. I am populating my PDF with the value $model->name, $model->created_at.

Do i really need a test on this and how can the test be done actually?

Activity icon

Replied to How To Write A Test Case For Generate PDF?

I am doing it in this way

 public function test_can_generate_pdf()
    {
        PDF::shouldReceive('loadView')
             ->once()
             ->andReturnSelf()
             ->getMock()
             ->shouldReceive('download')
             ->once()
             ->with('welcome.pdf')
             ->andReturn('THE_PDF_BINARY_DATA');

        $this->get('/download')
             ->assertSuccessful()
             ->assertSeeText('THE_PDF_BINARY_DATA');
    }

Sorry i am still new to test stuff, i stucked when i am going to check with the data pass into the loadView to generate PDF.

In my controller,

public function generatePDF(Model $model) {}

Basically i just throw $model to the view to generate PDF. How can i test on the data needed for the pdf? Not sure how i am going to test on this.

Activity icon

Started a new Conversation How To Write A Test Case For Generate PDF?

How do i test if i passed correct data to generate PDF?

$data = Model::where('id', 1)->first();
 $date = Carbon::parse($data->created_at)->format('d/m/Y');
 $pdf = PDF::loadView('printPDF', compact('data', 'date'));

return $pdf->download($data->runningNumber . '.pdf');

This is the sample of my controller. How can i create a test case for this? I want to check the $data passed to the view to generate the PDF.

May
05
1 month ago
Activity icon

Replied to How To Save Null Value Into Date Column Format?

It's just simple date format column. Already set ->nullable()->default(null) for table.

$track = new Track();
$track->parcel_delivery_date = null; // when i pass null it will automatic set as today's date
$track->save()

Just something like.

Activity icon

Replied to How To Save Null Value Into Date Column Format?

no, is another date column

Activity icon

Replied to How To Save Null Value Into Date Column Format?

My table already set to nullable, but it doesn't taking any effect. It will auto set to today's date.

Activity icon

Started a new Conversation How To Save Null Value Into Date Column Format?

I am having trouble when trying to update date column with null value. I found that null value unable to override the value stored in the date column. How can i update it with null value?

May
04
1 month ago
Activity icon

Replied to How To Validate Date And Time?

Alright, thanks.

Activity icon

Started a new Conversation How To Validate Date And Time?

I have a validation as shown below

'date' => 'nullable|date_format:Y-m-d|after_or_equal:today',
'time' => 'nullable|date_format:H:i'

When i am testing with data today data with past time. It still allowed me to pass. How can i validate if today date and time must be greater or equal time now?

May
02
1 month ago
Activity icon

Replied to Is There A Better Way To Grouping An Array Parent And Child?

How will it looks like if go for readability?

Apr
30
1 month ago
Activity icon

Started a new Conversation Vue Unable To Load Image

I have an issue with image display where it shows [object Module] for the image src.

This is my webpack config

const mix = require("laravel-mix");
const path = require("path");
const tailwindcss = require("tailwindcss");
const { styles } = require("@ckeditor/ckeditor5-dev-utils");
const CKERegex = {
    svg: /ckeditor5-[^/\]+[/\]theme[/\]icons[/\][^/\]+\.svg$/,
    css: /ckeditor5-[^/\]+[/\]theme[/\].+\.css/,
};

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel applications. By default, we are compiling the CSS
 | file for the application as well as bundling up all the JS files.
 |
 */

Mix.listen("configReady", (webpackConfig) => {
    const rules = webpackConfig.module.rules;
    const targetSVG = /(\.(png|jpe?g|gif|webp)$|^((?!font).)*\.svg$)/;
    const targetFont = /(\.(woff2?|ttf|eot|otf)$|font.*\.svg$)/;
    const targetCSS = /\.p?css$/;

    for (let rule of rules) {
        if (rule.test.toString() === targetSVG.toString()) {
            rule.exclude = CKERegex.svg;
        } else if (rule.test.toString() === targetFont.toString()) {
            rule.exclude = CKERegex.svg;
        } else if (rule.test.toString() === targetCSS.toString()) {
            rule.exclude = CKERegex.css;
        }
    }
});

mix.alias({
    "@": path.join(__dirname, "resources/app"),
    "~": path.join(__dirname, "node_modules"),
});

mix
    .js("resources/app/app.js", "public/dist/js")
    .vue()
    .sass("resources/app/assets/sass/app.scss", "public/dist/css")
    .options({
        processCssUrls: false,
        postCss: [tailwindcss("./tailwind.config.js")],
    })
    .autoload({
        "cash-dom": ["cash"],
        "@popperjs/core": ["Popper"],
    })
    .webpackConfig({
        module: {
            rules: [
                {
                    test: CKERegex.svg,
                    use: ["raw-loader"],
                },
                {
                    test: CKERegex.css,
                    use: [
                        {
                            loader: "style-loader",
                            options: {
                                injectType: "singletonStyleTag",
                                attributes: {
                                    "data-cke": true,
                                },
                            },
                        },
                        "css-loader",
                        {
                            loader: "postcss-loader",
                            options: {
                                postcssOptions: styles.getPostCssConfig({
                                    themeImporter: {
                                        themePath: require.resolve(
                                            "@ckeditor/ckeditor5-theme-lark"
                                        ),
                                    },
                                    minify: true,
                                }),
                            },
                        },
                    ],
                },
            ],
        },
    })
    .browserSync({
        proxy: "vue-laravel.test",
        files: ["resources/**/*.*"],
    });

Can i know which configure wrong that caused the issue?

Apr
29
1 month ago
Activity icon

Started a new Conversation Is There A Better Way To Grouping An Array Parent And Child?

I have an array in this format

"child_1" => [
......

"parents" => [
.......
]
]

"child_2" => [
......

"parents" => [
.......
]
]

How can i make it parents with many childs?

"parents" => [
....
"childs" => [

"child_1" => [],
"child_2" => [],
"child_3" => []
]

]

I am using foreach to loop again and reassign into a new array. Is there any better approach to achieve this?

$arr = [];

foreach ($array as $data) {
$arr[$data->parent_id] = $data->parent
$arr[$data->parent_id]["childs"] = $data

}

Apr
24
1 month ago
Activity icon

Replied to What Is The Good Design For Multiple Social Login Database On User?

So how was thing going on, e.g. a user use multiple social account to login. There might be some info different like profile photo, are we going to display the info based on social account or ignore it. Allowed them to login and just show the registered details at first?

Apr
23
1 month ago
Activity icon

Started a new Conversation What Is The Good Design For Multiple Social Login Database On User?

I am looking for an idea on designing table for user login with SSO/ traditional way. Basically, i am using one table to do the job by identify the provider_type and provider_key. I am thinking whether to separate it out into multiple table for social provider or 2 tables (user and provider).

Is it legit if every social account is linked to each other and access to same user? Or as a new user for each social account? Or it depends on business model?

What do you guys think of it?

Appreciated for the feedback. Thanks!

Mar
25
2 months ago
Activity icon

Replied to How To Assign Array Value Based On Key To A Class Public Properties?

The error show Typed property ...::$customer must be an instance of .....\Entities\Customer, array used

Activity icon

Started a new Conversation How To Assign Array Value Based On Key To A Class Public Properties?

I have a class with public properties.

public string $id;
public Customer $customer;

I have an array

$data =
 ['id' => 1,
 ['customer' => [........]
 ]


    protected function transform(array $data): void
    {
        foreach ($data as $key => $value) {
            $this->$key = $value;
        }
    }

How can i assign into the Customer with the loop above?

Mar
22
2 months ago
Activity icon

Started a new Conversation How To Assign Value Based On Key Without Needed To Assign One By One?

I have a class

class user() {
public string $id;
public string $first_name;
public string $last_name;
}

I want to assign value into user() based on the array i get

$array = [
'id' => 1,
'first_name' => 'james'.
'last_name' = > 'tan'
]

$user = new user();
$user->id = .....;

Is there a way used to map automatically without needed to reassign?

Mar
17
2 months ago
Activity icon

Started a new Conversation How To Prevent User From A Group To Access Other Group Resources?

I am implement API with passport, whoever own the bearer token can access to any user resource with the API.

E.g. order/1 , which belong to user A in company A but user B from other company also can access as long as got their own bearer token.

How could i restrict only to a group of user from a company which allow to view the order?

What is the method used to restrict resources being retrieved by others for api?

Mar
14
2 months ago
Activity icon

Started a new Conversation How To Convert Camel Case Into Snake Case When Store Into Database As Json?

I have an entity as shown below

class Entity {

public string uuid;
public string customerName;
......
}

In my controller

$data = collect(new Entity (
'b5b436f6-7a8b-4a5b-ae59-3754517d4ada'
'John'
))->toJson();

When converted into json, it will show {"uuid":"b5b436f6-7a8b-4a5b-ae59-3754517d4ada", "customerName":"John"}', i want it to be {"uuid":"b5b436f6-7a8b-4a5b-ae59-3754517d4ada", "customer_name":"John"}'

Mar
11
3 months ago
Activity icon

Replied to I Am Trying To Inject My Route Params Into My Model But Show 404

I am using passport, not sure why not working. Is my params wrong defined wrong so not able to do injection

Activity icon

Started a new Conversation I Am Trying To Inject My Route Params Into My Model But Show 404

This is my route

DELETE |  /api/v1/order/{order} 

I am passing my id /api/v1/order/1 to delete function in my controller

In my controller, i am using

use App/Models/OrderEvents as Order

public function delete(Order $order) {}

Am i doing in wrong way? It shows me 404 after i call my api.

Mar
09
3 months ago
Activity icon

Replied to Can Laravel Event Sourcing (spatie) Create Multiple Snapshots Table?

so meaning that i am wrong and can't use this method to achieve something like order event history? Instead of storing it in 1 snapshot table. I store it separately based on the event happened.

Activity icon

Replied to Can Laravel Event Sourcing (spatie) Create Multiple Snapshots Table?

to store snapshot for order like purchase, sale, invoice...etc in separate table

Activity icon

Started a new Conversation Can Laravel Event Sourcing (spatie) Create Multiple Snapshots Table?

Is there possible for laravel event sourcing (spatie) package to use multiple snapshots table or events table? It looks like config there only able bind to only one snapshot repo and event repo. Anyone tried before?

Mar
05
3 months ago
Activity icon

Replied to Which Approaches Better For REST API Params?

How about for product with price? Pass price as well then backend to verify if not same then throw price updated?

Activity icon

Started a new Conversation Which Approaches Better For REST API Params?

If i want store data as history. Should i pass only the id field and then retrieve record based on id, or pass all the info needed and store it in database? Which one is correctly being used?