larafam

larafam

Member Since 1 Year Ago

Experience Points 30,770
Experience
Level
Lessons Completed 264
Lessons
Completed
Best Reply Awards 2
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

28 Sep
1 month ago

larafam started a new conversation What This Snippet Do?

why is there __invoke on callback property? is __invoke a magic method for class?


$this->callback->__invoke($attribute, $value, function ($message) {
            $this->failed = true;

            $this->message = $message;
});

27 Sep
1 month ago

larafam left a reply on Modify Response In Middleware

@martinbean

$response->original; // return View instance
$response->setContent('something');
$response->original; // return string

i dont want to mutate original property. I need view instance even after modifying content.

23 Sep
1 month ago

larafam started a new conversation Modify Response In Middleware

how to set content on response without modifying View instance on $response->original property.

08 Sep
2 months ago

larafam started a new conversation About Subscription

let say i have three plan: basic, intermediate and advance

user subscribe to basic, after afew day they swap to advance plan and receive all advance feature.

before next bill, this user swap to starter plan back to avoid charge as advance plan.

how cashier handle this ? or am i need to manually handle it?

01 Sep
2 months ago

larafam left a reply on About Domain Name And Stuff

@topvillas can u paste the link for me. already search, not found :(

larafam started a new conversation About Domain Name And Stuff

i want to create a website where user can register an account and register domain name.

how to achieve this, im totally have no idea.

larafam left a reply on Vuejs In Laravel Controller

you can trigger click event or any js stuff by using url parameter

in your controller method


return redirect()->route('some.route', ['trigger' => true]);

in your view:

var isTrigger = {{ request('trigger') }};

Vue({
 .....


mounted() {
    if (isTrigger) {
        this.selectSingleOrder(order);
        // or do whatever
    }
}
30 Aug
2 months ago

larafam left a reply on [how To] Url And Controller

@bobbybouwmann anyway, based from your code, i get an idea and workaround for my solution.

function url_inside_controller($controllerToCheck)
    {
        return explode('@', app('router')->currentRouteAction())[0] == $controllerToCheck;
    }

i think i just need to grab current action. haha

larafam left a reply on [how To] Url And Controller

sry late, thanks @bobbybouwmann , your current technique give me this data:

    33 => "admin/pages"
    34 => "admin/pages"
    35 => "admin/pages/create"
    36 => "admin/pages/{page}/edit"
    37 => "admin/pages/{page}"
    38 => "admin/pages/{page}"
    39 => "admin/pages/{page}/builder"
    40 => "admin/pages/{page}/builder"
  ]```

what if my current url look like this:

example.com/admin/pages/some-page-slug/edit



larafam started a new conversation [how To] Url And Controller

lets say that current browser url is: example.com/admin/pages/create with route definition:

Route::get('admin/pages/create', '[email protected]');

i want to create a function that checks if current url is inside given controller,

url_inside_controller('TestController'); // return true

can anyone provide me with code example or maybe an idea.

16 Aug
2 months ago

larafam started a new conversation About Application Deployment

what is the proper way to deploy an app into a server? currently im using cleaver to deploy my app, but everytime i want to redeploy, it delete users generated files. am i doing it wrong? how to deploy an app, redeploy it (because i want to fix bug) without losing user data?

15 Aug
2 months ago

larafam started a new conversation When Laravel 5.7 Release?

i want to start new project, but i think i want to use laravel 5.7, should i wait?

12 Aug
3 months ago

larafam left a reply on Hotel Rooms Booking System.

@Krisell i think either way is insignificant in the machine though hahah

larafam left a reply on Hotel Rooms Booking System.

@Krisell room booking history should be in another table, i think room table should only state if the room is_booked or not #mytwocents

larafam left a reply on Hotel Rooms Booking System.

Room::where('is_booked', false)->get();

larafam left a reply on Users Block By A User

just put another rule:


if ($user) {
            if ($user->isblocked() OR $user->isblocking() && Auth::user()->id != $user->id) {
                return redirect('/home');
            } else {
                return $next($request);
            }
        }


larafam left a reply on Problem Regarding Cron Job

@crnkovic so how am i going to do that in laravel using native scheduling from laravel?

my current idea is: create middleware and call Artisan::call('schedule:run') in method terminate.

is my idea correct?

larafam started a new conversation Problem Regarding Cron Job

how to do virtual cron job (like wordpress) in laravel application, already google, no answer :(

larafam started a new conversation Update Mechanism Like Wordpress In Laravel

already google, no perfect answer.

05 Jul
4 months ago
04 Jul
4 months ago

larafam started a new conversation Weird Email 'from' Address

i saw shopify doing something like "via shopify". alt text

how to do something like that in laravel application?

03 Jul
4 months ago

larafam started a new conversation How To Fix This Vuejs Warning

[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "addressLine2"

i have this simple address form

<template>
    <div>
        <div class="field is-grouped">
            <div class="control is-expanded">
                <label for="first_name" class="label">First name</label>
                <input type="text" class="input" id="first_name" name="first_name" v-model="firstName" :required="isRequired">
            </div>
            <div class="control is-expanded">
                <label for="last_name" class="label">Last name</label>
                <input type="text" class="input" id="last_name" name="last_name" v-model="lastName" :required="isRequired">
            </div>
        </div>
        <div class="field">
            <label for="company" class="label">Company (optional)</label>
            <div class="control is-expanded">
                <input type="text" class="input" id="company" name="company" v-model="company">
            </div>
        </div>
        <div class="field">
            <label for="address" class="label">Address</label>
            <div class="control is-expanded">
                <input type="text" class="input" id="address" name="address_line_1" v-model="addressLine1" :required="isRequired">
                <input type="text" class="input mt-4" id="address" name="address_line_2" v-model="addressLine2">
            </div>
        </div>
        <div class="field">
            <label for="city" class="label">City</label>
            <div class="control is-expanded">
                <input type="text" class="input" id="city" name="city" v-model="city" :required="isRequired">
            </div>
        </div>
        <div class="field">
            <label for="country" class="label">Country</label>
            <div class="select is-fullwidth">
                <select name="country" id="country" v-model="country" @change="state = ''" :required="isRequired">
                    <option :value="country.name" :key="country.sortname" v-for="country in countries">{{ country.name }}</option>
                </select>
            </div>
        </div>
        <div class="field is-grouped">
            <div class="control is-expanded">
                <label for="state" class="label">States</label>

                <div class="select is-fullwidth" v-if="states.length > 0">
                    <select name="state" id="state" v-model="state" :required="isRequired">
                        <option :value="s.name" :key="s.id" v-for="s in states">{{ s.name }}</option>
                    </select>
                </div>
                <input type="text" class="input" id="state" name="state" v-model="state" v-else :required="isRequired">
            </div>
            <div class="control is-expanded">
                <label for="postal" class="label">Postal code</label>
                <input type="text" class="input" id="postal" name="postal" v-model="postal" :required="isRequired">
            </div>
        </div>

        <div class="field">
            <div class="control is-expanded">
                <label for="phone" class="label">Phone</label>
                <input type="text" class="input" id="phone" name="phone" v-model="phone" :required="isRequired">
            </div>
        </div>
    </div>
</template>

<script>
export default {
    name: "addressForm",
    props: {
        countries: {
            type: Array,
            required: true
        },
        firstName: String,
        lastName: String,
        company: String,
        addressLine1: String,
        addressLine2: String,
        city: String,
        country: String,
        state: String,
        postal: String,
        phone: String,
        isRequired: {
            type: Boolean,
            default: true
        }
    },

    data() {
        return {
            states: []
        };
    },

    watch: {
        country(value) {
            var country = collect(this.countries).where('name', value).first();

            if (typeof country !== 'undefined'){
                this.states = country.states;
                return;
            }

            this.states = [];
        }
    }
}
</script>

<style>

</style>

but whenever i edit one of the input. vue throw that warn. the thing is, i dont want to create data property because my props is too many.

how to tackle this kind of situation? my idea is to

  1. disable vue warn and just go with the anti pattern flow
  2. pass props as array instead one by one. (but it will become ugly)
25 Jun
4 months ago

larafam left a reply on Shared Variables In Route Group

@edwinjansen i solve this issue using view::share and middleware


Route::group(['middleware' => ['bound']], function () { .. your routes });

register bound middleware in kernel


// in Bound.php middleware

public function handle(Request $request, Closure $next)
    {
        \Illuminate\Support\Facades\View::share(
            'some_data',  'i want to share'
        );

        return $next($request);
    }

then you can use that data in that particular route group

23 Jun
4 months ago

larafam left a reply on Async In Php

@Cronix so what is the difference between queue worker and async stuff provide bye spatie/async or reactphp library?

larafam left a reply on Async In Php

@NickVahalik so if i want to send 100 email, i can just do it like this

// SomeController

$pool->add(new SendHundredEmail());

return back();

right?

larafam started a new conversation Async In Php

im currently really interested with async world, i want to move into nodejs async world, but then im too lazy to learn new stuff and stick with php (laravel).. can some one give me an async use case in php and how we tackle it with php? im thinking using spatie/async or reactphp..

22 Jun
4 months ago

larafam left a reply on Composer

@Snapey my project folder size become large:

with .git (800mb)

without .git (100mb)

larafam started a new conversation Composer

how to avoid composer to include .git folder for every package that i require.

13 Jun
5 months ago

larafam left a reply on Check If Class Extend Abstract Class Problem

@Cronix tq. this is my current solution


$parent = get_parent_class($instance);
        
$msg = 'Provider must extend '. Gateway::class .' abstract class.';

if (! $parent) {
    abort(403, $msg);
} else {
    $reflect = new \ReflectionClass($parent);

    if (! $reflect->isAbstract() || $parent != Gateway::class) {
        abort(403, $msg);
    }
}

12 Jun
5 months ago

larafam started a new conversation Check If Class Extend Abstract Class Problem

i already google 'how to check if a class extend abstract class'. all i get is to use is_subclass_of built in function which is not work as intended. already use instanceof still return false. any alternative?

08 Jun
5 months ago

larafam left a reply on Weird Sytax In Laravel Core

@tykus wow thanks. learn something new everyday.. hahaha... do u have a source (not php.net) for me to learn something like this?

larafam started a new conversation Weird Sytax In Laravel Core

i saw taylor do something like this in laravel core. i dont remember it at what file.

$this['something']

access object like array?

04 Jun
5 months ago

larafam left a reply on About Service Provider In Package Dev

@arukomp my problem is very weird actually haha.. might need to refactor the whole architecture... anyway, thanks alot for helping me

larafam left a reply on About Service Provider In Package Dev

@arukomp actually AServiceProvider boot method is waiting for BServiceProvider boot method.. :((

larafam started a new conversation About Service Provider In Package Dev

is there any way for me to make some of my package service provider to wait for other service provider??

something like this:


class AServiceProvider extends \Illuminate\Support\ServiceProvider
{
    protected $wait = BServiceProvider::class;
}

13 May
6 months ago

larafam started a new conversation Set Custom Timezone For Eloquent Timestamp Carbon

is timestamp carbon instance timezone follow app.php timezone or default timezone specify in php.ini?

does laravel timezone in config (app.php) set date_default_timezone_set in background????

basically, i have simple timezone select form. and want to set user chosen timezone like this,


config(['app.timezone' => $timezone]);

so, THE question is, how to properly set timezone that effect eloquent timestamp and carbon(if can)?

17 Apr
6 months ago

larafam left a reply on Laravel And Ajax

@bluelock yes, thats what i usually do for my ajax response. my question is when to use ajax?

larafam left a reply on Laravel And Ajax

@jlrdw so basically either way is okay right?

larafam started a new conversation Laravel And Ajax

when to use ajax in my application?

should i return the data at the controller like this:

return view('myview')->with('data', $data);

or use ajax to get the data???

11 Apr
7 months ago

larafam left a reply on Relationship Inside Accessor

@rin4ik


<?php

namespace Shop\Model;

use Illuminate\Database\Eloquent\Model;
use Shop\Model\Product;

class Variant extends Model
{
    protected $guarded = [];

    protected $appends = [
        'title_with_variants'
    ];

    public function product()
    {
        return $this->belongsTo(Product::class, 'product_id', 'id');
    }

    public function getTitleWithVariantsAttribute()
    {
        $postTitle = '';

        if($this->product->product_type == 'variable'){
            $postTitle = ' ('. implode(', ', $this->variants) .')';
        }

        return "{$this->product->title} {$postTitle}";
    }
}

larafam left a reply on Relationship Inside Accessor

@rin4ik im sorry. its Variant.php not Product.php

1 product has many variant. so in variant i want to access its product,.

larafam started a new conversation Relationship Inside Accessor

below snippet throw 500 error!

// model: Product.php


    public function getTitleWithVariantsAttribute()
    {
        $postTitle = '';

        if($this->product->product_type == 'variable'){
            $postTitle = ' ('. implode(', ', $this->variants) .')';
        }

        return "{$this->product->title} {$postTitle}";
    }


so how can i access $this->product (relationship) inside accessor ?

larafam left a reply on Json Response Question

@rin4ik

so basically second way is more appropriate??

larafam started a new conversation Json Response Question

what is the differences???


//between

return [
    'test' => 'hello world'
];

//and

return response()->json([
    'test' => 'hello world'
]);


06 Mar
8 months ago

larafam started a new conversation Is There Any Package That Solve Multiple Form Submission Issues?

is there any laravel package that solve this issue in server side (not client pls). is anyone here know?

24 Feb
8 months ago

larafam started a new conversation Modify Appended Property

the title says it all.

// mymodel.php

protected $appends = [
    'custom'
];

public function getCustomAttribute(){
    return 'foo';
}


$model = mymodel::find(1);

$model->custom = 'new value'; //not working
$model->setAttribute('custom', 'new value'); //not working

echo $model->custom; // foo (expecting new value)

is there any way that i can change the value??

09 Feb
9 months ago

larafam left a reply on Required If Coupon != 0

there is required_if rule in docs. im not sure if thats what u want,.

05 Feb
9 months ago

larafam left a reply on Weird Api Behaviour Or Am I Stupid? Halp!

@shez1983 using postman i get intended result, but not from client controller. its seems that


return Post::all(); 

is called from client server not remote server. hm