spodlogar

Web Developer at Permit.com

Experience

90,230

8 Best Reply Awards

  • Member Since 2 Years Ago
  • 947 Lessons Completed
  • 1 Favorite

10th April, 2018

spodlogar left a reply on How To Get User Details In Laravel Passport • 2 months ago

There is no default user info route in Passport.

You need to create a route in api.php that returns the current user information.

13th March, 2018

spodlogar left a reply on Forcing A Unique Rule To Ignore A Given ID In Form Request • 3 months ago

@tykus has a pretty good solution. Does that work for you?

spodlogar left a reply on Forcing A Unique Rule To Ignore A Given ID In Form Request • 3 months ago

If you have a user to edit you should have a User model to get the id from

spodlogar left a reply on Forcing A Unique Rule To Ignore A Given ID In Form Request • 3 months ago

Convert it to the array syntax.

return [
                'name'=>['required'],
                'email'=>['required', 'email', Rule::unique('users')->ignore($user->id)]
]

spodlogar left a reply on Forcing A Unique Rule To Ignore A Given ID In Form Request • 3 months ago

Can you post the rest of the update method so I can get a little more context?

spodlogar left a reply on Forcing A Unique Rule To Ignore A Given ID In Form Request • 3 months ago

If you have an authenticated user you can get the user from the request.

9th March, 2018

spodlogar left a reply on Debounce From Global Mixin For Live Search • 3 months ago

Alternatively, since you don't want to use Lodash you could use this little debounce library https://www.npmjs.com/package/debounce

spodlogar left a reply on Debounce From Global Mixin For Live Search • 3 months ago

I would recommend using Lodash for debouncing.

it makes it as easy as:

    // ADD THIS
    import _ from 'lodash';


    import { mapGetters } from 'vuex';

    export default {
        props: {
            gender: {
                type: String,
                required: true
            }
        },
        computed: {
            ...mapGetters([
                'loadedAthletes'
            ]),
            athleteSearchString: {
                get() {
                    return this.$store.getters.athleteSearchString;
                },
                set(value) {
                    this.$store.commit('setAthleteSearchString', value);
                }
            }
        },
        methods: {
            /**
             * Search for athletes
             * @return {void}
             */
        
            // UPDATE THIS
            search: _.debounce(function() {
                axios.post(route('athlete.search'), {
                    searchString: this.athleteSearchString,
                    gender: this.gender
                }).then((response) => {
                    if (this.athleteSearchString == '') {
                        this.$store.commit('setAthletes', this.loadedAthletes);
                    } else {
                        this.$store.commit('setAthletes', response.data);
                    }
                }).catch((error) => {

                });
            }, 200)
            // ^ ADD THE TIMEOUT
        }
    }

7th March, 2018

spodlogar left a reply on What Happen This Error? • 3 months ago

Meaning DB Credential Error...

spodlogar left a reply on What Happen This Error? • 3 months ago

Yep. Go ahead and connect a database, run your migrations and see if it clears that up.

spodlogar left a reply on What Happen This Error? • 3 months ago

That is a SQL connection error

spodlogar left a reply on What Happen This Error? • 3 months ago

So do this. Open the storage/logs/laravel.log file and delete all the content.

Then do whatever threw that error again and post the content of the laravel.log file.

spodlogar left a reply on Trying To Send Form When Select Changes. • 3 months ago

Great! :)

spodlogar left a reply on What Happen This Error? • 3 months ago

In your .env file what value do you have for the SESSION_DRIVER key?

spodlogar left a reply on What Happen This Error? • 3 months ago

Are there any files in the storage/framework/sessions directory?

spodlogar left a reply on Trying To Send Form When Select Changes. • 3 months ago

Yes. That should definitely work ?

spodlogar left a reply on What Happen This Error? • 3 months ago

and I'm assuming the path is correct?

spodlogar left a reply on What Happen This Error? • 3 months ago

try running:

php artisan cache:clear

and

php artisan view:clear

spodlogar left a reply on Trying To Send Form When Select Changes. • 3 months ago

In a Vue Template, the this keyword is obsolete.

This is how I would do it:

<span class="pull-right">
    <form method="POST" v-on:submit="update_status(log.id)" ref="form">
        <strong>Change To:</strong>
        <select name = "task_status" v-on:change = "$refs.form.submit()" style="border-radius: 2px; border-color: #0a0a0a;" v-model="log.status">
            <option value="new" >New</option>
            <option value="in-progress">In Progress</option>
            <option value="under-review">Under Review</option>
            <option value="completed">Completed</option>
            <option value="cancelled">Cancelled</option>
        </select>
    </form>
</span>

Using the ref directive on the form we can get a handle on it that we can access from the select element using $refs.

spodlogar left a reply on Using Eloquent To Find Latest Models • 3 months ago

But if you want the Invoices that have Status type "A" as their latest status I would do this:

$filteredInvoices = $invoices->filter(function($invoice) {
    return $invoice->statuses()->latest()->first()->status === "A"
});

spodlogar left a reply on Using Eloquent To Find Latest Models • 3 months ago

This is how I would do it:

$statuses = $invoices->map(function($invoice) {
    return $invoice->statuses()->latest()->first();
});

This will get an array of the first statuses for the queried invoices.

spodlogar left a reply on Directly Loop A Relationship • 3 months ago

This is the way I would do it:

$users = User::someCategory()->get();

$users->flatMap->transactions->each(function($transaction){
    // now you have $transaction
});

spodlogar left a reply on Directly Loop A Relationship • 3 months ago

This is the way I would do it:

$users = User::someCategory()->get();

$users->flatMap->transactions->each(function($transaction){
    // now you have $transaction
});

spodlogar left a reply on HTML Checkbox And Eloquent Variable • 3 months ago

With raw Laravel the cleanest way is this:

<input type="checkbox" name="is_hirable" id="is_hirable" {{ $isHirable ?? 'checked' : '' }} />

spodlogar left a reply on Directly Loop A Relationship • 3 months ago

Let see if I understand this...

You have Users and Transactions and you want to return all the Transactions in a specific User category.

Is that correct?

spodlogar left a reply on HTML Checkbox And Eloquent Variable • 3 months ago

If you have Vue in your project the cleanest way to do it is using the checked property.

<input type="checkbox" name="is_hirable" id="is_hirable" :checked="{{ isHirable }}" class="form-control"/>

spodlogar left a reply on How To Add Emoji In The Textbox • 3 months ago

I would recommend using At.js or Tribute with an emoji api like https://api.github.com/emojis

15th February, 2018

spodlogar left a reply on Is There A Way To Get A List Of Rows With A Unique Column • 4 months ago

Thank You guys for all the suggestions. I ended up getting something similar to what @petrit suggested.

7th February, 2018

spodlogar left a reply on Is There A Way To Get A List Of Rows With A Unique Column • 4 months ago

I will need to give that a try. That would be awesome if that worked though.

spodlogar left a reply on Is There A Way To Get A List Of Rows With A Unique Column • 4 months ago

@st8113 that works... But I want to return the whole post. Not just the channel column. Do you know if there is a way to do that?

spodlogar left a reply on Is There A Way To Get A List Of Rows With A Unique Column • 4 months ago

@petrit the groupBy function just returns an array with the Channel as the key and all the Posts below that level.

I don't want to have to get all the Posts in order to get the channels.

as @cmgmyr said distinct is the solution but Laravel does not let you set the column that you want to be distinct.

Looks like a raw query is the only solution.

spodlogar left a reply on Is There A Way To Get A List Of Rows With A Unique Column • 4 months ago

@cmgmyr The problem with that is it returns Posts that are entirely unique. I just want posts with a unique channel.

spodlogar started a new conversation Is There A Way To Get A List Of Rows With A Unique Column • 4 months ago

I have a Post model with a Channel column and I want to get all the channels but this:

Post::all()->pluck('channel');

returns several duplicates.

I also do not want to have to get all Posts. I want to just get posts with a unique channel.

Anybody know if this is possible with Eloquent?

10th November, 2017

spodlogar started a new conversation Prevent Synchronous Job Running • 7 months ago

Is there a way to make Laravel queue jobs run asynchronously using the Redis Queue?

8th November, 2017

spodlogar left a reply on PhpStrom Theme And Colour Schemes • 7 months ago

Looks like the Dayle Rees Slime color scheme with the Material UI Theme

spodlogar left a reply on PhpStrom Theme And Colour Schemes • 7 months ago

I am pretty sure it is the Material UI Theme

2nd November, 2017

spodlogar left a reply on How To Create Dynamic Fields And Store The Values Into Database • 7 months ago

So each field gets stored individually in the DB

spodlogar left a reply on How To Create Dynamic Fields And Store The Values Into Database • 7 months ago

You would not want to store as an array...

your payload would come in from the front end as something like this:

"fields": [
  {
    "id": 1,
    "name": "name",
    "type": "string",
    "value": "John Jones"
  },
  {
    "id": 2,
    "name": "email",
    "type": "email",
    "value": "[email protected]"
  },
  {
    "id": 2,
    "name": "message",
    "type": "text",
    "value": "some longer message"
  }
]

you would then loop through the fields and get the models associated by the id and update them with the new value.

spodlogar left a reply on How To Create Dynamic Fields And Store The Values Into Database • 7 months ago

You will need a forms table and a fields table.

Each field would have a form_id and a value.

spodlogar left a reply on How To Create Dynamic Fields And Store The Values Into Database • 7 months ago

like something to create a form builder? Or more like custom fields on a model?

13th September, 2017

spodlogar left a reply on How Can I Check If The App Is Using The ConvertEmptyStringsToNull Middleware? • 9 months ago

I believe it creates one if there is not one and resolves it if there is one already.

It should behave the same.

spodlogar left a reply on Vue Interpolation • 9 months ago

in Blade you need to escape the curly braces.

Give this a try

public function index () {
$text = 'hello @{{ xss vulnabilities }}';

return view('welcome', compact('text'));

}

// the screen will go blank if your js file is not minified but it will alert when minified
in blade
<h1>{{ $text }}</h1>

spodlogar left a reply on How Can I Check If The App Is Using The ConvertEmptyStringsToNull Middleware? • 9 months ago

This is how you can do that

app()->make(App\Http\Kernel::class)->hasMiddleware($middleware)

spodlogar left a reply on How Can I Check If The App Is Using The ConvertEmptyStringsToNull Middleware? • 9 months ago

You need an instance of App\Http\Kernel to call the hasMiddleware method on?

spodlogar left a reply on How Can I Check If The App Is Using The ConvertEmptyStringsToNull Middleware? • 9 months ago

I see what you are saying

spodlogar left a reply on How Can I Check If The App Is Using The ConvertEmptyStringsToNull Middleware? • 9 months ago

in the app/Http/Kernel.php

protected $middleware = [
    \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
    \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
    \App\Http\Middleware\TrimStrings::class,
    \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, // BOOM
    \App\Http\Middleware\TrustProxies::class
];

spodlogar left a reply on Laravel Not Throwing Error Saving • 9 months ago

@spodlogar can u explain somethin? do i need to use

$user = Auth::user();
    return view('services.create')->withUser($user);

in every function , controller?

No. you can just use Auth::user() or the helper function auth()->user().

spodlogar left a reply on Laravel Not Throwing Error Saving • 9 months ago

Awesome

spodlogar left a reply on Laravel Not Throwing Error Saving • 9 months ago

Yes delete this part

{{ Form::text('users_id',$user->id,['class' => 'form-control','required' => '', 'maxlenght' => '10'])}}

It should still work fine

spodlogar left a reply on Laravel Not Throwing Error Saving • 9 months ago

Instead of this

$service->users_id = $request->users_id;

do this

$service->users_id = $request->user()->id;
Edit Your Profile
Update

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