ludo1960

ludo1960

Member Since 8 Months Ago

Experience Points 2,840
Experience Level 1

2,160 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 0
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

08 May
2 months ago

ludo1960 left a reply on Reseed DB After A Crash

Thanks for that, worked first time!

ludo1960 started a new conversation Reseed DB After A Crash

Hi guys,

After a hard disk failure, I had to reload laravel from a backup. All looked good until I run:

php artisan migrate --seed

I get the error Class RolesAndPermissionsSeeder does not exist...

In my DatabaseSeeder.php i have:

    public function run()
    {
        $this->call([
            RolesAndPermissionsSeeder::class,
           // PostsTableSeeder::class,
           // CommentsTableSeeder::class,
        ]);

    }

and in my RolesAndPermissionsSeeder.php I have:

class RolesAndPermissionsSeeder extends Seeder
{

    public function run()
    {....

It all worked flawlessly before the crash. any ideas?

01 May
2 months ago

ludo1960 left a reply on How Long Is A Piece Of String?

Thanks devfrey, I think smaller and local is what i'm after, do any jquery offerings spring to mind?

ludo1960 started a new conversation How Long Is A Piece Of String?

Hi guys,

I have a few index pages for my data models, all working nicely. Now I would like to add an autocomplete search to each index page. Google tells me there are a gazillion ways to do this. I'm happy to go down the jquery route. Is there a package someone can recommend or a tutorial worthy of following?

Guess the title is right!

30 Apr
2 months ago

ludo1960 left a reply on How To Create A Password In Code?

Hey, I'm clicking like mad on Snapeys' Best Answer button and nothings happening WTF?

ludo1960 left a reply on How To Create A Password In Code?

Hooray, it works!!!

    public function setPasswordAttribute($password)
{
    $this->attributes['password'] = bcrypt($password);
}

I just changed $value to $password (as the variable is called in my seeder" and Hey Presto!

Thanks Snapey!

ludo1960 left a reply on How To Create A Password In Code?

What is a setter?

ludo1960 left a reply on How To Create A Password In Code?

@SNAPEY - Hi Snapey,

User Model:

    protected $fillable = [
        'name', 'email', 'password', 'role_ids', 'guard_name'
    ];

DB seeder:


 $password = bcrypt('granger');
...
    $user = User::firstOrCreate(['name' => 'Admin', 'email' => '[email protected]', 'password' => $password, 'guard_name' => 'web', 'role_ids' => $rid ]);

ludo1960 left a reply on How To Create A Password In Code?

@VAN1310 - Here you go:

 Symfony\Component\Debug\Exception\FatalThrowableError  : syntax error, unexpected '=>' (T_DOUBLE_ARROW)

  at /var/www/laramongo.local.com/database/seeds/RolesAndPermissionsSeeder.php:31
    27|         Permission::firstOrCreate(['name' => 'Administer roles & permissions']);
    28| 
    29|         // create roles and assign existing permissions
    30| 
  > 31|     $password => bcrypt('mypassword');
    32|     $role = Role::firstOrCreate([ 'name' => 'Admin', 'guard_name' => 'web' ]);
    33|     $role_id = Role::where('name', 'Admin')->get();
    34| 
    35|     foreach ($role_id as $rid) {

  Exception trace:

  1   Composer\Autoload\includeFile("/var/www/laramongo.local.com/vendor/composer/../../database/seeds/RolesAndPermissionsSeeder.php")

ludo1960 started a new conversation How To Create A Password In Code?

Hi guys,

In laravel 5.8 how to create a password in code. I've tried:

$password = bcrypt('mypassword');

and I've also tried:

use Illuminate\Support\Facades\Hash;

...
$password = Hash::make('mypassword');

But neither lets me login, what am I doing wrong?

28 Apr
2 months ago

ludo1960 left a reply on How To Use Sweet Alerts In Laravel

Nearly there:

   'onsubmit' => 'validate(event)' ])!!}

    <script>

    function validate() {
      event.preventDefault(); // prevent form submit
      var form = document.forms["my-form"]; // storing the form
      swal({
             title: "Are you sure?",
             text: "Once deleted, you will not be able to recover this imaginary file!",
             icon: "warning",
             buttons: true,
             dangerMode: true,
           })
          .then((willDelete) => {
               if (willDelete) {
                     form.submit();
               } else {
                      swal("Your imaginary file is safe!");
           }
        });
    }
    </script>

How to get rid of "swal("Your imaginary file is safe!");! and just return to the edit page?

ludo1960 left a reply on How To Use Sweet Alerts In Laravel

I'm missing something:

    'onsubmit' => 'validate(event'])!!}

    <script>

    $('validate').submit(function (e) {
    e.preventDefault();

    var form = $(this);

    swal({
        title: "Are you sure?",
        text: "You will not be able to recover this imaginary file!",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "Yes, delete it!",
        closeOnConfirm: false
    }, function (isConfirmed) {
        if (isConfirmed) {
            form.submit();
        }
    });

    return false;
    });
    </script>

ludo1960 left a reply on How To Use Sweet Alerts In Laravel

What should the value be for the 'onsubmit' to use with your #my-form example?

ludo1960 left a reply on How To Use Sweet Alerts In Laravel

Thanks for that, Can I not use a function in the on onsubmit method:

    {!! Form::open(['method'=>'DELETE', 'route' => ['posts.destroy', $post->id],'class'=>'form-horizontal',
    'onsubmit' => 'validate()'])!!}

Something like :

function validate() {
    // java stuff in here
}

ludo1960 started a new conversation How To Use Sweet Alerts In Laravel

Hi guys,

I can get a delete conformation like so in my blade file:

    {!! Form::open(['method'=>'DELETE', 'route' => ['posts.destroy', $post->id],'class'=>'form-horizontal',
    'onsubmit' => 'return confirm("Deletion, are you sure ?")'])!!}

But how to use sweet alerts to replace it ?

 <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>

    <script>
        swal({
        title: "Are you sure?",
        text: "You will not be able to recover this imaginary file!",
        type: "warning",   showCancelButton: true,   confirmButtonColor: "#DD6B55",
        confirmButtonText: "Yes, delete it!",   closeOnConfirm: false },
        function(){
            swal("Deleted!", "Your imaginary file has been deleted.", "success");
        });
    </script>

How to trigger the swal for the form open method?

27 Apr
2 months ago

ludo1960 left a reply on Delete Conformation Dialogue Box

@PHPHUPPTECHNOLOGIES - permissions.destroy is correct:

Is this line correct:

url: "{{route('permissions.destroy')}}"+id, // add your delete route

ludo1960 left a reply on Delete Conformation Dialogue Box

Tried it, but get the error:

Missing required parameters for [Route: permissions.destroy] [URI: permissions/{permission}]. (View: /var/www/laramongo.local.com/resources/views/permissions/index.blade.php)

Complete code just in case of a typo:

   @foreach ($permissions as $permission)
                <tr>
                    <td>{{ $permission->name }}</td>
                    <td>

                    <a href="{{ URL::to('permissions/'.$permission->id.'/edit') }}" class="btn btn-info pull-left" style="margin-right: 3px;">Edit</a>

                    {!! Form::open(['method' => 'DELETE', 'route' => ['permissions.destroy', $permission->id]  ]) !!}
                 {{--   {!! Form::submit('Delete', ['class' => 'btn btn-danger pull-right']) !!}
                    {!! Form::close() !!} --}}
                    <button class='delete btn btn-danger pull-right' onclick="deleteFunction('{{$permission->id}}')">Delete</button>

                    </td>
                </tr>
                @endforeach
            </tbody>
        </table>
    </div>

    <a href="{{ URL::to('permissions/create') }}" class="btn btn-success">Add Permission</a>
    <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
    <script type="text/javascript">
    function deleteFunction(id) {

        swal({
          title: "Are you sure?",
          text: "Once deleted, you will not be able to recover this imaginary file!",
          icon: "warning",
          buttons: {
            confirm: {
              text: "Ok",
              value: true,
              visible: true,
              className: "btn btn-success",
              closeModal: true
            },
            cancel: {
              text: "cancel",
              value: null,
              visible: true,
              className: "btn btn-danger",
              closeModal: true,
            }
          },
          dangerMode: true,
          confirmButtonColor: '#3f51b5',
          cancelButtonColor: '#ff4081'
        })
        .then((willDelete) => {
            if (willDelete) {
                $.ajax({
                type: "DELETE",
                url: "{{route('permissions.destroy')}}"+id, // add your delete route
                success: function (data) {
                    //here succes code
                }
            });
          }
        });
    }
    </script>
</div>

@endsection

ludo1960 left a reply on Delete Conformation Dialogue Box

@PHPHUPPTECHNOLOGIES - Thanks for that, how to implement it? Make a js file from your example and then call it within a blade file?

ludo1960 left a reply on Delete Conformation Dialogue Box

Here's the whole thing:

  @foreach ($roles as $role)
                <tr>

                    <td>{{ $role->name }}</td>

                    <td>{{ str_replace(array('[',']','"'),' ', $role->permissions()->pluck('name')) }}</td>{{-- Retrieve array of permissions associated to a role and convert to string --}}
                    <td >
                    <a href="{{ URL::to('roles/'.$role->id.'/edit') }}" class="btn btn-info pull-left" style="margin-right: 3px;">Edit</a>

                    {!! Form::open(['method' => 'DELETE', 'route' => ['roles.destroy', $role->id], 'class' => ['delete'] ])!!}
                    {!! Form::submit('Delete', ['class' => 'btn btn-danger pull-right']) !!}
                    {!! Form::close() !!}
                    <script>
                            $(".delete").on("submit", function(){
                                return confirm("Are you sure?");
                            });
                        </script>
                    </td>
                </tr>
                @endforeach
            </tbody>
                <script>
                    $(".delete").on("submit", function(){
                        return confirm("Are you sure?");
                    });
                </script>

ludo1960 left a reply on Delete Conformation Dialogue Box

@SNAPEY - Hi Snapey,

Tried like so:

    {!! Form::open(['method' => 'DELETE', 'route' => ['roles.destroy', $role->id], 'class' => ['delete'] ])!!}

Is that what you mean? If so it doesn't work :)

ludo1960 started a new conversation Delete Conformation Dialogue Box

Hi guys,

I would like to add a delete conformation box to a blade template, I have the following in my blade template:

        {!! Form::open(['method' => 'DELETE', 'route' => ['permissions.destroy', $permission->id] ]) !!}
        {!! Form::submit('Delete', ['class' => 'delete btn btn-danger pull-right']) !!}
        {!! Form::close() !!}

I have tried this but it doesn't work:

<script>
    $(".delete").on("submit", function(){
        return confirm("Are you sure?");
    });
</script>
``

I've also read that this method is not the way to go in laravel, what is the right way?
24 Apr
2 months ago

ludo1960 left a reply on Laravel Vuetify How To?

Hey Sergiu, I've tried the clicking "best answer" button and nothing happens, looks like laracasts has a bug :)

22 Apr
3 months ago

ludo1960 left a reply on Laravel Vuetify How To?

Thanks Sergiu, tutorial looks cool! Only trouble with google is you end up with laravel 4 4.2 5 5.2 etc.

ludo1960 left a reply on Laravel Vuetify How To?

Hi Sergiu,

I was reading https://vuetifyjs.com/en/getting-started/quick-start but going through the site did not mention anything about installing in laravel. When I add your code:

  <div id="app">
    <v-app>
      // 
    </v-app>
  </div>


  <script src="js/app.js"></script>

to my welcome blade, I get a blank screen, I guess that's because my app.js is not correct. Has anyone got a working app.js just to get me started?

ludo1960 left a reply on Laravel Vuetify How To?

Tried:

<template>
    <v-app>
        <script src="js/app.js"></script>
    </v-app>
</template>

But still no joy!

ludo1960 left a reply on Laravel Vuetify How To?

So in welcome.blade.php I added:

<v-app>
@import 'js/app.js';
</v-app>

It doesn't do anything, so I guess that isn't correct. Am I going about this the right way?

ludo1960 started a new conversation Laravel Vuetify How To?

Hi guys,

I've installed laravel, with vue.js and vuetify, when I run:

npm run watch

It reports all is well!

But when I browse mysite.com:8080 I just get the laravel welcome blade.

Here is my app.js

import Vue from 'vue'
import Vuetify from 'vuetify'

Vue.use(Vuetify)

require('./bootstrap');

window.Vue = require('vue');

Vue.component('example-component', require('./components/ExampleComponent.vue').default);

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

Is there something else I need to change?

ludo1960 started a new conversation Insert Predefined Values Into Mongodb

Hi guys,

I can insert a Boolean as true or false like so:

'color' =>$faker->Boolean,

But what if I want to make predefined values like Red, Green and Blue, or Male/Female. Any ideas how to achieve this?

20 Apr
3 months ago

ludo1960 left a reply on View Reflecting HasOne And HasMany

In my customer model I have:

    public function address()
{
  return $this->hasOne(CustomerAddress::class);
}

    public function purchase()
{
    return $this->hasMany(CustomerPurchase::class);
}

Is that enough?

Hoe to get that into my view/views as my OP?

ludo1960 left a reply on View Reflecting HasOne And HasMany

oops, missed out the controller, do I just need a customer controller? If so do I just "php artisan create:controller customer" then edit as you suggested?

ludo1960 started a new conversation View Reflecting HasOne And HasMany

Hi guys,

I've managed to create a related Eloquent Model, customer hasOne with CustomerAddress and customer hasMany with CustomerPurchase, The migration was successful as was my table seeder, so I guess my models are correct. Now I would like to create views reflecting the relationship. Google has not been my friend in finding a how to. I know how to get the data separately from each of the models, but I would like to have is a view of customer and customeraddress and customer and customepurchase, Any pointers would be appreciated.

Thanks in advance...

16 Apr
3 months ago

ludo1960 left a reply on Troubleshoot A Route

Thanks very much, another super useful laravel function!

15 Apr
3 months ago

ludo1960 started a new conversation Troubleshoot A Route

Hi Guys,

If I have a route, say mysite.com/users/1 and something somewhere is blocking it, is there a laravel helper function that will help me troubleshoot said route?

ludo1960 left a reply on Where To Start Debugging

A reboot took care of the xdebug/vscode issue. It looks like xdebug is a wonderful tools. Delighted you guys talked me into it! So before I re-install I tried out xdebug on th eUserController (which is the simplest of all the controllers) Started debug and:

<?php

namespace Encore\Admin\Controllers;

use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Layout\Content;
use Encore\Admin\Show;
use Illuminate\Routing\Controller;

class UserController extends Controller

Exception has occurred.
Fatal error: Class 'Illuminate\Routing\Controller' not found

A very suspicious looking error, no idea how that happens as all the illuminate stuff is built into Laravel. Anyone got the remotest idea as to why this is happening?

14 Apr
3 months ago

ludo1960 left a reply on Where To Start Debugging

Got xdebug installed, php -v shows xdebug is installed. Got https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug installed. Now the small matter of getting vscode to talk to xdebug. I tried adding:

// server -> local
"pathMappings": {
  "/var/www/mysite.com/public": "${workspaceRoot}/www",
  "/app": "${workspaceRoot}/app"
}

But it didn't like it, can some please tell me what the have in their launch.json. Here's what I've got at the moment:

{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [

        {
              "name": "Listen for XDebug",
              "type": "php",
              "request": "launch",
              "port": 9000
        },
        {
              "name": "Launch currently open script",
              "type": "php",
              "request": "launch",
              "program": "${file}",
              "cwd": "${fileDirname}",
              "port": 9000
        }
  ]

}

ludo1960 left a reply on Where To Start Debugging

Gonna re-install and go back to the drawing board, happy days!

ludo1960 left a reply on Where To Start Debugging

!. route being called is admin/auth/roles/1

  1. routes has nothing about admin/auth/roles
use Illuminate\Routing\Router;

Admin::registerAuthRoutes();

Route::group([
    'prefix'        => config('admin.route.prefix'),
    'namespace'     => config('admin.route.namespace'),
    'middleware'    => config('admin.route.middleware'),
], function (Router $router) {

    $router->get('/', '[email protected]');

});
  1. Insert dd in rolecontroller:
    public function edit($id, Content $content)
    {
        dd($id);
        return $content
            ->header(trans('admin.roles'))
            ->description(trans('admin.edit'))
            ->body($this->form()->edit($id));

    }
 ModelNotFoundException In Builder.php line 369 :
No query results for model [Encore\Admin\Auth\Database\Role] 1
```
dd displays nothing and lins 369 in Builder.php
```
    public function getHiddenFields()
    {
        return $this->hiddenFields; // this is line 369

    }

ludo1960 left a reply on Where To Start Debugging

one step forward and two steps back! Any other useful functions other than dd?

13 Apr
3 months ago

ludo1960 left a reply on Where To Start Debugging

Thanks, i'll give it a go. Was hoping somebody knew how to get that darn Debugbar working!

ludo1960 left a reply on Where To Start Debugging

Result of

dd($menuModel, $permissionModel, $roleModel)

is


"Encore\Admin\Auth\Database\Menu"
"Encore\Admin\Auth\Database\Permission"
"Encore\Admin\Auth\Database\Role"

ludo1960 left a reply on Where To Start Debugging

From the laravel logs, it points to an error in Route), Object(Encore\Admin\Controllers\MenuController), 'store') That's why im trying to start debugging there. I have installed Debugbar with composer.

    /**
     * Make a form builder.
     *
     * @return Form
     */
    public function form()
    {
        $menuModel = config('admin.database.menu_model');
        $permissionModel = config('admin.database.permissions_model');
        $roleModel = config('admin.database.roles_model');

        Debugbar::info($menuModel);     // code added by me!!!
        Debugbar::info($permissionModel);
        Debugbar::info($roleModel);
        debug($menuModel, $permissionModel);

does nothing, What else can I try?

ludo1960 left a reply on Where To Start Debugging

How the heck am I supposed to use Debugbar ??

ludo1960 left a reply on Where To Start Debugging

Followed instructions here: https://github.com/barryvdh/laravel-debugbar#laravel-55

I don't get any error about importing the class???

ludo1960 left a reply on Where To Start Debugging

Sure did:

use DebugBar\StandardDebugBar; 

ludo1960 left a reply on Where To Start Debugging

I don't have much to go on other than what I have posted above:

I go to any input page and when I hit submit i get:

 FatalThrowableError In MenuController.php line 124 :
Class 'Encore\Admin\Controllers\Debugbar' not found

Looking in the logs tells me the error is in:

Route), Object(Encore\Admin\Controllers\MenuController), 'store')

Then looking in that file gives me:

    public function form()
    {
        $menuModel = config('admin.database.menu_model');
        $permissionModel = config('admin.database.permissions_model');
        $roleModel = config('admin.database.roles_model');

        $form = new Form(new $menuModel());

        $form->display('id', 'ID');

        $form->select('parent_id', trans('admin.parent_id'))->options($menuModel::selectOptions());
        $form->text('title', trans('admin.title'))->rules('required');
        $form->icon('icon', trans('admin.icon'))->default('fa-bars')->rules('required')->help($this->iconHelp());
        $form->text('uri', trans('admin.uri'));
        $form->multipleSelect('roles', trans('admin.roles'))->options($roleModel::all()->pluck('name', 'id'));
        if ($form->model()->withPermission()) {
            $form->select('permission', trans('admin.permission'))->options($permissionModel::pluck('name', 'slug'));
        }

        $form->display('created_at', trans('admin.created_at'));
        $form->display('updated_at', trans('admin.updated_at'));

        return $form;
    }

usin tinker:

>>> config('admin.database.menu_model')

"Encore\Admin\Auth\Database\Menu"

Which is the menu_model for the MenuController code above, dunno what else to try?

12 Apr
3 months ago

ludo1960 left a reply on Where To Start Debugging

Come on guys, don't be shy, help me out!

ludo1960 left a reply on Where To Start Debugging

Ok, from tinker:

>>> config('admin.database.menu_model')

"Encore\Admin\Auth\Database\Menu"

Which is the menu_model for the MenuController code above, what now?

ludo1960 left a reply on Where To Start Debugging

I tried adding:

use DebugBar\StandardDebugBar;

Then just after this code I added:

    public function form()
    {
        $menuModel = config('admin.database.menu_model');
        $permissionModel = config('admin.database.permissions_model');
        $roleModel = config('admin.database.roles_model');

        Debugbar::info($menuModel);     // code added by me!!!
        Debugbar::info($permissionModel);
        Debugbar::info($roleModel);

But nothing appears in the bugbar, am I using the correct approach?