geetpurwar

geetpurwar

Member Since 4 Years Ago

Experience Points 26,140
Experience Level 6

3,860 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 254
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.

06 Jul
2 months ago

geetpurwar started a new conversation Using Middleware In Dispatching Queue

Hi,

I need a bit of help here. I am using following function which seems fine with using middleware.

Route::get('push', function(){
    $product = \App\Product::find(5028);
    $product->shopify_upload();
    return "Done";
})->middleware('dConfig');

However, I need to dispatch this via queue job and this is providing me error as I am not able to use middleware in jobs.

Route::get('push', function(){
    PushProductToShopify::dispatch(5029)->delay(now()->addSeconds(1));
})->middleware('dConfig');

Anyone please suggest how do I use middleware in queues. Thanks.

22 Mar
5 months ago

geetpurwar left a reply on Composer Update - Out Of Memory

Thank you. I have to enable swap. That worked.

21 Mar
5 months ago

geetpurwar started a new conversation Composer Update - Out Of Memory

Hi,

I am trying to running composer update and ubuntu based server with 1GB RAM shows following error.

mmap() failed: [12] Cannot allocate memory
PHP Fatal error:  Out of memory (allocated 695214080) (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52

Fatal error: Out of memory (allocated 695214080) (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52

Command : free -h

[email protected]:/var/www/lumberdev# free -h
              total        used        free      shared  buff/cache   available
Mem:           992M        242M        639M         31M        109M        600M
Swap:            0B          0B          0B

Please advise. Thanks.

03 Nov
10 months ago

geetpurwar left a reply on Relationship With State(s)

Can we access it in this way after that?

$subscribers = Notifications::delivered();

geetpurwar started a new conversation Relationship With State(s)

Hi,

I need advise and solution for a use-case. I have built up a push notification service, which has multiple website (Model).

Each website has many Subscribers (Model) and many Notifications (Model). Each Notification has 4 states: Sent, Delivered, Clicked & Closed.

Now I need to setup a relationship between Notification & Subscriber of each Website, so I can create a queryScope where I can get specific subscribers who clicked Notification and who closed it.

I think pivot table might not be use here.

Please advise. Thanks.

16 Oct
11 months ago

geetpurwar left a reply on Splice Deleting Last Element

@bobbybouwmann Thats working now. Thanks.

11 Oct
11 months ago

geetpurwar started a new conversation Splice Deleting Last Element

Hi,

I am trying to create a segmentation filter, where use can add/ remove rules on the fly. However, I am facing a issue here, where removing a rule always remove last element. Any idea what I am doing wrong?

https://codepen.io/geetpurwar/pen/yRbdQB

Code:

Vue.component('add-rule', {
    data: function(){
        return {
            criteriaType : '',
            fieldName : '',
            rule: {
                query: '',
                operator: '',
                value: '',
            },
            operator : '',
            operators: [],
            criteria: [
                {
                    name: 'Select',
                    value: ''
                },
                {
                    name: 'Timezone',
                    value: 'timezone',
                    type: 'select',
                    operator: ['is','is not'],
                },
                {
                    name: 'Language',
                    value: 'language',
                    type: 'select',
                    operator: ['is','is not'],
                },
                {
                    name: 'Platform',
                    value: 'platform',
                    type: 'select',
                    operator: ['is','is not'],
                },
                {
                    name: 'Browser',
                    value: 'browser',
                    type: 'select',
                    operator: ['is','is not'],
                },
                {
                    name: 'OS',
                    value: 'os',
                    type: 'select',
                    operator: ['is','is not'],
                },
                {
                    name: 'Country',
                    value: 'country',
                    type: 'select',
                    operator: ['is','is not'],
                },
                {
                    name: 'State',
                    value: 'state',
                    type: 'select',
                    operator: ['is','is not'],
                },
                {
                    name: 'City',
                    value: 'city',
                    type: 'select',
                    operator: ['is','is not'],
                },
                {
                    name: 'Useragent',
                    value: 'useragent',
                    type: 'text',
                    operator: ['contains','doesn\'t contain'],
                },
                {
                    name: 'Referrer',
                    value: 'HTTP_REFERRER',
                    type: 'text',
                    operator: ['contains','doesn\'t contain'],
                },
                {
                    name: 'Subscription Date',
                    value: 'subscribed_on',
                    type: 'date',
                    operator: ['on', 'before', 'after', 'between'],
                },
                {
                    name: 'Take',
                    value: 'take',
                    type: 'text',
                    operator: ['=='],
                },
                {
                    name: 'Geolocation',
                    lat: 26,
                    lng: 79,
                    radius: 100, //km
                    type: 'text',
                    operator: ['=='],
                }
            ],

            browser: ['Chrome', 'Firefox', 'Safari'],
            os: ['Mac OS', 'Windows', 'Linux', 'Android'],
            timezone: ['Asia', 'Europe', 'Austrialia', 'America'],
            language: ['English', 'Hindi', 'Spanish', 'German'],
            platform: ['Desktop', 'Tablet', 'Mobile'],
            country: ['India', 'Germany', 'USA'],
            state: ['UP', 'Texas', 'KA'],
            city: ['Orai', 'London', 'New York'],
            selectTwo: [],
            textValue: '',
        }
    },

    template: `
        <div class="columns add-property">
            <a class="delete is-small is-pulled-right" v-on:click="$emit(\'remove\', $event)"></a>
            <div class="column">
                <div class="select is-rounded">
                  <select v-on:change="onCriteriaChange">
                    <option v-for="criteria in criteria" v-bind:value="criteria.value + '-' + criteria.type + '-' + criteria.operator">{{ criteria.name }}</option>
                  </select>
                </div>
            </div>

            <div class="column">
                <template v-if="criteriaType == 'select' || criteriaType == 'text'">
                    <div class="select is-rounded">
                      <select v-bind:name="operator" v-on:change="onOperatorChange">
                        <option v-for="operator in operators" v-bind:value="operator">{{ operator }}</option>
                      </select>
                    </div>
                </template>
            </div>

            <div class="column">
                <template v-if="criteriaType == 'select'">
                    <div class="select is-rounded">
                      <select v-bind:name="fieldName" v-on:change="onSelectValue">
                        <option v-for="option in selectTwo" v-bind:value="option">{{ option }}</option>
                      </select>
                    </div>
                </template>

                <template v-else-if="criteriaType == 'text'">
                    <input class="input is-rounded" type="text" v-bind:name="fieldName" v-on:blur="onTextValue">
                </template>
            </div>
        </div>
    `,

    methods: {
        onCriteriaChange(e){
            if(e.target.value != ''){
                var type = e.target.value.split('-')[1];
                console.log(e.target.value.split('-'));
                if(type == 'select'){
                    this.rule.operator = '';
                    this.rule.value = '';
                    this.selectTwo = this[e.target.value.split('-')[0]];
                    this.criteriaType = 'select';
                    this.fieldName = e.target.value.split('-')[0].toLowerCase().trim();
                    this.operators = e.target.value.split('-')[2].split(',');
                    this.rule.query = this.fieldName;
                    this.rule.operator = this.operators[0];
                    this.rule.value = this.selectTwo[0];
                }else if(type == 'text'){
                    this.criteriaType = 'text';
                    this.rule.operator = '';
                    this.rule.value = '';
                    this.fieldName = e.target.value.split('-')[0].toLowerCase().trim();
                    this.operators = e.target.value.split('-')[2].split(',');
                    this.rule.query = this.fieldName;
                    this.rule.operator = this.operators[0];
                    this.rule.value = this.selectTwo[0];
                }
            }
        },

        onOperatorChange(e){
            this.rule.operator = e.target.value;
        },

        onSelectValue(e){
            this.rule.value = e.target.value;
        },

        onTextValue(e){
            this.rule.value = e.target.value;
            console.log(e.target.value);
            console.log(e);
        },

        removeRule(index){
            console.log(index);
            console.log(this);
        }
    },

    computed: {
        arrayLength: function () {
            if(this.selectTwo.length > 0){
                return false;
            }else{
                return true;
            }
        },
    }
});

Vue.component('add-property', {
    template: `
        <div class="add-condition">
            <add-rule v-model="row.name" v-for="(row, index) in rows" :key="index + 1" v-on:remove="removeThisRow(index)"></add-rule>
            <button class="button is-small is-rounded is-info is-pulled-right" v-on:click.stop="addRule">Add Rule</button>
        </div>
    `,

    data: function () {
        return {
            count: 1,
            rows: []
        }
    },

    methods: {
        addRule(event){
            this.count += 1;
            this.rows.push({
                name: '',
            });
            event.preventDefault();
        },
        removeThisRow(index){
            console.log(index);
            console.log(this.rows);
            this.rows.splice(index, 1);
        }
    }
});

Vue.component('add-condition', {
    template: `
        <div>
            <add-property v-for="(n, index) in count" :key="index + 1"></add-property>
        </div>
    `,

    data: function () {
        return {
            count: 1
        }
    },

    methods: {
        addRule(){
            this.count += 1;
        }
    }
});

new Vue({
    el: '#app',

    data: {
        count: 1,
    },

    methods: {
        addCondition(event){
            this.count += 1;
            event.preventDefault();
        }
    },
});
05 Oct
11 months ago

geetpurwar left a reply on Processing Millions Of Records

@Snapey yes, I plan to use Digital Ocean Droplet for sending push notifications. What else do you recommend and what service do you serve on Digital Ocean Droplet.

geetpurwar started a new conversation Processing Millions Of Records

I need to send push notifications to millions of records. I am using following method. Wondering if there is better way to do it.

$merged_collection = new Collection;
foreach($segmentArray as $singleSegment){
$merged_collection =        $merged_collection>merge(segmented_subscribers($singleSegment, false, false));
}

$chunk = $merged_collection->chunk(200);
foreach($chunk as $subscribers){
    foreach($subscribers as $subscriber){
        if(! in_array($subscriber->id, $sentArray)){
            $subscription = Subscription::create([
                    'endpoint' => $subscriber->endpoint,
                    'publicKey' => $subscriber->publicKey,
                    'authToken' => $subscriber->authToken,
            ]);

            if($webPush->sendNotification($subscription, $payload, true)){
            array_push($sentArray, $subscriber->id);
        }else{
            array_push($failedArray, $subscriber->id);
            }
        }
    }
}

geetpurwar left a reply on Merge Returning Empty Collection

@Snapey There are millions of records and segmentation is based on User created conditions, which could result in possible duplicate items.

geetpurwar left a reply on Merge Returning Empty Collection

Figured out the issue. Need to use class.

$final = new Collection;

geetpurwar left a reply on Merge Returning Empty Collection

@Snapey push() is working, however its also including duplicate items. Need to remove duplicate items here too.

geetpurwar started a new conversation Merge Returning Empty Collection

hi, I am using collection merge method and its returning empty collection. How do I correctly use it?

use Illuminate\Database\Eloquent\Collection;

$final = new Collection();
    
$first_collection = Notification::where('id', 1)->get();
$second_collection = Notification::where('id', 2)->get();

$final->merge(first_collection);
$final->merge($second_collection);

dd($final);

Result:

Collection {#358 ▼
  #items: []
}
04 Oct
11 months ago

geetpurwar left a reply on DB Builder Query

@wilk_randall Thanks it worked. I never knew we could use prepend '&' with it. Any reference link to understand it more.

Thanks again.

geetpurwar started a new conversation DB Builder Query

Hi,

I am not able to take value of variable outside. Let me know of what I am doing wrong?

$sentArray = array(); //Match if existing Subscriber has already been sent the message

array_push($sentArray, 0);

$query = \DB::table('subscribers');

$query
->select('id', 'endpoint', 'publicKey', 'authToken')
->where('website_id', $websiteId)
->orderBy('id')->chunk(200, function($subscribers) use($sentArray){
    foreach($subscribers as $subscriber){
        array_push($sentArray, $subscriber->id);
    }
});

dd($sentArray);

Result is always this:

array:1 [▼
  0 => 0
]
29 Sep
11 months ago

geetpurwar started a new conversation Model Reusable Segmentation

Hi,

Here's a case and I am not able to understand how to approach. I am collecting subscriber details to send notifications and approx 20+ parameters are collected while subscription process such as platform, OS, Browser Details, Country, City etc.

Now, I need to send notifications based on these parameters, some notification for windows, some for Chrome etc.

how do I create reusable segments to send such notifications.

At this moment, I am using this code to find subscribers, but thats not reusable.

$subscribers = \DB::table('subscribers')
                    ->where('platform_type','Desktop')
                    ->where('browser_name','Canary')
                    ->orWhere('browser_name','Chrome')
                    ->get()->toArray();
    $subscribers = json_decode(json_encode($subscribers), true);

Any suggestions?

22 Sep
11 months ago

geetpurwar started a new conversation Eloquent Returning Empty Collection

Hi,

My Subscriber Model is returning empty collection.

Here's the Model. And Model class is custom here. Any suggestions whats wrong in here.

<?php

namespace App;
use Illuminate\Database\Eloquent\SoftDeletes;

class Subscriber extends Model
{
    /* Soft-Deletes */
    use SoftDeletes;
    protected $dates = ['deleted_at'];

    /* Relationship */
    public function website()
    {
        return $this->belongsTo(Website::class);
    }

    public function create(Request $request)
    {
        return $this->request;
    }
}

Model Class:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model as Eloquent;
use Spatie\Geocoder\Geocoder;

class Model extends Eloquent
{
    protected $fillable = [
        'uuid',
        'website_id',
        'endpoint',
        'publicKey',
        'authToken',
        'contentEncoding',
        'browser_name',
        'browser_version',
        'browser_timezone',
        'browser_timezone_offset',
        'browser_language',
        'browser_local_time',
        'useragent',
        'platform_name',
        'platform_version',
        'platform_vendor',
        'platform_model',
        'platform_type',
        'is_mobile',
        'is_touch',
        'is_secure',
        'HTTP_REFERER',
        'HTTP_ORIGIN',
        'HTTP_HOST',
        'referral_url',
        'referral_website',
        'IP',
        'ip_is_decoded',
        'ip_country_iso',
        'ip_country',
        'ip_state_short',
        'ip_state',
        'ip_city',
        'ip_postal_code',
        'ip_lat',
        'ip_lon',
        'ip_lat_lon',
        'ip_timezone',
        'ip_currency',
        'ip_as',
        'ip_isp',
        'ip_org',
        'ip_is_mobile',
        'ip_is_proxy',
        'is_located',
        'location_lat',
        'location_lon',
        'location_lat_lon',
        'location_is_decoded',
        'location_country',
        'location_state',
        'location_district',
        'location_city',
        'location_postal_code',
        'location_formatted_address',
        'is_ecommerce',
        'ecommerce_count',
        'ecommerce_amount',
        'ecommerce_checkout',
        'ecommerce_currency',
        'ecommerce_timestamp'
    ];
}

geetpurwar left a reply on Searchable Arrays In Database

Is this correct format of relationship here:

public function up()
    {
        Schema::create('segments', function (Blueprint $table) {
            $table->increments('id')->unsigned();
            $table->string('name');
        });

        Schema::create('segment_subscriber', function (Blueprint $table) {
            $table->integer('subscriber_id')->unsigned();
            $table->integer('segment_id')->unsigned();
            $table->primary(['subscriber_id', 'segment_id']);
            $table->foreign('subscriber_id')->references('id')->on('subscribers');
            $table->foreign('segment_id')->references('id')->on('segments');
        });

        Schema::create('segment_website', function (Blueprint $table) {
            $table->integer('website_id')->unsigned();
            $table->integer('segment_id')->unsigned();
            $table->primary(['website_id', 'segment_id']);
            $table->foreign('website_id')->references('id')->on('websites');
            $table->foreign('segment_id')->references('id')->on('segments');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('segments');
        Schema::dropIfExists('segment_subscriber');
        Schema::dropIfExists('segment_website');
    }
21 Sep
11 months ago

geetpurwar left a reply on Searchable Arrays In Database

Wow! Thanks @Sergiu17 & @Vilfago

One more addition to question:

Subscriber belongs to Website Model, which I think should have Topics. Let me know if I am correct here.

Website to Topics => One to Many Model Topic to Subscribers => Many to Many

Any better approach is welcome too :) Thanks.

geetpurwar started a new conversation Searchable Arrays In Database

Hi, I need little bit here over here. I am creating a subscriber Model, which I need to separate into several segments depending on user's choice.

Example : A user may choose to subscribe for tech news, sports news etc. A subscriber may opt for single segments or multiple segments too. Say, he can opt for both tech news and sports news.

Now once all subscribers have this information updated, I need to have them searchable to send me appropriate news they have subscribed too.

Any suggestions how do I setup that in migration, model and search using eloquent.

Let me know. Thanks.

13 Sep
1 year ago

geetpurwar started a new conversation NPM Run Watch Gives Error

Hi, I am using Laravel Mix to process sass and js files. However, it now shows some error, which I couldn't understand.

Any ideas? Thanks.

 [9] → npm run watch

> @ watch /Users/Geet/Dropbox/Personal/projects/pushvertize
> npm run development -- --watch


> @ development /Users/Geet/Dropbox/Personal/projects/pushvertize
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js "--watch"

module.js:549
    throw err;
    ^

Error: Cannot find module '..'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/Geet/Dropbox/Personal/projects/pushvertize/node_modules/.bin/cross-env:4:16)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js "--watch"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ development script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/Geet/.npm/_logs/2018-09-13T14_11_56_534Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ watch: `npm run development -- --watch`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ watch script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/Geet/.npm/_logs/2018-09-13T14_11_56_553Z-debug.log
12 Sep
1 year ago

geetpurwar left a reply on Model Update Error

Thanks @manogi . It did the fix. @s4muel Looking info error format.

geetpurwar left a reply on Model Update Error

Cache cleared but no use. It works fine when I insert the data for link.

dd($request) provides following:

+request: ParameterBag {#45 ▼
    #parameters: array:19 [▼
      "_method" => "PUT"
      "_token" => "a957hz0SDJqvpr5sYZ7RiGRZMkLg2x2mQ7nN9983"
      "name" => "Pushvertize"
      "timezone" => "Asia/Kolkata"
      "opt_in_type" => "http"
      "opt_in_theme" => "safari"
      "chicklet_position" => "chicklet-right-side"
      "chicklet_default_text" => "Enable Notifications"
      "chicklet_enable_text" => "Subscribe"
      "chicklet_disable_text" => "Unsubscribe"
      "chicklet_wait_text" => "Wait"
      "chicklet_incompatible_text" => "Notifications are incompatible"
      "optin_title" => "Subscribe to Notifications"
      "optin_subtitle" => "You can unsubscribe anytime"
      "optin_allow" => "Allow"
      "optin_close" => "Close"
      "welcome_push_title" => "Thanks for subscribing."
      "welcome_push_body" => "Click here to learn more."
      "welcome_push_link" => null
    ]
  }

geetpurwar started a new conversation Model Update Error

Hi, I have created a website Model, which has certain fields. Only 'name' field is required.

However, if I submit without entering any other field, I always get following errors. What am I doing wrong?

{"welcome_push_link":["The welcome push link must be at least 2 characters.","The welcome push link format is invalid."]}

I am using following update method in Website Controller.

public function update(User $user, Request $request, Website $website)
    {
        if(auth()->user()->id == $website->user_id):

            $this->validate($request, [
                'name'                       => 'required|min:2',
                'icon'                       => 'image|mimes:jpeg,png,jpg,gif,svg|max:10048',
                'timezone'                   => 'required',
                'opt_in_type'                => 'min:2',
                'opt_in_theme'               => 'min:2',
                'chicklet_position'          => 'min:2',
                'chicklet_default_text'      => 'min:2',
                'chicklet_enable_text'       => 'min:2',
                'chicklet_disable_text'      => 'min:2',
                'chicklet_wait_text'         => 'min:2',
                'chicklet_incompatible_text' => 'min:2',
                'optin_title'                => 'min:2',
                'optin_subtitle'             => 'min:2',
                'optin_allow'                => 'min:2',
                'optin_close'                => 'min:2',
                'welcome_push_title'         => 'min:2',
                'welcome_push_body'          => 'min:2',
                'welcome_push_link'          => 'min:10'
            ]);

            $filename = NULL;
            if( $request->hasFile('icon') ) {
                $website->icon_s3 = uploadAndReturnLink($request->file('icon'), 'websiteIcons', 's3');
                $website->icon_local = uploadAndReturnLink($request->file('icon'), 'websiteIcons', 'local');
            }

            $website->name                       = $request->name;
            $website->timezone                   = $request->timezone;
            $website->opt_in_type                = $request->opt_in_type;
            $website->opt_in_theme               = $request->opt_in_theme;
            $website->chicklet_position          = $request->chicklet_position;
            $website->chicklet_default_text      = $request->chicklet_default_text;
            $website->chicklet_enable_text       = $request->chicklet_enable_text;
            $website->chicklet_disable_text      = $request->chicklet_disable_text;
            $website->chicklet_wait_text         = $request->chicklet_wait_text;
            $website->chicklet_incompatible_text = $request->chicklet_incompatible_text;
            $website->optin_title                = $request->optin_title;
            $website->optin_subtitle             = $request->optin_subtitle;
            $website->optin_allow                = $request->optin_allow;
            $website->optin_close                = $request->optin_close;
            $website->welcome_push_title         = $request->welcome_push_title;
            $website->welcome_push_body          = $request->welcome_push_body;
            $website->welcome_push_link          = $request->welcome_push_link;

            $website->save();

            generateJSFile($website);
            return back()->with('success', 'Settings Updated.');
        endif;
    }
10 Sep
1 year ago

geetpurwar left a reply on API Returning 401

just figured it out. It was auth middleware that was kicked in by constructor of Notification controller. Updated constructor code as follows:

$this->middleware('auth', ['except' => ['TrackClose', 'TrackClick', 'TrackDelivery', 'updateSent']]);

geetpurwar started a new conversation API Returning 401

Hi, I am trying to update content using JSON and Laravel API, however, its returning 401 now. What I need is just to pull this content and update database.

api.php

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

Route::options('{all}', '[email protected]')->where('all', '.*');

Route::any('{all}', function(){
    return abort(404);
})->where('all', '.*');

Notification Controller:

public function TrackDelivery(Request $request, Notification $notification)
{
    return "Track Delivery Count";
}

public function options(Request $request, Response $response)
{
        $origin = $request->header('origin') ?: $request->url();

        $response->header('Access-Control-Allow-Origin', $origin);
        $response->header('Access-Control-Allow-Headers', 'origin, content-type, accept, Authorizations');
        $response->header('Access-Control-Allow-Methods', 'GET, HEAD, OPTIONS, POST, PATCH, DELETE');

        return $response;
}

Any idea?

09 Sep
1 year ago

geetpurwar left a reply on Image Resize & Upload To AWS S3

hi Bobby,

That worked. Thanks so much :)

geetpurwar started a new conversation Image Resize & Upload To AWS S3

Hi, I am using following code and I am able to resize and upload image using image intervention but can't get correct url after image is uploaded.

This is my code:

function uploadAndReturnLink($file, $path)
{
    //$file = $request->file('file');

    $img = Image::make($file)->resize(300, null, function ($constraint) {$constraint->aspectRatio();});

    $filename = uuid().'.'.$file->getClientOriginalExtension();

        $cloudpath = Storage::disk('s3')->put($path.'/'.$filename, $img->stream()->__toString());

        return Storage::url($cloudpath);
}