sergionader

sergionader

Member Since 1 Year Ago

Experience Points 8,460
Experience
Level
Lessons Completed 75
Lessons
Completed
Best Reply Awards 0
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

07 Nov
1 month ago

sergionader started a new conversation Vue Grid Component For Grouping Data (for Using With A Laravel App)

Hello!

I need to show a tracking issue table that has projects and its issues. The idea is to group by projects:

Project 1
    issue 1, due date 1
    issue 2, due date 2
Project 2
    issue 3, due date 2
    issue 4, due date 3

Or by Due Date:

Due date 1
    issue 1, Project 1
Due date 2
    issue 2, Project 1
    issue 3,Project 2
Due date 3
    issue 4, Project 2

Or even by due date/project:

...
Due date 2
    Project 1
        Issues...
    Project 2
        issues...
...

The ideal situation is to allow the user to group/ungroup them dynamically.

Any suggestions for a good Vue plug-in/library?

Thanks!!!
05 Oct
2 months ago

sergionader left a reply on Using Nova Inside A Current App

Maybe I was clear in my question. I would like to show a nova resource inside my current app and not moving my current app to nova.

I believe that it should be something more people would be interested in.

Thanks!!!

03 Oct
2 months ago

sergionader started a new conversation Using Nova Inside A Current App

  1. In my current app, I have domain/app/clients that display a client list.
  2. I created a Nova resource that does the same: domain/nova/resources/clients
  3. I am trying to figure out how to show the new Nova grid using the old URL (../app/clients).
  4. Also, I don't want a redirect as the user should always the see the 'old' URL (app/clients)/

Any suggestion?

Thanks!

04 Sep
3 months ago

sergionader left a reply on Get The Value Of A Signed Route.

Hey guys,

@aurawindsurfing, the URL was a typo, thanks

@newbie360, I created a middleware and now it's working the way I need. Thanks!

01 Sep
3 months ago

sergionader left a reply on Get The Value Of A Signed Route.

Thanks, @aurawindsurfing I understand how that works.

I am not getting is the following:

  1. User visits http://localhost:8000/test/11?signature=89ffe6d8348dbcbf1b36fb97421742a48d959a7998078c77365922279075455d

  2. route validates it

  3. if not ok, abort

  4. if ok, pass the id to a controller that will show a page.

Any ideas?

Thanks and have a great weekend!

30 Aug
3 months ago

sergionader left a reply on Get The Value Of A Signed Route.

@newbie360, you are correct. Thanks!

@aurawindsurfing, I had done the validating thing as well, but this is not the point. After validating, how can I know who the user to unsubscribe it? Is there any way other than Route::current()->parameters;?

Thank you!

sergionader started a new conversation Get The Value Of A Signed Route.

Hey!

Following https://laravel.com/docs/5.7/urls#signed-urls I generated a signed route:

URL::signedRoute('unsubscribe', ['user' => 1]);
http://localhost:8000/unsubscribe/1?signature=d1964b9477471fa9d0004176f36687928c12a9bb7a4d5085fcb0f334a6398860"

As you can see the URL has the user, 1, and signature, d1964b9....

The route is:

...
})->name('unsubscribe');

I want to retrieve the user. None of these will show it:

$request->all(); result: {"signature":"d1964b9477471fa9d0004176f36687928c12a9bb7a4d5085fcb0f334a6398860"}

$request->user(); result: null

$request->input('user'); result: null

No error is thrown

Any ideas?

Thanks!

31 Jul
4 months ago
30 Jul
4 months ago

sergionader left a reply on How To Apply HTML Tags Inside A Bootstrap Alert Box?

Thanks, @lostdreamer_nl It worked -- how could I have missed it....? :-) Regards!

sergionader started a new conversation How To Apply HTML Tags Inside A Bootstrap Alert Box?

Hi!

It seems very basic, but I couldn't find a solution.

  1. I have a controller that will call a blade: return redirect()->route('app.vendor.search', [$variables])->with('info-success', 'File uploaded successfully.');
  2. the blade has the following code:
                <div class="alert alert-success alert-dismissible">
                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                    <h4>
                        <i class="icon fa fa-check"></i> Success!</h4>
                        {{ Session::get('info-success') }}
                </div>
            @endif```
3) It works very  well. 
4) However, if I try something like 
`....)->with('info-success', 'File <strong>uploaded<strong> successfully.'); ` the "strong" tag will be ignored. As matter of fact all the tags I've tried we ignored. 

Any ideas? 

Thanks  !!

sergionader left a reply on Slack - Message Error Content

Thanks, @ohffs !

I will give it a try.

Sergio

27 Jul
4 months ago

sergionader started a new conversation Slack - Message Error Content

Hello. I set up my server to send a slack message every time an error occurs -- it works perfectly.

However, the message we got lacks some vital information -- for instance, I don't know what was the code (file/line) that failed.

Please take a look here: https://screencast.com/t/vWXLnHOssQ

Is there a way to set to messages to be more useful?

Thanks!!

01 Jun
6 months ago

sergionader left a reply on Users X Unique Email

Hey @Cronix

Typo was my first attempt, but the "class" (that is a table, in fact) comes from here.

'email' => 'required|email|unique:*users*',

I just made another test and tried to validate the field using another table, dealers:

`$rules = ['email' => 'required|unique:dealers,name'];``

Guess what? No error at this time. I really seems to (very well) hidden somewhere....

31 May
6 months ago

sergionader left a reply on Users X Unique Email

Hey @Snapey. Unfortunately not. There is just the 500 server error

**** Symfony\Component\HttpKernel\Exception\HttpException: Class users does not exist in /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php:284
Stack trace:
#0 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(187): Illuminate\Foundation\Exceptions\Handler-&gt;prepareResponse(Object(Illuminate\Http\Request), Object(ReflectionException))
#1 /var/www/html/timesaver/app/Exceptions/Handler.php(60): Illuminate\Foundation\Exceptions\Handler-&gt;render(Object(Illuminate\Http\Request), Object(ReflectionException))
#2 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(83): App\Exceptions\Handler-&gt;render(Object(Illuminate\Http\Request), Object(ReflectionException))
#3 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): Illuminate\Routing\Pipeline-&gt;handleException(Object(Illuminate\Http\Request), Object(ReflectionException))
#4 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#5 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Routing\Middleware\SubstituteBindings-&gt;handle(Object(Illuminate\Http\Request), Object(Closure))
#6 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#7 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php(43): Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#8 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Auth\Middleware\Authenticate-&gt;handle(Object(Illuminate\Http\Request), Object(Closure))
#9 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#10 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#11 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\View\Middleware\ShareErrorsFromSession-&gt;handle(Object(Illuminate\Http\Request), Object(Closure))
#12 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#13 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(63): Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#14 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Session\Middleware\StartSession-&gt;handle(Object(Illuminate\Http\Request), Object(Closure))
#15 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#16 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#17 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse-&gt;handle(Object(Illuminate\Http\Request), Object(Closure))
#18 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#19 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(59): Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#20 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Cookie\Middleware\EncryptCookies-&gt;handle(Object(Illuminate\Http\Request), Object(Closure))
#21 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#22 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#23 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Routing/Router.php(661): Illuminate\Pipeline\Pipeline-&gt;then(Object(Closure))
#24 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Routing/Router.php(636): Illuminate\Routing\Router-&gt;runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#25 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Routing/Router.php(602): Illuminate\Routing\Router-&gt;runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))
#26 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Routing/Router.php(591): Illuminate\Routing\Router-&gt;dispatchToRoute(Object(Illuminate\Http\Request))
#27 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\Routing\Router-&gt;dispatch(Object(Illuminate\Http\Request))
#28 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Foundation\Http\Kernel-&gt;Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#29 /var/www/html/timesaver/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#30 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Fideloper\Proxy\TrustProxies-&gt;handle(Object(Illuminate\Http\Request), Object(Closure))
#31 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#32 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(31): Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#33 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Foundation\Http\Middleware\TransformsRequest-&gt;handle(Object(Illuminate\Http\Request), Object(Closure))
#34 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#35 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(31): Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#36 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Foundation\Http\Middleware\TransformsRequest-&gt;handle(Object(Illuminate\Http\Request), Object(Closure))
#37 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#38 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#39 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Foundation\Http\Middleware\ValidatePostSize-&gt;handle(Object(Illuminate\Http\Request), Object(Closure))
#40 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#41 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(51): Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#42 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode-&gt;handle(Object(Illuminate\Http\Request), Object(Closure))
#43 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#44 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#45 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\Pipeline\Pipeline-&gt;then(Object(Closure))
#46 /var/www/html/timesaver/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel-&gt;sendRequestThroughRouter(Object(Illuminate\Http\Request))
#47 /var/www/html/timesaver/public/index.php(55): Illuminate\Foundation\Http\Kernel-&gt;handle(Object(Illuminate\Http\Request))
#48 {main}

sergionader left a reply on Users X Unique Email

Hey @jake.admin@gmail.com. Thanks but it's not working. It worked on a fresh install but it has to work on the live system.

I will keep researching and until I find a solution, I will manually check the email uniqueness.

30 May
6 months ago

sergionader left a reply on Users X Unique Email

@jake.admin@gmail.com, your suggestions to use $this-> was good but no success. I tried both ways you suggested and it didn't work.

And even if the ways I was using was not the best ($request->validate( $rules, $customMessages); it did work on a fresh Laravel install...

There is something somewhere else that is being called just before the error is thrown....

sergionader left a reply on Users X Unique Email

Hey @jake.admin@gmail.com, the error happens regardless what is or is not in the email variable. Also, it happens with or without the required.

@snapey the error happens on line 362: /vendor/laravel-doctrine/orm.src/IlluminateRegistry.php

(362)--> $proxyClass = new ReflectionClass($class);
               if ($proxyClass->implementsInterface(Proxy::class)) {
                   $class = $proxyClass->getParentClass()->getName();
               }

sergionader left a reply on Users X Unique Email

Hey @jake.admin@gmail.com,

In a fresh installation, it worked.... trying to figure out what is wrong if my current project.

sergionader left a reply on Users X Unique Email

Thanks for the reply.

Yes, the 'email' after the comma was meant to the field name. I am check if it is an email on the form.

Regardless, I copied and pasted your suggestion and I still get the same error. $rules = ['email' => 'required|unique:users|email'];' I also tried $rules = ['email' => 'required|unique:users'];`

Any other insight? I will try it in a fresh Laravel installation and see what happens.

sergionader left a reply on Users X Unique Email

Hey @mstnorris, thanks for your reply.

This is enough to produce the error in my case. To keep it simple, I removed the name and password validation (with or without them the error will appear).

 public  function storeNewUser(Request $request){   
        $rules = ['email' => 'required|unique:users,email'];
        $email_message = 'Please enter a valid and unique email address.';    
        $customMessages = ['email.required' => $email_message];
        $request->validate( $rules, $customMessages);
        // if validated, then I will save it. 
    }

The error is pointed to be here: vendor/laravel-doctrine/orm/src/IlluminateRegistry.php

        $proxyClass = new ReflectionClass($class);
        if ($proxyClass->implementsInterface(Proxy::class)) {
            $class = $proxyClass->getParentClass()->getName();
        }

sergionader started a new conversation Users X Unique Email

Hello!

I read a lot of posts about it, but can't figure out what is wrong when I try to validate an email for insertion (this for a new user).

This is the error I get through everything looks as described in the docs:

(unique:table,column,except,idColumn at https://laravel.com/docs/5.6/validation#rule-unique)

Class users does not exist

I am using "laravel/framework": "5.6.*",

Using the users table as follows:

Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('email')->unique();
            $table->string('password');
            $table->rememberToken();
            $table->dateTime('deleted_at')->nullable(true)->default(null);
            $table->timestamps();
        });

Model:

class User extends Authenticatable
{
    use Notifiable;
    
    protected $fillable = [
        'name', 'email', 'password',
    ];
    
    public function roles()
    {
        return $this->belongsToMany('App\Role');
    } 
    
    protected $hidden = [
        'password', 'remember_token',
    ];
}```

And finally controller:

... use App\User; ... $rules = [ 'email' => 'required|unique:users,email', ]; $customMessages = [ 'email.required' => $email_message, ]; $request->validate( $rules, $customMessages);

result:
*Class users does not exist* 

sergionader left a reply on Laravel E-comm Experience & Demo

Thanks for the reply, @jlrdw!

I have already searched GitHub.

For now, I have this as a strong candidate: https://aimeos.org/integrations/laravel-ecommerce-package/ However, there is no USPS native connection to it. I can see a lot of UPSP connectors for Laravel but as before I interested in some real experience.

Have anyone used a Laraval/USPS package? Any recommendation?

Thanks!

27 May
6 months ago

sergionader started a new conversation Laravel E-comm Experience & Demo

Hello!

Is anyone running a Laravel based e-comm site? if yes, what is the URL and what are you using?

I administrate some Magento stores and though Magento is a great and very flexible product, it's kind of expensive when it comes to code-customized it,

Considering how robust and easy it is to customize Laravel solutions, I am looking for a Laravel an e-comm package that would offer at least a basic e-comm set of features, as follows: a) shopping cart; b) shipping integration with USPS (if possible) c) at least a Paypal payment gateway d) admin interface for managing products, orders, and customers; e) order status (placed, processed, shipped, etc). f) flexible blade structure for customizing the store view

It does not have to offer all the features of Magento, of course.

I see that there are some packages available for it, but most of them lack live examples.

Well, much better than live examples, is to have the impressions and comments of the Laracast community.

If you have any insights and experience with any Laravel e-comm package, I am sure that many readers would be interested in knowing them. Any suggestions will be very welcome!

Thanks!

27 Mar
8 months ago

sergionader left a reply on Update Records/pagination After Reloading The View.

Snapey, it worked. The way I did it some hours ago was creating an infinite load loop.

sergionader left a reply on Update Records/pagination After Reloading The View.

Thanks, Snapey. I tried it but got an error. I will try again and see what is going on.

sergionader started a new conversation Update Pagination After Reloading The View.

Scenario:

  1. I have a view, dealers.blade, that shows in a the contents of a single table.
  2. the view has a pagination control,{{$dealers->links()}}, and the controller sends pagianate(10) to the view. The
  3. The records of the dealers table are added by importing an excel file.
  4. the file upload field and the importer button are in the same blade.

Question:

  1. say we have 20 dealers. When I access the view, I can see pages 1 and 2 on the pagination control. This is fine.
  2. now, using the very same page, I select a file, upload it and add to the dealers table. Dealer table now has 40 records/
  3. the pagination control should show 4 pages, but it is still showing 2 pages (because the previous count was 20 records). In other words, the view is still showing the same old 20 records.
  4. Now I import 10 more records and the view now shows 4 pages (from the previous import) instead of five.
  5. in any case, if I hit the "go to the last record" button, the pagination control is updated by itself. After importing the data, I call the view using: return view('app.dealers',[<<variables>>]);

Basically I need to show the new records when I call the view again. If the new records are show, the pagination control will be updated by itself, I guess.

TIA!

27 Jan
10 months ago

sergionader left a reply on Laravel: Fetch Data Inside A Vue Component

OMG! For some reason, I thought "data" was a reserved word. Now it is:

   <country-list :countries="{{ $countries }}"></country-list>

I ketp the :.

Thanks a lot, guys!

sergionader left a reply on Laravel: Fetch Data Inside A Vue Component

BTW, props is not being populated. Please see this image: https://screencast.com/t/O8x4RCEjit

For the record, I populated the table countries with dummy data, so there no real names there (using faker())

sergionader left a reply on Laravel: Fetch Data Inside A Vue Component

Thanks a lot! I have done it before, but forgot to npm run watchand was struggling with an old error.

BTW, now there is no error and no data, unfortunately. To make sure $countriesis holding the data, I set up the blade like this:

    <div>
        All countries: {{$countries}}
    </div> 
    <br>
    <div>
        List of countries:
        <country-list :data="{{ $countries }}"></country-list>
    </div>

I got the data after "All countries"  but not after  "List of countries".

The component follows: 
```
Vue.component('country-list', {
    props: ['countries'], 
    template: `
        <div>
        <ul>
            <country v-for="country in countries" :key="country.id" > {{ country.name }} </country>
            </ul>
        </div>
        `,         
        data(){
            return {
                countries: this.countries
            }
        }
});
```
I also tried returning nothing as in your example, but neither of them worked. 
```
...
  data(){
            return {
                countries: this.countries
            }
        }
...
```

Any ideas? 

sergionader left a reply on Laravel: Fetch Data Inside A Vue Component

I just tried

<country-list :data="{{ $countries }}"></country-list> 

what gives me a Vue error that makes sense. Kind of stuck. Researching.

sergionader started a new conversation Laravel: Fetch Data Inside A Vue Component

Not sure if this is the best approach, but what I need looks to be very simple.

Let's say the application needs to show a list of countries inside a combo-box or using any other formatting. The list of countries is in a table named, say, countries and we get the data via de Country model as usual.

Instead of showing it inside a @foreach loop for all the blades it will show up, I would like to have something more modular like a Vue component.

Using the Laravel's built-in Vue component structure, I came out with the following for validating the idea:

resources/assets/js/app.js

Vue.component('country-list', {
    template: `
        <div>
        <ul>
            <country v-for="country in countries" :key="country.id" > {{ country.name }} </country>
            </ul>
        </div>
        `,
    data(){
        return {
            countries: [
                { id: 1, name: 'Australia'},
                { id: 2, name: 'Brazil'},
                { id: 3, name: 'Italy'},
                { id: 4, name: 'United States'}
            ]    
        }
    }
});
Vue.component('country', {
    template: '<li><slot></slot></li>',
})

const app = new Vue({
    el: '#app'
});

Blade:

@extends('layouts.app')
@section('content')      
    <country-list></country-list>        
@endsection

Works perfectly but as you can see, the countries are hard-coded, what is not what I want.

Considering I can fetch the countries with something like $countries = Country::all() how can I bind it to the Vue component so the <country-list></country-list> tag will show the data from the countries table?

Thanks!

27 Nov
1 year ago

sergionader left a reply on L5.5: Cache: Missing Illuminate\Database\Query\Builder::remember()

Thanks. I just saw it somewhere else as well :-)

sergionader left a reply on L5.5: Cache: Missing Illuminate\Database\Query\Builder::remember()

Thanks, @tykus! Worked very well. For the record, I got it from the below video: (https://laracasts.com/lessons/cache-tags-and-memcached)

Screenshot: (https://screencast.com/t/VZyDlN8tH) Other than a version issue, any reason for the divergence?

Regards!

26 Nov
1 year ago

sergionader started a new conversation L5.5: Cache: Missing Illuminate\Database\Query\Builder::remember()

Hi!

Using tinker the following works:

$u = User::all();

but

$u = User::remember(10)->get();

fails with the following message:

BadMethodCallException with message 'Call to undefined method Illuminate\Database\Query\Builder::remember()'

I have redis and memcached running and tried them both by changing cache.php:

  'default' => env('CACHE_DRIVER', <<redis or memcached>>),

The user model starts like this:

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravel\Scout\Searchable;
...

I tried to include the Cache facade (use Illuminate\Support\Facades\Cache;) with no success.

Looks like I am missing something very simple...

Thanks!!

sergionader left a reply on SQL To Eloquent -- How To Convert This Query?

Thanks a lot, @Dry7

For the record, I had to make a little change to make it work.

        $sql = DB::table('visits')
        ->join('product_visit', 'visit_id', '=', 'visits.id')
        ->where('product_visit.amount', '>', 0)
        ->whereBetween('visits.dt', [$dt_start, $dt_start])
        ->groupBy('month_idx', 'year')
        ->orderBy('year', 'desc')
        ->selectRaw('DATE_FORMAT(visits.dt, \'%m\') AS month_idx')
        ->selectRaw('DATE_FORMAT(visits.dt, \'%Y\') AS year')
        ->selectRaw('ROUND(sum(product_visit.amount)) AS y')
        ->get();

if I try

...
 ->selectRaw(
            'DATE_FORMAT(visits.dt, \'%m\') AS month_idx',
            'DATE_FORMAT(visits.dt, \'%b\') AS month',
            'DATE_FORMAT(visits.dt, \'%Y\') AS year',
            'ROUND(sum(product_visit.amount)) AS y'
        )
...

I get an error saying it expects an array.

The way I did, it's now working.

25 Nov
1 year ago

sergionader started a new conversation SQL To Eloquent -- How To Convert This Query?

Hello!

I have this query that works very well:

$sql = DB::select("
        SELECT
            DATE_FORMAT(visits.dt, '%m') AS month_idx,
            DATE_FORMAT(visits.dt, '%b') AS month,
            DATE_FORMAT(visits.dt, '%Y') AS year,
            ROUND(sum(product_visit.amount)) AS y
        FROM    visits, product_visit
        WHERE
            visits.id       = product_visit.visit_id
            AND product_visit.amount>0
            AND (visits.dt between '$dt_start' and '$dt_start')
        GROUP BY month_idx, month, year
        ORDER BY year desc, month_idx desc;
        ");

However, the following one will not run:

 $sql_sales_by_month = DB::table('visits')
        ->join('product_visit', 'visit_id', '=', 'visits.id')
        ->where('product_visit.amount', '>', 0)
        ->whereBetween('visits.dt', [$dt_start, $dt_start])
        ->groupby('month_idx', 'year')
        ->groupby(['year', 'desc'])
        ->select(
            'DATE_FORMAT(visits.dt, \'%m\') AS month_idx',
            'DATE_FORMAT(visits.dt, \'%b\') AS month',
            'DATE_FORMAT(visits.dt, \'%Y\') AS year',
            'ROUND(sum(product_visit.amount)) AS y'
        )
        ->get();

The error message is:

There was an error: {"readyState":4,"responseText":"{\n "message": "SQLSTATE[42S22]: Column not found: 1054 Unknown column 'DATE_FORMAT(visits.dt, '%m')' in 'field list' (SQL: select DATE_FORMAT(visits.dt, '%m') as month_idx, DATE_FORMAT(visits.dt, '%b') as month, DATE_FORMAT(visits.dt, '%Y') as year, ROUND(sum(product_visit.amount)) as y from visits inner join product_visit on visit_id = visits.id where product_visit.amount > 0 and visits.dt between 2017-01-01 and 2017-01-01 group by month_idx, year, year, desc)"

Any idea of how we can make it work?

Thanks!!

21 Nov
1 year ago

sergionader left a reply on Laravel 5.5/Scout: How To Extend Scout To Use Eloquent Joins?

Hello, Ccris! Thanks for the hint. I've changed back to Elastic Search two days ago - now using Erick's driver, that sorts related tables out of the box: https://github.com/ErickTamayo/laravel-scout-elastic. This driver relays on you to set up whatever you want via ES API and does a great job so far. I will soon post the complete code. Thanks!

19 Nov
1 year ago

sergionader left a reply on Laravel 5.5/Scout: How To Extend Scout To Use Eloquent Joins?

Update: I give Algolia a try and:

  1. it searches very well related tables. It also has fuzzy search out of the box and a basic web interface for index management. To make it work, it's important to set up the main model. In my case, the model Visit has:
  public function toSearchableArray()
    {
        $array = $this->toArray();
        $array['products'] = $this->products->toArray();
        $array['origin'] = $this->origin->toArray();
        $array['profile'] = $this->profile->toArray();
        $array['user'] = $this->user->toArray();
        return $array;
   }

Searching is a breeze:

  $visits = Visit::search("$query")
            ->paginate(10);

Works very fast and nice but... -- and this is very annoying but -- I can't sort the resulting grid by any field I want. I dug a little and found out the following:

  1. To sort, it's necessary to create an index replica. That's easy and makes sense;
  2. only numeric fields can be sorted -- and this is very weird...
  3. for instance, to sort the date, I created a new field called dt_unix where I store strtotime($date). Then I created two indices replicas: dt_asc and dt_desc.
  4. When I want to sort I just have to indicate which index should be used. Here is how to set the index on the fly:
  $index_name = 'dt_desc';
  $visits = Visit::search("$query")
            ->within($index_name)
            ->paginate(10);
  1. However, only the fields on the main table/model can be sorted. Thus, if I want to sort Origin (by any numeric criteria I could create), there is no way to set the index to sort by a field from a related table. Maybe using an "inverted model", i.e, Origin and the "related" Visits, it can be done -- it does look very messy, kind of the patch of the workaround!

If I am missing something, please let me know. The only thing I need is to have a server paginated grid that is searchable and sortable -- sure, it's a very common thing.

As always, any ideas are welcome!

16 Nov
1 year ago

sergionader left a reply on Laravel 5.5/Scout: How To Extend Scout To Use Eloquent Joins?

Hi, @CcrisS. Thanks for the post, but it won't work. The mapping shows

   "origin_name": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            }
                        },
                        "fielddata": true

but

$sort_column = 'origin_name';
$visits = Visit::search("canada")
            ->orderby($sort_column, $sort_az_za)
            ->with(['origin', 'profile', 'user'])
            ->paginate(10); 
```

will give us: 
<SQLSTATE[42S22]: Column not found: 1054 **Unknown column 'origin_name'**  in 'order clause' (SQL: select * from `visits` order by `origin_name` asc limit 10 offset 0)>

the whole problem is that the Visit model does not know the origin table even with the "with('origin') method. 
15 Nov
1 year ago

sergionader left a reply on Advanced Scout Driver For Elastic Search

Hello, Babenko. I can't understand why nobody has answered to your post (I am new here). I am using your driver with success (congrats!!!). The only point I have is described in this Laracast thread.

Looks like it's not related to the driver but to way Scout users the query builder. Would you have any suggestion? Basically, I would like to be able to search and sort the results in a grid for every field and not only for those of the "main" table.

14 Nov
1 year ago

sergionader left a reply on Laravel 5.5/Scout: How To Extend Scout To Use Eloquent Joins?

Thanks, Pierre! Unfortunately, it will not work.

Visit::where('column', 'LIKE', '%$query%')
->join('origins', 'origins.id', 'visits.origin_id')
->search('canada')
->get();

will produce:

Call to undefined method Illuminate\Database\Query\Builder::search()

and

$visits = Visit::search('canada')
->where('column', 'LIKE', '%$query%')
->join('origins', 'origins.id', 'visits.origin_id')
->get();
``
will give us: 
> Method join does not exist.


I am trying to figure out how to extend ../vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php to "understand" the search() method. 

Any suggestions are welcome!

sergionader left a reply on Laravel 5.5/Scout: How To Extend Scout To Use Eloquent Joins?

No ideas, guys?

I believe that more people have been faced (or facing) it as having a searchable and sortable grid is a common need. Thanks?

13 Nov
1 year ago

sergionader started a new conversation Laravel 5.5/Scout: How To Extend Scout To Use Eloquent Joins?

Hello. This is my first post here and have to say I am glad to join the Laracasts community! Let's go, then!

I am using Laravel/Scout/Elasticsearch via https://packagist.org/packages/babenkoivan/scout-elasticsearch-driver and I have this situation:

  1. To search, I must use a model like this:
$visits = Visit::search("canada")->with(['origin', 'profile', 'user'])->paginate(10);

It works very well.`

  1. As you can see, this model is related to three other tables: origins (that are countries), profile and users. The way everything is set, I can search for "canada" and get all the visits that came from Canada, what is fine as well.

  2. The result is shown in a grid using paginate(), what works well, too.

  3. However, if I want to sort the grid by Origins -- for everything I read and tried so far -- I can't use the $model::search('canada')->with(...) approach. Instead, I have to use something like

$visits = DB::table('visits') 
->join('origins', 'origins.id', 'visits.origin_id')
->orderby($sort_column, $sort_az_za)
->paginate(10);

This is the thing: the search() will not work with the DB::table('visits') syntax and Visit::search("canada")->with(....)... approach does not allow me to sort by a field that is not in the Visits table. BTW,

Visit::search("$query")->join('origins', 'origins.id', 'visits.origin_id')...

will not work as well.

The question is: how can I search and sort the results by any field I want?

I thought that it should be possible to extend Scout to search DB::table('TABLE') or to try to sort directly via ES -- though I would prefer to keep all the code bound to the "Laravel way".

If extending the DB::table('TABLE') is a way, could someone point me where to start?

Other than that, any other ideas/insights?

Thanks!