robrogers3

Software Engineer at CrowdStar

Experience

112,740

60 Best Reply Awards

  • Member Since 3 Years Ago
  • 1096 Lessons Completed
  • 2 Favorites

13th June, 2018

robrogers3 left a reply on RefreshDatabase Trait Doesn't Refresh Database • 1 week ago

it's a trait. so you can at the beginning of your test do $this->refreshDatabase();

8th June, 2018

robrogers3 left a reply on How To Start Countdown For Two Variables At A Time • 1 week ago

function countdown(el) {
    var i = 1;
    console.log('start count down for ' + el)
    while (i < 10) {

        z = function(x) {
            setTimeout(function(j){ 
                console.log(j)
                if (j <= 10)  {
                    z(j+1)

                }
            }, 1000, x);
        };
        
        if (i == 1)
            z(i);
        i++;
    }
}
countdown('a');
setTimeout(function(){countdown('b');}, 1050);

7th June, 2018

robrogers3 left a reply on Logout Route Middleware Not Working • 1 week ago

I've thought about the back button. I don't think you can change this, unless you add some js to the page. you can check if the csrf is valid via ajax. and redirect if not still valid.

let me know if you need code

robrogers3 left a reply on Valet No Longer Working, "Unable To Determine Linked PHP" • 1 week ago

so what brew command did you run? can you copy and paste?

6th June, 2018

robrogers3 left a reply on How To Start Countdown For Two Variables At A Time • 2 weeks ago

you have a race condition where your solution is to serve up A first and ignore B if A has already started counting.

this should work

function countdown(el) {
    
          let counting = true;
          let i = 1;
          console.log('start count down for ' + el)
          while (i < 10) {
              z = (x) => {
                setTimeout(function(j){ 
                  console.log(j)
                   if (j <= 10)  {
                      z(j+1)

                   }
                   }, 1000, x);
              };
            
              if (i == 1)
                z(i);
              i++;
          }
}
countdown('a')
setTimeout(() => {countdown('b')}, 1050)

robrogers3 left a reply on Logout Route Middleware Not Working • 2 weeks ago

what's the password cache? the session?

robrogers3 left a reply on Setting Up Different Queues For Jobs • 2 weeks ago

have you tried specifying a queue

Job::dispatch('special_queue')?

robrogers3 left a reply on Iterating $request • 2 weeks ago

hey. just do dd($_REQUEST) and then you will have your answer.

robrogers3 left a reply on Logout Route Middleware Not Working • 2 weeks ago

The route middleware executes in the order of registration. So, IF, you put yours below the auth middleware, yours never gets hit. The auth middleware checks first and wins thus redirecting you to the login page. (or wherever)

if you've registered your MW before auth, well then let's take a closer look.

robrogers3 left a reply on Valet No Longer Working, "Unable To Determine Linked PHP" • 2 weeks ago

What's likely happened is the symlink from /usr/local/bin/php(some version) has been lost.

what you can do in run the brew link command.

it will look something like: brow link php70 (or whatever version you are running.)

to find out do this: $ ls -l /usr/local/Cellar/|grep php

2nd March, 2018

robrogers3 left a reply on Collection Sort By Multiple Fields • 3 months ago

This is a short coming of the collection method sort by. You really need a compare function.

so mid way, i'd do something like:

$tempArray = $myCollection->toArray();

$fieldsToSortBy = array('name', 'age', 'start_order');

usort($a, function ($a, $b) use ($fieldsToSortBy) {
    $position = array(true => -1, false => 1);
    $order = true;
    foreach ($fields as $value) {
        $order = ($a[$value] < $b[$value]);
        if ($a[$value] !== $b[$value]) {
            return $position[$order];
        }

    }
    return $position[$order];
});


usort($tempArray, 'multiFieldSort')

//then continue;
$originalCollection = collect($tempArray);

//...

1st March, 2018

robrogers3 left a reply on How To Download A File From A Blob Url • 3 months ago

what happens, nothing??

robrogers3 left a reply on Cannot Call Auth::routes In Other Locations • 3 months ago

can you post the entire error message?

robrogers3 left a reply on Map Data From Database To An Array Then Insert Array • 3 months ago

public function mapToIdUsingForEach()
  {

    $originalNamestoThingMap = [
                        ['name' => 'John', 'thing' => 'Thing1'],
                        ['name' => 'Jane', 'thing' => 'Thing2']
                        ];

    $idToThingMap = [];
    foreach($namesToThingMap as $map) {
      $record = UserModel::where('name', $map['name'])->first();
      if (!$record) {
        continue;
      }
      $idToThingMap[] = ['id' => $record->id, 'thing' => $map['thing']];
    }

    return $idToThingMap;
 }

28th December, 2017

robrogers3 left a reply on AJAX - Post Table Rows And Individual Inputs • 5 months ago

I may have missed a couple spots let me know if it's totally not working and I'll create a fiddle.

robrogers3 left a reply on AJAX - Post Table Rows And Individual Inputs • 5 months ago

This is TRIVIAL with Vue. Trivial. Watch Vuecasts. but this will get you MORE than started:

you blade file:

@extends('layouts.app')
@section('content')
<shipments template="inline">
    <modelx>
<table>
        <tr>
        <td>
            {{ csrf_field() }}
            <select v-model="payer_id" name="payer_id" class="js-basic-single payer_id" style="width:100%;" id="payer_id">
                 <option></option>
                 @foreach($customers as $customer)
                 <option value="{{ $customer->id }}">{{ $customer->customer_name }}</option>
                 @endforeach
            </select>
            <div id="existing_biller_details" class="hidden" name="existing_biller_details" style="margin-top:10px;">
                </div>
            <select v-model="deposit_type" class="form-control deposit_type" name="deposit_type" id="deposit_type">
            <option disabled selected>Please Select</option>
            <option value="Check">Check</option>
            <option value="Cash">Cash</option>
                <option value="ECheck">ECheck</option>
            </select>
            <div name="check_number" id="check_number" class="hidden">
                  <input v-model="check_number" type="text" placeholder="Check Number" class="form-control" id="check_number" name="check_number">
              </div>
            <input v-model="payment_amount" type="text" class="form-control" placeholder="Payment Amount" name="payment_amount" id="payment_amount">
            <input v-model="date" type="date" class="form-control" placeholder="Date of Deposit" name="date_deposit" id="date_deposit">
            <textarea v-model="notes" placeholder="Notes" style="width:100%;" class="form-control" id="notes" name="notes"></textarea>
        </td>
        <td style="width:50%;">
            <table style="width:100%;" id="freight_bill_items">
                <thead>
                
                    <td style="width:30%;font-weight:bold;text-align:center;">Bill No.</td>
                    <td style="width:30%; font-weight:bold; text-align:center;">Amount</td>
                    
                </thead>
                <tbody v-for="paymentDetail in paymentDetails"><!-- as you add this grows automatically -->
                    <tr style="height:40px" class="use a component best"> <!-- use a component best, but also why inputs?? -->
                        <td>
                            <input v-model="paymentDetail.shipment_id" type="text" name="shipmentid" required class="form-control name_list" id="shipment_id" placeholder="Bill No." required>
                        </td>
                        <td style="width:30%;text-align:center;">
                            <input v-model="paymentDetail.amount" type="text" name="amount" required class="form-control name_list" id="amount" placeholder="Amount" required>
                        </td>
                        <!-- you may want a remove button here -->
                    </tr>
            </tbody>
            <tbody>
                <tr class="use a component way better">>
                        <td style="width:30%;text-align:center;">
                                <input v-model="shipment_id" type="text" name="shipmentid" required class="form-control name_list" id="shipment_id" placeholder="Bill No." required></td>
                                <td style="width:30%;text-align:center;">
                                <input type="text" name="amount" required class="form-control name_list" id="amount" placeholder="Amount" required>
                        </td>
                    <td>
                        <button @click="addPaymentDetail" type="button" name="add" id="add" class="btn btn-success clicking add should ">Add</button>
                    </td>
                </tr>
            </tbody>
            </table>
                <div id="freight_bill_items_subtotal;" style="font-weight:bold; padding-top:10px; padding-bottom:10px; text-align:left; background-color: #f0f8ff;">
                SUBTOTAL:
                    Your SubTotal is <span v-text="calculatedSubTotal"></span>
                </div>
            </td>    
        </tr>
        </table>
        <footer>
                <button @click="submitDetails">Submit Details</button>
            </footer>
       
        </div>
    </shipments>

@endsection

your Vue file: (note Vue just works out of the box with Laravel. npm run install. npm run build. DONE!!!!!)

your new vue js file: create this file called Shipments.vue in the js directory

<script>
export default {
    data() {
        return {
            payer_id: '',
            paymentDetails: [], // <-- here is the main difference it's an array of objects
            check_number: '',
            deposit_type: '',
            chock_number: '',
            paymount_amount: '',
            date: '',
            notes: '',
            shipment_id: '',
            amount: ''
        }
    },
    computed: {
        calculatedSubTotal() {
            return 'your math';
        }
    },
    methods: {
        addPamentDetails() {
            let paymentDetail = {
                shipment: this.shipment,
                amount: this.amount
            };
            
            this.paymentDetails.push(paymentDetail); //just add to the array
            this.shipment_id = '';
            this.amount = '';
        },
        submitDetails() {
            let formData = new FormData;
            formData.append('payer_id', this.payer_id);
            //Repeat for all the easy ones.
            //now for payment details:
            this.paymentDetails.each((detail) => {
                formData.append('payment_details[]["amount"]', detail.amount);
                formData.append('payment_details[]["shipment_id"]', detail.shipment_id);
            });
            //https://www.mattlunn.me.uk/blog/2012/05/sending-formdata-with-jquery-ajax/
            axios.post('/payments/createNew', formData) //jus jquery too. just pass it in as data: formData.
            .then(() => alert('success'))
            .catch(error => {
                alert('something is wrong!!')
            });
        }
    }

}

</script>

update app.js

Vue.component('shipments', require('./Shipments.vue'));
const app = new Vue({
    el: '#app'
});


make sure you include the app.js in your html.

then reload the page.

robrogers3 left a reply on Cast Value To Specific Object • 5 months ago

You could use an Accessor and Mutator

https://laravel.com/docs/5.5/eloquent-mutators#defining-a-mutator

so if column is my_interval.

then like this:

Class Foo
{
    public function getMyIntervalAttribute($value)
    {
        return new Interval($value);
    }

    public function setMyIntervalAttribute(Interval $value)
    {
        $this->attributes['my_interval'] = $interval->value;
    }
}

then

$foo = Foo::find(1);

$interval = $foo->interval;

echo $interval->value = 10;

$foo->save();



robrogers3 left a reply on Select In View A Relationshap • 5 months ago

@hamzacreede this $categorie->vehicules()

should be this. $categorie->vehicules

probably.

what does '->test' refer too??????????? what propety.

robrogers3 left a reply on Select In View A Relationshap • 5 months ago

@Snapey yeah can you write my code too?

jeez

27th December, 2017

robrogers3 left a reply on Select In View A Relationshap • 5 months ago

i'm not sure what your specific problem is but this

 @foreach ($Conducteurs as $categorie)

                       <tr>

                     @foreach ($Conducteurs as $categorie)

                               <td>{{$categorie->vehicules()->test   }} </td>

                    @endforeach 

                      @foreach ($Conducteurs as $categorie)

                               <td>{{$categorie->conducteurs()->test   }} </td>

                    @endforeach

                       </tr>

   @endforeach

is wrong. well, it's also confusing what does the 'test' property refer to?

either way you are looping 3 times when you only need one loop.

in the outer loop. you have access to the 'current' categorie

so the two inner foreachs don't require you to loop them.

maybe you want?

foreach ($categorie->vehicules()) ??

and foreach ($categorie->conducteurs()) where you print out the test property each time.

robrogers3 left a reply on OrderBy Not Working Correctly • 5 months ago

okay so your ordering by what the request says, in the direction of direction.

so it might be by 'id' desc or asc based on 'dir'.

can you Log or print out the sql and the bindings.

so b4 the get().

do dump($objQuery->toSql());

and dd($objQuery->getBindings());

let us know what you get.

15th December, 2017

robrogers3 left a reply on Help Me Fix A Vue.js Train Wreck (well Entire Js Trainwreck) • 6 months ago

Well I came up with an answer just plain js, that can work with the ugly Vue instances.


function Validator() {
    "use strict";
    this.errors = [];
    this.objectType = getQueryVariable('item');
    this.id = getQueryVariable('item_detail');
    this.form = null;
    this.currentHandler = null;
}

Validator.prototype.validate = function () {
    this.currentHandler = this.handleErrors;

    let formData = this.collectFormData(true);

    formData.append('validate', true);

    axios.post('/admin/validate.php', formData)
        .then((response) => {
            console.log(response.data);
            this.currentHandler = this.displayWarnings;
            this.verify();
        }).catch(error => {
        this.handleCatch(error)
    })
};
Validator.prototype.collectFormData = function ($validate) {

    let formData = new FormData(this.form);

    formData.append('object_type', this.objectType);

    formData.append('id', this.id);

    if ($validate) {
        formData.append('validate', true);
    }

    return formData;
};

Validator.prototype.submitForm = function () {
    this.form.submit();
};

Validator.prototype.handleWarnings = function () {
    this.displayWarnings(this.errors)
        .then(() => {
            this.errors = [];
        })
        .catch((data) => {
            if (data === 'cancel') {
                this.submitForm();
            } else {
                swal('very weird data really can only be cancel');
            }
        })
};

Validator.prototype.handleErrors = function () {
    this.displayErrors(this.errors);
    this.errors = [];
};
Validator.prototype.verify = function () {
    let formData = this.collectFormData(false);

    this.currentHandler = this.handleWarnings;

    axios.post('/admin/validate.php', formData)
        .then(() => {
            this.submitForm();
        }).catch(error => {
        this.handleCatch(error);
    });
};


Validator.prototype.displayWarnings = function (messages) {
    return swal({
        title: "You've got potential (problems).",
        text: messages,
        type: "warning",
        width: 800,
        showCancelButton: true,
        allowEscapeKey: false,
        allowOutsideClick: false,
        cancelButtonText: "I've got my reasons.",
        confirmButtonText: "Let's fix it."
    });
};

Validator.prototype.displayErrors = function (messages) {
    swal({
        title: 'Ouch!',
        html: messages,
        width: 800,
        type: 'error'
    })
        .catch(() => {
            console.log('no oop')
        })
};

Validator.prototype.handleCatch = function (error) {
    if (error.response) {
        this.errors = error.response.data;

        if (error.response.status === 422 || error.response.status === 422) {
            this.errors = error.response.data.join('<br>');
        }

        this.currentHandler();
    } else if (error.request) {
        // The request was made but no response was received
        // `error.request` is an instance of XMLHttpRequest in the browser and an instance of
        //swal("Wow we have problems", error.response.data, 'error');

        console.log(error.request);
    }
};

Validator.prototype.handleSubmission = function (e) {

    this.form = document.querySelector('form.contentdetail');
    this.validate();

    validate_submit(e, () => {    
        this.validate();
    });
};


then I call it on submitting the form. via addEventListener


    $('[data-submit-call-back]').on('submit', function (e) {
        e.preventDefault();

            let validation = new Validator();
            validation.handleSubmission(e);
        }
    });

robrogers3 left a reply on How To Model This Example With Custom Fields • 6 months ago

@oscarl to answer your quest above. Yes. But I would name the column 'fields'

ps. recent versions of mysql support the json data type https://dev.mysql.com/doc/refman/5.7/en/json.html

ps. what's an answer. and how does that relate to this.

Also, you may want an another column for 'required_fields'. This is also json. It allows you to separate the custom and required, so that users can't clobber required.

Or just (and maybe better) create a custom accessor getAttributRequiredFields where you'd return an array of those two fields. Why monkey with the db for this?

robrogers3 left a reply on How To Model This Example With Custom Fields • 6 months ago

I'm wondering if you can take advantage of json encoding for Form Inputs and their associated values.

Essentially, I don't think you need to normalize this at all, and you won't be querying for a fieldType or fieldValue.

this makes your required Models go down from 5 to 3. and will likely speed up your site.

defining and pulling out json is trivial. well automatic.

https://laravel.com/docs/5.5/eloquent-mutators#array-and-json-casting

you then just store your form field definitions as text. done.

robrogers3 left a reply on Updating Data When Child Component Is Doing A SetTimeout() • 6 months ago

do this from now on:

            Event.$on('copying', (id, event) => {
                if (this.entry.id == id) {
                    this.entry.copying = true;
                }
            });

it's called the fat arrow syntax and it will change your life. it keeps the context when invoked so there are no self = this stuff.

13th December, 2017

robrogers3 left a reply on Updating Data When Child Component Is Doing A SetTimeout() • 6 months ago

so to clarify. note: the

there is a list of children (things) which the parent lists out to display.

when a child emits a 'selected' event, the parent adds that child to a list which is (at some point) posted to the server. and while it's ajaxy-fying, the parent and the children are still whirring in the background (changing the status on all sorts of things). When the ajax call returns, it then clobbers everything that has happened since it was invoked.

I'm not sure about this:

then the child doesn't realise it should keep asking the back-end for updates of itself.

why it it stop?

That said how many race conditions do we have going on here? 2 racing for the same thing (the set of status flags that correspond to the children?)

  • the child getting it's status (on whether it should keep asking the backend for updates
  • the parent keeping ahold of the correct 'status flag set' for the children.

i.e. ajax is happening (with a certain status set for the children), a child emits event which in turn updates that same said set of flags, then the parent returns from the ajax call which then clobbers the current status set for the new one(???)

maybe I don't got it all.

That said we don't want this synchronous but you do need to maintain state. I think you need 2 things.

  1. the parent tells the children when to emit the event. It's in charge. Use an async function for this.
  2. you do need a mutex lock of some sort. perhaps the parent has two sets of flags, processing and listing. how could this work? do you merge them in after the ajax call returns? And if so which list wins -- if there are conflicts. I think probably the return results. I'm not sure about the data set.

maybe you only need number 1 above. but with a chance to break a lock. essentially, after it notifies the children it will wait until the all respond 'completed', and when they do then the ajax call is made. But sometimes maybe they won't all respond, for some weird reason, and in that case you break the lock (i.e. don't wait anymore) -- but this should happen very rarely.

meh?

12th December, 2017

robrogers3 left a reply on Help Me Fix A Vue.js Train Wreck (well Entire Js Trainwreck) • 6 months ago

@burlresearch thanks for the reply. We want to hit the repo, and the end points for ajax work just fine.

it's this damn legacy js that's killing me. I don't know how Vuex can help here -- outside of data management. It's the functionality I need. i.e. methods.

robrogers3 left a reply on Guzzle Sending 2 Requests On Same Time Ask Question • 6 months ago

I don't see any reference to session!.

where are you storing the token for the second call?

or are you doing the calls one after the other?

robrogers3 left a reply on How To Show Different Tasks Items According To User Id In Laravel 5.2? • 6 months ago

Well, doesn't a User have Tasks?

if that's the case, use the $user->tasks

if a user doesn't have tasks then update the User Model. Unless you can think of a really good reason not to.

robrogers3 left a reply on Adding 0.000005 To 0.000005? • 6 months ago

you would think it does,

but here's the signature, looks otherwise. weird.

@ 13EN what happens your way?

but yeah, you can probably just do an update $monster = Monster::find($id); $monster->update('cost', $monster->cost + 0.000005); etc.

robrogers3 started a new conversation Help Me Fix A Vue.js Train Wreck (well Entire Js Trainwreck) • 6 months ago

I got myself into a jam by using multiple Vue instances throughout my app.

Here's the deal (it's a little complicated).

  • The app is a CMS, and before submitting data it needs some validation/sanity-checking.
  • BUT, each form is different; it's dynamically rendered based on the schema of the backend table (for starters).
  • So in order to handle this we load a validation script based on the type of object being edited.
  • the scripts are a mix of: jquery, vanilla js, and Vue. (New js is now module based using es6) ** an example: if an Event (like a concert, say) is being submitted then: *** if the event is a Weekend event then start and end times must be 48hrs apart. *** if the event is a Evening dinner event then the duration cannot be more than say 4hrs. *** and before a venue is selected it's availability must be verified.
  • OH, and yeah, some validation is not a hard failure some are just warnings. Like a special weekend event could be longer than normal ones. Here we just want to display a warning. And the User can decide to basically submit as is, or fix the potential problem.

Now I'm trying to unify all validation that requires ajax to go through one Vue instance.

  • Where it handles: ** All ajax requests for validation, displays Errors and Warnings, as well as calling validation that doesn't require a server call.

So what's the problem? Some of the validation is done with Vue and is triggered on the current validation handler. Which means, that the Object specific Vue based validator instance and the new Vue ajax validation handler instance have to be mounted on the same DOM element. Which means, they conflict and clobber each other. Well one wins, usually the the Object specific one. But even so it's data is gone (v-model specific data). And of course the Vue ajax validation instance is gone.

So what are my options? So far I've come up with:

  • Using a mixin. It's probably the best. But some validation handlers have no associated Vue instance. They are crusty old jquery mostly. Which means there's nothing to mixin to.
  • Using a plugin but it has the same problems and it's probably not as good as the mixin.
  • Making the validator with vanilla js. But I lose so many of the benefits I get from Vue.
  • I can't see a Component working.

So, in short, what do I do? I'm in a pickle.

robrogers3 left a reply on Check Subscription Status In Blade • 6 months ago

a yes the nav forgot about that.

use a partial. so:

@if($subscribed)
@include('subscribed.partial')
@else
@include('non-subscribed.partia'l
@endif 

robrogers3 left a reply on Guzzle Sending 2 Requests On Same Time Ask Question • 6 months ago

Are the API calls based of a users request?

robrogers3 left a reply on Removing Title (removeAttr) Problem • 6 months ago

Yeah. That's probably the problem

It's got to be some tooltip thingt

robrogers3 left a reply on How To Import Multiple Components From The Same Path(on One Line)? Vue V.2.5.9 • 6 months ago

Your export default is first graph ?

robrogers3 left a reply on Guzzle Sending 2 Requests On Same Time Ask Question • 6 months ago

umm, assuming the calls come from a request, where are you storing the $token.

I don't see any reference to session.

robrogers3 left a reply on Laravel Form Or HTML • 6 months ago

no you are not! it doesn't do anything except make your view files confusing.

unless someone could show me otherwise.

robrogers3 left a reply on How To Import Multiple Components From The Same Path(on One Line)? Vue V.2.5.9 • 6 months ago

ps.

export should look like this

foo.js

function cube(x) {
  return x * x * x;
}
const foo = Math.PI + Math.SQRT2;
export { cube, foo };

import would look like this: bar.js

import {cube, foo} from 'bar';

does it look similar?

robrogers3 left a reply on How To Import Multiple Components From The Same Path(on One Line)? Vue V.2.5.9 • 6 months ago

ok number one, let's see your Graph.vue file.

it's weird you are exporting 2 components from the same file.

do you have 2 templates??

anywho, let's see your Vue files.

the import is correct.

I assume you registered it in the Vue instance.

components: { FirstGraph, SecondGraph }

robrogers3 left a reply on Removing Title (removeAttr) Problem • 6 months ago

are you using a tool tip or something to display the titles. because you can't hover over a div?

your code does (re-)set the title.

robrogers3 left a reply on Check Subscription Status In Blade • 6 months ago

@kishoresai438

return view('index', $isSubscribe); <-- nope need to use compact or ->with()

but plus one anyway.

@Mick79

are there any common elements between paying and non paying users?

if there is not, are very few. Then at least use a different view file.

you will save a lot of headaches.

ps. let me know if you need help with the view files.

robrogers3 left a reply on Eloquent API - Different Resource For Different Requests • 6 months ago

Well I'm sorry to say we are both dumb.

$ php artisan make:resource UserFoo;

$ php artisan make:resource UserBar

public function someMethod()
{
    $userFoo = new UserFoo(User::find(1));

    $userBar = new UserBar(User::find(1))

    it turns out the resource property is whatever you pass in.
    dump($userFoo == $userBar); //maybe if you make them the same.

    $userFooTwo = new UserFoo(DummyModel::find(1));

    dump($userFoo == $userFooTwo);//unless you try really hard.
}

it turns out the resource property is whatever you pass in.

11th December, 2017

robrogers3 left a reply on Best Method To Manage Tables Of Data. • 6 months ago

I have done this with Vue js and it is very very easy.

I can give you my complete package. It's called DataGrid.

In the meantime look at this: https://vuejs.org/v2/examples/grid-component.html

and it's really just a matter of fetching the data from the server.

robrogers3 left a reply on Model With Status Attribute. How To Handle? • 6 months ago

Well you could create a method in the Model say:

public function manage($force == false)
{
    //works like an update but first checks status.

    if ($this->status == 0 || $force) {
        //update $this model. use request()
        return;
    }

    
    throw new \Exception('Sorry but this order is not available for updates');

}

then in controller

public function update(Order $order) { try { $order->update() return view('awesome'); } catch (Exception $e){ $request->session()->flash('status', 'sorry charlie'); return view(''); } }

robrogers3 left a reply on Eloquent API - Different Resource For Different Requests • 6 months ago


public function toArray($request)
{
    return [
        'id' => $this->id,
        'name' => $this->name,
        'email' => $this->email,
        'secret' => $this->when($this->isAdmin(), 'secret-value'), // LOOK HERE.
//secret key will only be returned in the final resource response if the  $this->isAdmin() method returns true.
        'created_at' => $this->created_at,
        'updated_at' => $this->updated_at,
    ];
}

public function isAdmin()
{
    return  Auth()->user()->hasRole('admin');   
}

but that's trivial. and assumes the general keys are generally the same. if you want more flexibility I'm sure you could return a method that returns an array based on the request.

not tested though.

robrogers3 left a reply on Strange Error: Vue.component Is Not A Function • 6 months ago

honestly I think there is something screwy in the package. well it's looks weird to me. he does NOT import Vue in main.js.

I wonder if he's depending on Vue being loaded from the CDN or something. But his example doesn't use it.

post you bootstap.js file and your app.js file

also make sure Vue is available in the console. just type Vue and see what happens.

robrogers3 left a reply on Strange Error: Vue.component Is Not A Function • 6 months ago

what happens if you type this: Vue.component

into the console in the dev tools.

robrogers3 left a reply on Laravel - AJAX Pull Along With Storage URL • 6 months ago

Is this working for you know? If so can you please close it.

robrogers3 left a reply on Add Variable To Auth Registration By The URL • 6 months ago

try this

<form action="{!! route('register', ['groupid' => $groupid]) !!}">
    html here
</form>

the array after the route name, is the parameters your missing.

10th December, 2017

robrogers3 left a reply on Hide Admin User In View • 6 months ago

Damn I'm an idiot I can't believe I missed the missing get.

That's the problem. As soon as I saw flip whops.

So after the where add a ->get()

Fixed !!!

Edit Your Profile
Update

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