Borisu

Experience

96,240

44 Best Reply Awards

  • Member Since 1 Year Ago
  • 654 Lessons Completed
  • 22 Favorites

30th May, 2018

Borisu left a reply on User Permission Using Service Repository • 2 weeks ago

In that case you can check if the user has a permission, as it is a table in your database. You can use where to experiment and finally even add a scope to filter the data.

Borisu left a reply on Routing Under One Parent Folder • 2 weeks ago

Yes but then you will have a show method on the controller instead an index:

Route::group(['middleware' => ['auth'], 'prefix' => 'fixtures'], function() {
    Route::get('/', '[email protected]');

    Route::get('/competition/{competitionId}', '[email protected]');

    Route::get('/hometeam-vs-awayteam/{hometeamId}', '[email protected]');
});

You can find more here: https://laravel.com/docs/5.6/routing#route-parameters

29th May, 2018

Borisu left a reply on Loop Through Axios Data To Display Thumbnails • 3 weeks ago

Well you have to parse the html you get back and pick out the href's of the anchor tags. You can then give the response data to cheerio (https://github.com/cheeriojs/cheerio) and play around with it. It should be fairly easy to get the images since they all share the itemprop "thumbnailUrl". At this point you have a list of valid html, just append it to your page and you're done.

Borisu left a reply on Undefined Variable: Peaple • 3 weeks ago

I'm with tykus on this, I think you're visiting the wrong url, where there is no variable people (nor peoples). And by the way peoples is not correct english, since people is already plural, might want to be careful with that...

Borisu left a reply on Conditionally Pushing Event Listeners To Queue • 3 weeks ago

Did you register it properly? Having the class is not enough.

Borisu left a reply on Access Multiples Authenticate Guards On Subdomain? • 3 weeks ago

Watch this video it will clear it all up:

https://www.youtube.com/watch?v=iKRLrJXNN4M&t=1706s

Borisu left a reply on User Permission Using Service Repository • 3 weeks ago

It depends what kind of permission-system you're using. Your own, Voyager or something else?

Borisu left a reply on Routing Under One Parent Folder • 3 weeks ago

You can do something like this:

Route::group(['middleware' => ['auth'], 'prefix' => 'fixtures'], function() {
    Route::get('/', '[email protected]');

    Route::get('/competition', '[email protected]');

    Route::get('/hometeam-vs-awayteam', '[email protected]');
});

The prefix keyword will put the fixtures in front of all links in the group. If you would like to create some named routes you can use 'as => 'fixtures.' To prefix the names with fixtures. <- note the dot.

You can name the controllers anything you want ;) and yes it's actually a good idea to have three separate controllers :)

Borisu left a reply on Undefined Variable: Peaple • 3 weeks ago

You missed an s in peoples

// you have
url = "{{ route('peoples.edit', ['id' => $people->id]) }}" + '*apiPrefix*' + '/peoples/' + id + '/edit';

// should be
url = "{{ route('peoples.edit', ['id' => $peoples->id]) }}" + '*apiPrefix*' + '/peoples/' + id + '/edit';

24th May, 2018

Borisu left a reply on Search The Database But Does Not Pass The Value • 3 weeks ago

@GeorgeMartins it seems you have different names: one is modelo_id and the other cliente_id Did you change it? If the request name is differs from the validation name, it won't pass validation and you'll just get redirected back to your page.

Is your intended process as follows: User visits page where they see a form, they select something in the form and post it to the server. Based on the input you search for a result in your tables and display that to the user. (So if this is true, we might be looking at a different problem).

21st May, 2018

Borisu left a reply on Hello Newbie Here • 4 weeks ago

@tykus awesome tip :)

20th May, 2018

Borisu left a reply on Search The Database But Does Not Pass The Value • 4 weeks ago

@GerogeMartins Yes, sorry about that. pluck actually gives back an array, so it wouldn't work as I suggested. I used Client::get(['id', 'razaosocial']) for testing, which will give you back a collection of models. What tykus said will work correctly. (So this is just personal preference at this point).

Back to the main problem. Did you check your validation? Can you just dd(request()->all()) in your controller and check if the value is inside?

Check your middleware as well. Might be something fishy there, if the dd() doesn't show the value.

18th May, 2018

Borisu left a reply on Search The Database But Does Not Pass The Value • 1 month ago

ouhare's suggestions is not correct as it will pass the array index into the form value and not the actual id. The correct version is:

\@foreach ($cliente as $client)
    <option value={{ $client->id }}>{{ $client->razaosocial }}</option>
\@endforeach

Also if the value is not fillable you'll get an error saying 'Cannot insert into table etc etc.' showing the query to the db with an empty value for cliente_id.

The only other thing I can think of right now is maybe form validation. @GeorgeMartins do you have any and what does it look like?

Borisu left a reply on Laravel Queues • 1 month ago

In that case you can just restart the queue as it will not persist the list of jobs.

17th May, 2018

Borisu left a reply on Laravel Queues • 1 month ago

Theoretically yes, but why would you want to do that? If the queue begins with a 1000 jobs and finished 500 in 24 hours then you'll have only 500 jobs left in the queue. As soon as a job is done it's removed from the list of jobs. You just leave the queue open forever and it will process jobs until you kill the application. No need for any manual action.

Borisu left a reply on Search The Database But Does Not Pass The Value • 1 month ago

@tykus It was just an educated guess why it might not be working.

Borisu left a reply on Check A Single Item Within A Query Scope • 1 month ago

Do you really have a field with an arrow symbol in the column name? Think about it...

If I understand you have a table with a regions column, which is supposedly a relationship. So just get the objects where the relationship returns an empty object.

Borisu left a reply on Search The Database But Does Not Pass The Value • 1 month ago

You should maybe close the form after the select ;)

Also, what exactly do you mean it shows the value, but it's not passed. Passed where?

Borisu left a reply on Laravel Queues • 1 month ago

Ok putting queues on a separate server is possible, although unless you have an obscene amount of jobs not really practical or necessary. You can have a queue for mass emails, for user notifications, for promotions and what not. This way you can just leave them running as they won't interfere with the rest of the processing. Just as a little experiment, try to fill a queue to the point it starts dropping records... You'll quickly notice it's nearly impossible for a normal applications (unless you have some bad code or something).

Borisu left a reply on What Is The Standard Practice For Laravel + VueJS Authentication? • 1 month ago

Hey, a very simple rule to go by. Use the backend for business logic and the front-end for ease-of-use. You can even use the built-in authentication, it works perfectly.

Borisu left a reply on Login Redirection • 1 month ago

What you need is a middleware to check if the currently logged in user is also verified and has supplied a company name. This should be fairly easy to implement.

Borisu left a reply on Array Object Pass In Modal Using Jquery • 1 month ago

Then you'll have to find the select you wish to hydrate and append an option tag to it with the values from response. Something like

$select = $('#target-select')
response.options.forEach(function(item) {
    $select.append('<option value="' + item.value + '">' +item.name + '</li>')
}

Next time please be very precise on what you have and what you exactly need...

Borisu left a reply on Hello Newbie Here • 1 month ago

Nope. This is just for Jeffreys series.

Borisu left a reply on Trying To Setup A New Notification For Updating User Password • 1 month ago

Hi, you don't really need a whole class per se. All you need is the following (to send the token):

$user->notify(new ChangePasswordNotification());

This would be the easiest way to do what you want.

Just to clarify, are you trying to send them a confirmation link or just notify them of the change?

Borisu left a reply on Session Variables Missing After Fail Logging In. • 1 month ago

Great! Consider marking the question as done ;)

Borisu left a reply on Auth::attempt() Not Checking Password For Another Guard • 1 month ago

Ok try to dd() the current user right before you check the credentials. That way you'll see if there is something happening before you arrive at that point

16th May, 2018

Borisu left a reply on Do You Know What Is Necessary To Have A Search Autocomplete Input Text With Laravel? • 1 month ago

Per documentation (please read it): http://api.jqueryui.com/autocomplete/

you can provide an array of objects in the form

[{label: 'Label', value: 'Value'}, ...]

Where label is displayed to the user and value is the value inserted into the input box.

$conferences = $conferences->map(function($conference) {
    return ['label' => $conference->name, 'value' => $conference->id];
});

This is a very very basic autocomplete functionality, if you want to show the customer in which field his query is valid, you'll have to pay for a service like Algolia.

Borisu left a reply on Do You Know What Is Necessary To Have A Search Autocomplete Input Text With Laravel? • 1 month ago

So you're getting the double conf conf because you're transforming your data after you get it from the eloquent query

// in the foreach loop:
$data[] = ['id'=> $value->id, 'value' => $value->name . " " . $value->name];

The second error is also connected to this data transformation, since the city key is no longer present in the result, you cannot show it. I would suggest you pass back the collection directly.

return response($conferences);

What i meant with checks is to validate the user input before doing anything with it. So in fact the first thing you do in your controller is:

$request->validate([
    'term' => 'required|alpha'
]);

It's best if you just use a custom rule for the input validation...

Borisu left a reply on Vue Compiled Mixed With Runtime • 1 month ago

Well you have a lot of choices. You can make a single generic wrapper component with the functionality you need. You might use inline templates. You just might need some vanilla js... Maybe if you post some of the concrete problems you want to solve it will be easier to give a comprehensive in-depth reply ;)

Borisu left a reply on Auth::attempt() Not Checking Password For Another Guard • 1 month ago

Did you logout first? The guard usually first checks if someone with the same id is already logged in. Next step would be to check if your guard is properly setup...

Borisu left a reply on Pagination Page 2 Return Page 1 On Production Server • 1 month ago

Maybe a silly question, but do you have more than 10 values in the list?

Borisu left a reply on Trying To Setup A New Notification For Updating User Password • 1 month ago

You can open the PasswordBroker to see exactly what is happening there. Since the sendResetLink is a method on that class and the class is not macroable, your best bet is to make your own class with the functionality you need which implements the PasswordBroker class. This way you can extend it and keep some of the nice functionality. You could just try to put the logic for the separate steps in your controller, make it work there and when it's done start extracting to dedicated classes. This is usually an easier approach to complex multi-step processes (in my opinion).

Borisu left a reply on Session Variables Missing After Fail Logging In. • 1 month ago

You're using the flash function, which will show the flash message only to the next view in the chain. Usually using middleware you go through a couple of layers and the flash gets lost. Try saving the message to the session instead of flashing it. If it works you'll know it's a problem with the amount of layers you have in your app...

Borisu left a reply on Do You Know What Is Necessary To Have A Search Autocomplete Input Text With Laravel? • 1 month ago

Well on the back-end you're just making a query to your database for the fields you mentioned. So a super simplified version might look like:

public function search(Request $request) {
    $userQuery = $request->get('q'); // where "q" is the name of the input you use
    $conferences = Conference::where('name', 'like', $userQuery)->get();
    return view('your.view', compact('conferences'));
}

This is the back-end. For each letter the user inputs you'll fire a request to your server and trigger this search function. It will return a collection of the conferences which correspond to it. The problem is you don't want to fire a request every time someone types in a letter. There some functionality like the lodash debounce function comes into play and will wait for some time before sending a request to the server, thus minimizing the load on the back-end. To extend the search you can do:

$conferences = Conference::where('name', 'like', $userQuery)
    ->orWhere('city', 'like', $userQuery)
    ->get();

Hope this helps. Don't forget this is absolutely the minimal amount of work to get a result. You should secure with checks and what not.

5th March, 2018

Borisu left a reply on How To Hide Laravel-debugbar In A Specific View. • 3 months ago

You have to do this in the AppServiceProvider. There in the register method you can check if the environment is production and hide it.

if ($this->app->isLocal()) {
    $this->app->register(\Barryvdh\Debugbar\ServiceProvider::class);
}

Similarly you can check if you're on a specific view:

if (! Route::is('some.route', 'another.route')) {
    $this->app->register(\Barryvdh\Debugbar\ServiceProvider::class);
}

I'll leave the optimization to you tho ;)

3rd March, 2018

Borisu left a reply on The Route::is() Method - How To Find Out ? ... • 3 months ago

You don't actually need a method on the class, just get the name of the current route and use in_array('route.name', ['routes', 'more.routes'])

23rd February, 2018

Borisu left a reply on Is It Possible To Inject A Variable Into Route Group Which Is Common For All Inside Routes? • 3 months ago

Yes, but not in the routes. You can use view composers to make a variable available to a certain "group" of views. You can specify which vies will get access to the data, or use wildcards to specify all etc.

https://laravel.com/docs/5.6/views#view-composers

Borisu left a reply on I Want To Build One-to-one Private Realtime Chat With Firebase • 3 months ago

Just check this out: https://laracasts.com/series/get-real-with-laravel-echo Should have everything you need to get started.

Borisu left a reply on Remove URL Query Parameters Form Url • 3 months ago

You're getting the query string because your form method is get. You either just use an anchor tag, or a post request.

<a href="{{ route('user.showProduct', $productProductOption->product->slug) }}">
or
<form method="POST" action="{{ route('user.showProduct', $productProductOption->product->slug) }}">

Borisu left a reply on Testing Mailables Attachment • 3 months ago

Check if you're performing your assert in the right order.

Borisu left a reply on Testing Mailables Attachment • 3 months ago

You don't need to mock the storage function in the mail class, because you have mocked the global storage class. This means any operations related to storing will go to the fake.

Borisu left a reply on Laravel Append Attribute Not Working • 3 months ago

Hi, custom attributes are not automatically appended. You can call

protected $appends = ['averageRating'];

to include it whenever you retrieve a model.

22nd February, 2018

Borisu left a reply on Refactor A Lot Of Conditionals • 3 months ago

You might look at the "Whip monstrous code into shape" series here. There you'll find a couple of ways to do it, including The strategy pattern. It's what you need.

Borisu left a reply on Dynamic Shop Filter • 3 months ago

Are the filters checkboxes?

Borisu left a reply on Bes Practices: Relation Based On Two Columns Or Pivot Table • 3 months ago

Hi, you will probably hear many valid suggestions. My preference in this matter is to put the job title as a third column on the employee_company table. This way you can include it in your queries like so withPivot('job_title'). The pros for this is that it's simple. Another very powerful method is to use database views, which are tables made dynamically from other tables. This way you can have the relationship tables for employee company and company title and employee title or whatever and join all the infos in the db view.

Borisu left a reply on Dynamic Shop Filter • 3 months ago

In your data object store an array of filters. Then use a v-on:click on each filter element which points to a method. The method toggles the presence of the filter value in the filters array. Something like:

<div @click="toggleFilter('someFilter')">someFilter</div>

export default {
    data() {
        return {
            filters: []
        }
    },
    methods: {
        toggleFilter(filterName) {
            this.filters.includes(filterName) ? this.filters.pop(filterName) : this.filters.push(filterName);
        }
    }
}

21st February, 2018

Borisu left a reply on Escape String Parameters For Markdown Emails? • 3 months ago

Maybe just prefix your expressions with a backslash:

// some blade template with markdown
\{{ $someString }}
...

This will evaluate correctly.

Borisu left a reply on Escape String Parameters For Markdown Emails? • 3 months ago

I'm not sure if it will work, but you can try the new Blade::doubleEncode() method. This should escape all special characters and replace them with the html equivalents.

Ref.: https://laravel-news.com/blade-double-encoding-vue-components

20th February, 2018

Borisu left a reply on Route Has Only One Parameter • 3 months ago

Not really. The most you could get is a route like /files/{files}/filename/{filename} and that's just wrong in your case and would also completely change the api

Edit Your Profile
Update

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