larafam

Experience

30,460

2 Best Reply Awards

  • Member Since 1 Year Ago
  • 262 Lessons Completed
  • 0 Favorites

8th September, 2018

larafam started a new conversation About Subscription • 1 week ago

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?

1st September, 2018

larafam left a reply on About Domain Name And Stuff • 2 weeks ago

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

larafam started a new conversation About Domain Name And Stuff • 2 weeks ago

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 • 2 weeks ago

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
    }
}

30th August, 2018

larafam left a reply on [how To] Url And Controller • 3 weeks ago

@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 • 3 weeks ago

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 • 3 weeks ago

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.

16th August, 2018

larafam started a new conversation About Application Deployment • 1 month ago

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?

15th August, 2018

larafam started a new conversation When Laravel 5.7 Release? • 1 month ago

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

12th August, 2018

larafam left a reply on Hotel Rooms Booking System. • 1 month ago

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

larafam left a reply on Hotel Rooms Booking System. • 1 month ago

@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. • 1 month ago

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

larafam left a reply on Users Block By A User • 1 month ago

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 • 1 month ago

@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 • 1 month ago

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 • 1 month ago

already google, no perfect answer.

5th July, 2018

larafam left a reply on Weird Email 'from' Address • 2 months ago

4th July, 2018

larafam started a new conversation Weird Email 'from' Address • 2 months ago

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

how to do something like that in laravel application?

3rd July, 2018

larafam started a new conversation How To Fix This Vuejs Warning • 2 months ago

[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)

25th June, 2018

larafam left a reply on Shared Variables In Route Group • 2 months ago

@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

23rd June, 2018

larafam left a reply on Async In Php • 2 months ago

@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 • 2 months ago

@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 • 2 months ago

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

22nd June, 2018

larafam left a reply on Composer • 2 months ago

@Snapey my project folder size become large:

with .git (800mb)

without .git (100mb)

larafam started a new conversation Composer • 2 months ago

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

13th June, 2018

larafam left a reply on Check If Class Extend Abstract Class Problem • 3 months ago

@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);
    }
}

12th June, 2018

larafam started a new conversation Check If Class Extend Abstract Class Problem • 3 months ago

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?

8th June, 2018

larafam left a reply on Weird Sytax In Laravel Core • 3 months ago

@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 • 3 months ago

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

$this['something']

access object like array?

4th June, 2018

larafam left a reply on About Service Provider In Package Dev • 3 months ago

@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 • 3 months ago

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

larafam started a new conversation About Service Provider In Package Dev • 3 months ago

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;
}

13th May, 2018

larafam started a new conversation Set Custom Timezone For Eloquent Timestamp Carbon • 4 months ago

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)?

17th April, 2018

larafam left a reply on Laravel And Ajax • 5 months ago

@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 • 5 months ago

@jlrdw so basically either way is okay right?

larafam started a new conversation Laravel And Ajax • 5 months ago

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???

11th April, 2018

larafam left a reply on Relationship Inside Accessor • 5 months ago

@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 • 5 months ago

@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 • 5 months ago

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 • 5 months ago

@rin4ik

so basically second way is more appropriate??

larafam started a new conversation Json Response Question • 5 months ago

what is the differences???


//between

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

//and

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


6th March, 2018

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

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

24th February, 2018

larafam left a reply on Modify Appended Property • 6 months ago

omg thanks @Snapey

larafam started a new conversation Modify Appended Property • 6 months ago

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??

9th February, 2018

larafam left a reply on Required If Coupon != 0 • 7 months ago

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

5th February, 2018

larafam left a reply on Weird Api Behaviour Or Am I Stupid? Halp! • 7 months ago

@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

larafam started a new conversation Weird Api Behaviour Or Am I Stupid? Halp! • 7 months ago

client.com has no post, remote.com has a post, but when i request from remote, i got zero post, it should return a post, why is this happening??? lets consider this scenario.


// client.com
Route::get('/request/to/client/controller', '[email protected]');


// SomeController
public function getDataFromRemote(){

    $response = (new \GuzzleHttp\Client)->request('post', '//remote.com/api/data');

    echo $response->getBody(); // return [] (should have a result)

}



// remote.com

// api
Route::post('/data', '[email protected]');


// SomeController
public function fetchPost(){

    return Post::all(); 

}

please halp!

1st February, 2018

larafam left a reply on Analytics But Not From Google Analytics. Anyone? • 7 months ago

@martinbean suggestion seems nice. i didnt realize google analytics have users management until u mentioned. thanks.

@AviationCode thanks for the response. im hoping for small package that track my client website like

31st January, 2018

larafam started a new conversation Analytics But Not From Google Analytics. Anyone? • 7 months ago

is there any php/laravel analytics packages that i can use for my websites? i dont want to use google analytics because i dont want my client to go through google analytics setup process.

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.