rabol

rabol

Member Since 3 Years Ago

Experience Points 26,540
Experience Level 6

3,460 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 249
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.

28 May
1 month ago

rabol left a reply on DB::connection Does Not Work As Documented

@TRAY2 - I need to transform data during the migration, so the data migration is a 'project' within the project

27 May
1 month ago

rabol left a reply on DB::connection Does Not Work As Documented

@JLRDW - I 100% agree with you that it is documented and while double checking the config i finally saw the problem.

I copied the 'mysql' section, but I did not change this part

        'orig_db' => [
            'database' => env('DB_DATABASE', 'orig_db'),
            'username' => env('DB_USERNAME', 'homestead'),
            'password' => env('DB_PASSWORD', 'secret'),
        ],

so therefor it took the db defined in .env file and not the 'orig_db'

rabol left a reply on DB::connection Does Not Work As Documented

@MVD - Sorry, none of your suggestions work.

there is no such thing as

DB::Connection()->connection(...)

rabol left a reply on DB::connection Does Not Work As Documented

@TRAY2 - There are many workarounds, but i just want to use the one that is documented

rabol left a reply on DB::connection Does Not Work As Documented

@JLRDW - yes, as stated in the initial post:

I have a connection called 'orig_db'

and use it like this:

$record = DB::Connection('orig_db')->select('select * from my_table where id = ?',[$id]);

but get an error as the select is executed against the 'default' database and not the one defined in the 'orig_db' configuration

rabol left a reply on DB::connection Does Not Work As Documented

Documentation say: $users = DB::connection('foo')->select(...); One needs to have a connection called ‘foo’ in condig/database.php but it does not work

rabol started a new conversation DB::connection Does Not Work As Documented

Hi

I'm trying to migrate one old php app to Laravel so I have two databases

In my 'new db' I do not have the same table structure which is why i would like to connect to the old, and insert into the new db.

Both DB's are on the same MySQL

In my config/database.php I have the normal 'mysql' and then I have created a new 'orig_db'

$users = DB::Connection('orig_db')->select('select * from my_table where id = ?',[$id]);

i get an error saying that the .my_table does not exists is the new database so the table does not exists, which is why I would like to use the DB:connection

I'm using Laravel v5.8.15

Any hints?

14 May
2 months ago

rabol started a new conversation Getmxrr Not Working On Homestead Box

Hi

the function getmxrr() does not work on the Homestead dev box nor does nslookup

is that a VirtualBox issue or ?

Thanks in advance

09 May
2 months ago

rabol left a reply on Scheduler Not Working As Expected

on the Homestead (Ubuntu?), one also need to specify the user

* * * * * root /usr/bin/php /home/vagrant/code/blog/artisan schedule:run >>/tmp/blog_cron.log 2>>/tmp/blog_cron_err.log

root should of course be replaced with a more appropriate user

rabol left a reply on Scheduler Not Working As Expected

@SNAPEY - thanks, I will give it a try

Then the documentation should be updated :)

I copied the crontab entry from:

https://laravel.com/docs/5.8/scheduling#defining-schedules

rabol started a new conversation Scheduler Not Working As Expected

Hi

I'm trying to setup some jobs to be executed daily and hourly

for the test I'm using a local Homestead box

Cron is running Crontab looks like this:

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user  command
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
* * * * * cd /home/vagrant/code/blog && php artisan schedule:run >> /dev/null Z>&1
```

app/console/Kernel.php looks like this:

```
    protected function schedule(Schedule $schedule)
    {
        $schedule->command('inspire')->hourly();
        $schedule->job(new MyJob())->daily();
        $schedule->job(new MyJob())->hourly();
        $schedule->command('telescope:prune')->daily();
        $schedule->job(new Heartbeat)->everyFiveMinutes();
    }

```

I have rebooted the server

but still nothing is happening

I'm sure I miss something, but what

Thanks in advance
07 May
2 months ago

rabol left a reply on Is Supervisor Installed By Default In The Homestead Box

Hi

I have tried my best to follow the update, but a small thing 'bugs' me

according to Github, the latest release is 8.4.0 when I do a git checkout v8.4.0 i get this: HEAD is now at c1e194b Tag v8.3.4

I added the "laravel/homestead": "^8" to my composer.jason and did a composer update

vagrant destroy vagrant up

and then when I log into homestead it say:

  • Homestead 8.4.0 released!
  • Settler v7.2.1 released! Make sure you update

supervisord -v 3.3.1 which is from 2016

I would not mind installing a new version of supervisor myself, but using the 'normal' way does not work, and as I'm not a Linux guy I'm kind of lost.

By 'normal' i mean pip install --upgrade supervisor New version is downloaded, it say that it's installed but it's not working

rabol started a new conversation Is Supervisor Installed By Default In The Homestead Box

Hi

Is the supervisor tool installed by default in the Homestead Vagrant box?

I ask because I thought that I installed it, but now I have 'destroyed' the VM and created a new and Supervisor is still there - but in a old version the same goes for pip and it's difficult to update.

sure, pip install --upgrade supervisor should work, but it does not, it say that a new version is installed, but executing supervisord -v shows 3.3.1 and the downloaded version is 4.0.2

If supervisor is installed by default, why then a old version ?

if it is not installed by default, why is it then running on my box after a : vagrant destroy and vagrant up command?

23 Apr
2 months ago

rabol left a reply on Why Does \Log Not Work In Jobs

@SNAPEY - After a good night's sleep, I doubled checked all configuration and ensured that Supervisor was properly restarted - Now it works.

Lessons learned: Make sure that Supervisor is 'restarted' correctly, otherwise it does not pick up any code changes

22 Apr
3 months ago

rabol left a reply on Why Does \Log Not Work In Jobs

@SNAPEY - Job is run by Supervisor

rabol left a reply on Why Does \Log Not Work In Jobs

Changing owner did not solve the issue

rabol left a reply on Why Does \Log Not Work In Jobs

@RONON - I'm using homestead so I assume that it is www-data, I will give it a try

21 Apr
3 months ago

rabol left a reply on Route-Model Binding Doesn't Work

And you are sure the parameter in the controller is called exactly the same as in the route definition?

rabol started a new conversation Why Does \Log Not Work In Jobs

Hi

What can I do to log actions or error in jobs?

I use \Log::Info() but nothing is logged

02 Apr
3 months ago

rabol started a new conversation How To Enable XML-RPC On Homestead

Hi

How can I enable XML-RPC in the Vagrant/Homestead dev environment ?

01 Apr
3 months ago

rabol left a reply on How To Make The --force Work On Generator Command

this is the code in the GeneartorCommand - handle()

if ((! $this->hasOption('force') || ! $this->option('force')) && $this->alreadyExists($this->getNameInput())) { $this->error($this->type.' already exists!');

        return false;
    }

so if I parse 'force' in the 'options', then the above should not be executed

rabol left a reply on How To Make The --force Work On Generator Command

@SNAPEY - No, but by own command ask and the values are passed to the Artisan call

rabol started a new conversation How To Make The --force Work On Generator Command

Hi

I'm trying to create a artisan command will generate some code based on stub's

parameters are collected and parsed to Artisan::call()

but for some reason the --force does not have any effect

Is there something special one have to do to make the --force work when creating e.g. a controller class?

21 Mar
4 months ago

rabol left a reply on Method Illuminate\Validation\Validator::validateRequired|date|before Does Not Exist.

@TOMOPONGRAC - Thanks! Almost okay

the start date is now validated correctly

but... end date is 'optional' so it should only be validated if entered

so if no end date I get this:

rabol started a new conversation Method Illuminate\Validation\Validator::validateRequired|date|before Does Not Exist.

Hi

In a form request I try to validate that the start date is before today and the end date is before the start date in my FormRequest derived class i have this: public function rules() { return [

        'start_date'    => ['required|date|before:today'],
        'end_date'      => ['date|before:start_date']
     ];

}

public function messages() { return [ 'start_date.required' => 'The :attribute field is required.', 'start_date.before' => 'The :attribute field must be before today', ]; }

when I submit my form I get this error:

Method Illuminate\Validation\Validator::validateRequired|date|before does not exist.

What did I miss ?

Thanks

14 Mar
4 months ago

rabol left a reply on Why Does Storage::disk('local')->deleteDirectory($directory); Not Work

Crap.... When I save, i have the 'public' as second parameter so that should also be included when deleting

rabol started a new conversation Why Does Storage::disk('local')->deleteDirectory($directory); Not Work

Hi

The user upload a picture and I save it using the Uploadfile from a form.

image is saver in a subfolder like this: $image->store('/user/' . auth()->user()->id . '/' . $doc->id, 'public'); returned path is correct and everything is fine.

Then later I want to delete the user and his images but it does not work.

$directory = '/user/' . auth()->user()->id; Storage::disk('local')->deleteDirectory($directory);

nothing is deleted

Any hints ?

15 Feb
5 months ago

rabol left a reply on Homestead Acting Strange

and debugging is not working

rabol started a new conversation Homestead Acting Strange

Hi

I have just made a new installation on my MBP of Vagrant and Homestead Mapped 3 folders and created 3 Sites

did a index.php with only phpinfo(); code and all 3 sites worked

Then I want to install OctoberCMS, I downloaded the installer, and then at the end I get this: LARAVEL_START already defined

I do understand that one might say that it is a problem of OctoberCMS, but...

If I do php artisan key:generate I get this:

Application key [base64:jkL0wB5oW5M6tYUPTnv32S5krDA6nKToPQRfV0AQWX8=] set successfully.

however the .env file is not updated

Any hints?

19 Oct
1 year ago

rabol left a reply on My Laravel App Does Not Work Any More...

damn.... mod_rewrite was not enabled...

rabol started a new conversation My Laravel App Does Not Work Any More...

Hi

For the last 2 months I have not done any Laravel dev on my Mac, but today I wanted to play around, but none of my local Laravel apps was working any more

Sure, the 'main' url like laravel.dev showed the main page, but as soon as I tried something like laravel.dev/login i get a 404

php artisan route:list shows that the route is correct

I have followed this: https://mallinson.ca/osx-web-development/

Now, the first thing one would ask is: What changes have happened to the system, and I would say, none... but that is not completely true as I have installed latest Mac Updates

so, system is like this: macOS High Sierra, v 10.13 MySQL php 7.1.5

There is no errors in my apache config files There is no information in my apache error_log

I do know that it might not be a laravel error, but something in my system, but what?

Any help or hint would be highly appriciated

Thanks in advance

08 Jun
2 years ago

rabol started a new conversation Npm Run Dev Does Not Work

Hi

Environment: Mac OsX 10.12.5 php 7.1.0 node v8.0.0 npm 5.0.1 laravel installer 1.3.6

Did the following

laravel new mytest cd mytest npm install npm run dev

> @ dev /Users/steenrabol/Sites/mytest
> npm run development


> @ development /Users/steenrabol/Sites/mytest
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

fs.js:638
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: ENOENT: no such file or directory, open '/Users/steenrabol/Sites/mytest/schema/loader.json'
    at Object.fs.openSync (fs.js:638:18)
    at Object.fs.readFileSync (fs.js:540:33)
    at validateOptions (/Users/steenrabol/Sites/mytest/node_modules/schema-utils/dist/validateOptions.js:35:27)
    at ExtractTextPlugin.extract (/Users/steenrabol/Sites/mytest/node_modules/extract-text-webpack-plugin/index.js:206:3)
    at Sass.rules (/Users/steenrabol/Sites/mytest/node_modules/laravel-mix/src/Preprocessors/Preprocessor.js:46:42)
    at Mix.preprocessors.forEach.preprocessor (/Users/steenrabol/Sites/mytest/node_modules/laravel-mix/setup/webpack.config.js:243:33)
    at Array.forEach (native)
    at Object.<anonymous> (/Users/steenrabol/Sites/mytest/node_modules/laravel-mix/setup/webpack.config.js:242:23)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ development script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/steenrabol/.npm/_logs/2017-06-08T06_41_37_119Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/steenrabol/.npm/_logs/2017-06-08T06_41_37_205Z-debug.log

30 Mar
2 years ago

rabol left a reply on How Do I Include NPM Installed JS Library E.g JQuery UI

Trust me, I would not annoy YOU if i could find the answer

I looked at that thread and as others report it did not work, which is why I asked the question

rabol started a new conversation How Do I Include NPM Installed JS Library E.g JQuery UI

Hi

Sorry to ask here, but there is no mix channel

What is the correct / best way to include jQuery-UI in my project so that I can run npm run dev/production to generate appropriate files

First I do

npm install jquery-ui

then.. What ?

I tried to look at the videos, but did not really find the answer

Thanks in advance

27 Feb
2 years ago

rabol left a reply on How To Implement Sequential Numbers For Records

hmmm doctrine2/lib/Doctrine/ORM/Id/SequenceGenerator.php

but that is not part of Laravel

rabol left a reply on How To Implement Sequential Numbers For Records

yes, but the $nr is the one that I need, not the formatting :)

in good old ADO PHP, there was a GenId()

/**
 * Generates a sequence id and stores it in $this->genID;
 * GenID is only available if $this->hasGenID = true;
 *
 * @param seqname       name of sequence to use
 * @param startID       if sequence does not exist, start at this ID
 * @return      0 if not supported, otherwise a sequence id
 */

I was hoping that Laravel had something similar

rabol started a new conversation How To Implement Sequential Numbers For Records

Hi

Is there a easy way to implement sequential numbering for records?

What I need is:

on a table i have a string field, let's say seqId

and in every form I would like to initialise the field with the next number in in the sequence, but as the same time format it like INV-000001, INV-000002 etc.

It should be DB independent :)

Thanks in advance

22 Jan
2 years ago

rabol started a new conversation How To Extend Or Replace App\User At Run-time

Hi

Is there a way to extend or replace the App\User at runtime?

My goal is to add extra features to the App\User and have it available everywhere in the application.

Thanks in advance.

Kind regards Steen

26 Dec
2 years ago

rabol started a new conversation How To Do Multiple

Hi

How do I add multiple where clauses

e.g

$bmr = Bmr::where('gender', '=', $this->gender)->where('age_from', '<=', $this->age)->where('age_to', '=>', $this->age)->first();

the sql fro this is: select * from bmr where gender = '1' and age_from <= '50' and age_to = '=>' limit 1

it seems like the last where is not tanslated correctly

rabol left a reply on How To Add A User Profile

Thanks!

rabol started a new conversation How To Add A User Profile

Hi

For a new project I would like to add a 'User profile' to the user, however I do not want to add 20+ new fields to the users table

so i did the following: created a new migration (no foreign key constraint) created a new controller created a new model

modified the User model to create a new UserProfile when created Added a new function(relation) to my User model like this:

public function userProfile()
{
    $this->hasOne(UserProfile::class,'user_id','id');
}

then to test I did this in my home.blade.php

{{ auth()->user()->userProfile()->age }}

but... I get an exception:

Trying to get property of non-object (View: /Users/steenrabol/Sites/laravel/resources/views/home.blade.php)

What did I miss ?

25 Dec
2 years ago

rabol left a reply on How To Exclude Index From Route::resource

damn... i had ['Except' => 'index']... that did not work, but I did not think that the Capital E was the problem.

Thanks!!

rabol started a new conversation How To Exclude Index From Route::resource

Hi

i would like to exclude the 'index' of the Route::resource() How to do that ?

07 Nov
2 years ago
03 Nov
2 years ago

rabol left a reply on Createdb: Database Creation Failed: ERROR: Database "homestead" Already Exists

Actually I just updated the box and I saw that the error exists by default, not just because I am doing 'pr. project'

rabol left a reply on Createdb: Database Creation Failed: ERROR: Database "homestead" Already Exists

I mean... pr. project means that I have a new VM pr. project, not the same :)

rabol left a reply on Createdb: Database Creation Failed: ERROR: Database "homestead" Already Exists

yes, but I get the error when I do the vagrant up command I'm not trying to create a new database myself

rabol started a new conversation Createdb: Database Creation Failed: ERROR: Database "homestead" Already Exists

Hi

I have been doing a few 'Pr. project' Homestead VM's and doing my last I noticed this error: createdb: database creation failed: ERROR: database "homestead" already exists How can I have the database if I do a new VM pr. project ?

26 Oct
2 years ago

rabol left a reply on Homestead Installation On Mac OS X 10.12

I used this one: https://github.com/rlerdorf/php7dev

made it work in less than 10 minutes