stefan7

stefan7

Member Since 1 Year Ago

Experience Points 4,630
Experience Level 1

370 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 42
Lessons
Completed
Best Reply Awards 0
Best Reply
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.

18 Jun
7 hours ago

stefan7 left a reply on How To Create URL Slugs In Laravel

str_slug($title) is deprecated, use:

Str::slug($title)


$slug = Str::slug('Laravel 5 Framework', '-');

https://laravel.com/docs/5.8/helpers#method-str-slug

10 Jun
1 week ago

stefan7 started a new conversation Get All Parent Categories

Hi,

I have a category model with parent_id attribute. I am trying to write a function that gives me all the parents. dd($parent) returns only string: "parent_id" What am I missing? And what is here the difference between $parent = $this->parent(); and$parent = $this->parent; ??

    public function parent()
    {
        return $this->belongsTo('App\Models\Category', 'parent_id', 'id');
    }

    public function getAllParents()
    {
        $parents = collect([]);
        $parent = $this->parent;

        while(!is_null($parent)) {
            $parents->push($parent);
            $parent = $parent->parent;
        }

        return $parents;
    }

dd($this) returns object

Category {#399 ▼
  #parent: "parent_id"
  #appends: array:1 [▶]
  +fillable: array:3 [▶]
  #connection: "mysql"
  #table: null
  #primaryKey: "id"
  #keyType: "int"
  +incrementing: true
  #with: []
  #withCount: []
  #perPage: 15
  +exists: true
  +wasRecentlyCreated: false
  #attributes: array:7 [▼
    "id" => 7
    "parent_id" => 3
    "en_name" => "Category 7"
    "de_name" => "Kategorie 7"
    "slug" => "category7"
    "created_at" => "2019-06-03 11:27:37"
    "updated_at" => "2019-06-03 11:27:37"
  ]

I tried also this

$parent = $this->parent();

Which returns me, but is not accessible

BelongsTo {#419 ▼
  #child: Category {#399 ▶}
  #foreignKey: "parent_id"
  #ownerKey: "id"
  #relation: "parent"
  #query: Builder {#402 ▶}
  #parent: Category {#399 ▶}
  #related: Category {#418 ▶}
  #withDefault: null
}
30 May
2 weeks ago

stefan7 left a reply on Remove Entry Of Collection

I tried my original function with Typeahead and it is working. Seems to be an issue with easyAutocomplete.

stefan7 left a reply on Remove Entry Of Collection

Thank you already for your hints! dd() before return leads to good results. I still don't understand why it does not appear in the autocomplete. Without removing items from the collection, the autocomplete is working.

 Illuminate\Database\Eloquent\Collection Object
(
    [items:protected] => Array
        (
            [3] => App\Models\Category Object
                (
                    [parent:protected] => parent_id
                    [fillable] => Array
                        (
                            [0] => en_name
                            [1] => de_name
                            [2] => parent_id
                        )

                    [connection:protected] => mysql
                    [table:protected] => 
                    [primaryKey:protected] => id
                    [keyType:protected] => int
                    [incrementing] => 1
                    [with:protected] => Array
                        (
                        )

                    [withCount:protected] => Array
                        (
                        )

                    [perPage:protected] => 15
                    [exists] => 1
                    [wasRecentlyCreated] => 
                    [attributes:protected] => Array
                        (
                            [id] => 6
                            [parent_id] => 3
                            [en_name] => Category 1
                            [de_name] => Kategorie 1
                            [slug] => category-1
                            [created_at] => 2019-04-26 10:56:22
                            [updated_at] => 2019-04-26 10:56:22
                        )


stefan7 started a new conversation Remove Entry Of Collection

Hi,

I have a 3-level tree. The functions should return json with only 3rd-level catgories for autocomplete field. Autocomplete has no results with $data->forget($key), but why? I tried the code without the return, just printing with dd() and the collection showed 3 items. If I do the same request with the following function i get no results.

 public function autocompleteSearch(Request $request)
    {
        $searchquery = $request->searchquery;
        $data = Category::where('parent_id','!=',0)
                          ->where('de_name','like','%'.$searchquery.'%')
                          ->get();
        
        foreach($data as $key => $cat) {
            $category = Category::find($cat->parent_id);
            if($category->parent_id == 0) {
                $data->forget($key);
            }
        }
        return response()->json($data);
    }
23 May
3 weeks ago

stefan7 left a reply on @php In Foreach

Yes, but why? And how can i solve this?

stefan7 started a new conversation @php In Foreach

Hi, any idea why the $url-variable in between of @php is not working?

Exception: Trying to get property 'content' of non-object

               @foreach($position->url as $url)
                    @php
                        $content = $url->content;
                    @endphp
                @endforeach
07 Feb
4 months ago

stefan7 left a reply on Route Parameter Delivers Locale Instead Of ID

Thank you, that is the solution!

stefan7 started a new conversation Route Parameter Delivers Locale Instead Of ID

Hi, I pass an ID in a route, but the function in the controller is reading the false part of the url.

http://127.0.0.1/testsystem/public/de/importer/startImportProcess/2

The right function in ImporterController is called, but: My variable $id return "de" (=locale of the url) instead of "2".

web.php Route::get('/startImportProcess/{id}', '[email protected]')->name('importer.start');

[email protected] `` public function startImportProcess($id) {

    $importer = Importer::find($id);

``

What could be the reason?

19 Jan
4 months ago

stefan7 left a reply on Router Link Error

I did make a tutorial and ran into this error. I am new tue vue. Changing it to the following did not help, same errors

  <router-link to="admin/comments/create" class="btn btn-success">Create comment</router-link>

For me this is weird error message with "can not read property 'name'.." because now there is not anywhere in app.js or component the word name. If i remove the code-block with the buttons (for create and edit), the errors disappear.

And how would I add the variable to the following "to" with the way you mentioned?

                        <router-link :to="{name: 'editComment', params: {id: comment.id}}" class="btn btn-xs btn-default">
                            Edit
                        </router-link>

stefan7 started a new conversation Router Link Error

Hi, in app.js i defined: ´´´ import CommentsIndex from './components/comments/CommentsIndex.vue'; import CommentsCreate from './components/comments/CommentsCreate.vue'; import CommentsEdit from './components/comments/CommentsEdit.vue';

const routes = [ { path: '/', components: { commentsIndex: CommentsIndex } }, {path: '/admin/comments/create', component: CommentsCreate, name: 'createComment'}, {path: '/admin/comments/edit/:id', component: CommentsEdit, name: 'editComment'}, ] ´´´

Then in CommentsIndex.vue there is the router link: ´´´ <router-link :to="{name: 'createComment'}" class="btn btn-success">Create Comment</router-link> ´´´

But why is it not working? ´´´ vue.js:525 [Vue warn]: Missing required prop: "to" (found in component ) warn @ vue.js:525 assertProp @ vue.js:1289 validateProp @ vue.js:1242 loop @ vue.js:3149 initProps @ vue.js:3163 initState @ vue.js:3120 Vue._init @ vue.js:3376 VueComponent @ vue.js:3498 createComponentInstanceForVnode @ app.js:40432 init @ app.js:40253 createComponent @ app.js:41730 createElm @ app.js:41677 createChildren @ app.js:41804 createElm @ app.js:41706 createChildren @ app.js:41804 createElm @ app.js:41706 patch @ app.js:42213 Vue._update @ app.js:38782 updateComponent @ app.js:38910 get @ app.js:39264 Watcher @ app.js:39253 mountComponent @ app.js:38917 Vue.$mount @ app.js:44662 Vue.$mount @ app.js:47061 init @ app.js:40259 createComponent @ app.js:41730 createElm @ app.js:41677 createChildren @ app.js:41804 createElm @ app.js:41706 createChildren @ app.js:41804 createElm @ app.js:41706 createChildren @ app.js:41804 createElm @ app.js:41706 createChildren @ app.js:41804 createElm @ app.js:41706 createChildren @ app.js:41804 createElm @ app.js:41706 createChildren @ app.js:41804 createElm @ app.js:41706 createChildren @ app.js:41804 createElm @ app.js:41706 createChildren @ app.js:41804 createElm @ app.js:41706 createChildren @ app.js:41804 createElm @ app.js:41706 patch @ app.js:42252 Vue._update @ app.js:38782 updateComponent @ app.js:38910 get @ app.js:39264 Watcher @ app.js:39253 mountComponent @ app.js:38917 Vue.$mount @ app.js:44662 Vue.$mount @ app.js:47061 (anonymous) @ app.js:14074 webpack_require @ app.js:20 (anonymous) @ app.js:14030 webpack_require @ app.js:20 (anonymous) @ app.js:63 (anonymous) @ app.js:66 vue.js:525 [Vue warn]: Error when rendering component : warn @ vue.js:525 Vue._render @ vue.js:2227 updateComponent @ vue.js:2613 get @ vue.js:2936 Watcher @ vue.js:2928 Vue._mount @ vue.js:2612 Vue$3.$mount @ vue.js:6176 Vue$3.$mount @ vue.js:8547 init @ app.js:40259 createComponent @ app.js:41730 createElm @ app.js:41677 createChildren @ app.js:41804 createElm @ app.js:41706 createChildren @ app.js:41804 createElm @ app.js:41706 patch @ app.js:42213 Vue._update @ app.js:38782 updateComponent @ app.js:38910 get @ app.js:39264 Watcher @ app.js:39253 mountComponent @ app.js:38917 Vue.$mount @ app.js:44662 Vue.$mount @ app.js:47061 init @ app.js:40259 createComponent @ app.js:41730 createElm @ app.js:41677 createChildren @ app.js:41804 createElm @ app.js:41706 createChildren @ app.js:41804 createElm @ app.js:41706 createChildren @ app.js:41804 createElm @ app.js:41706 createChildren @ app.js:41804 createElm @ app.js:41706 createChildren @ app.js:41804 createElm @ app.js:41706 createChildren @ app.js:41804 createElm @ app.js:41706 createChildren @ app.js:41804 createElm @ app.js:41706 createChildren @ app.js:41804 createElm @ app.js:41706 createChildren @ app.js:41804 createElm @ app.js:41706 patch @ app.js:42252 Vue._update @ app.js:38782 updateComponent @ app.js:38910 get @ app.js:39264 Watcher @ app.js:39253 mountComponent @ app.js:38917 Vue.$mount @ app.js:44662 Vue.$mount @ app.js:47061 (anonymous) @ app.js:14074 webpack_require @ app.js:20 (anonymous) @ app.js:14030 webpack_require @ app.js:20 (anonymous) @ app.js:63 (anonymous) @ app.js:66 app.js:48624 Uncaught TypeError: Cannot read property 'name' of undefined at normalizeLocation (app.js:48624) at VueRouter.resolve (app.js:49920) at Proxy.render (app.js:47760) at VueComponent.Vue._render (vue.js:2220) at VueComponent.updateComponent (vue.js:2613) at Watcher.get (vue.js:2936) at new Watcher (vue.js:2928) at VueComponent.Vue._mount (vue.js:2612) at VueComponent.Vue$3.$mount (vue.js:6176) at VueComponent.Vue$3.$mount (vue.js:8547) ´´´

04 Jan
5 months ago

stefan7 started a new conversation Pattern-visitor.js - Uncaught TypeError

Hi, I have no idea where this error is coming from: pattern-visitor.js:32 Uncaught TypeError: Cannot read property 'toString' of undefined at Object. (pattern-visitor.js:32)

Any suggestions where to look or how to solve?

Thanks Stefan

04 Dec
6 months ago

stefan7 left a reply on Node Modules Are Installed But Are Not Found

Still having this issue, how can I solve this?

02 Dec
6 months ago

stefan7 left a reply on Node Modules Are Installed But Are Not Found

Thanks I have now less error messages. I tried to play around to add these packages to config like FS, but did not seem to work. I have still left although the packages exist in the folder:

ERROR in ./node_modules/spdx-expression-parse/scan.js Module not found: Error: Can't resolve 'spdx-exceptions' in 'D:\Xampp\htdocs\project node_modules\spdx-expression-parse'

ERROR in ./node_modules/spdx-expression-parse/scan.js Module not found: Error: Can't resolve 'spdx-exceptions' in 'D:\Xampp\htdocs\project node_modules\spdx-expression-parse'

ERROR in ./node_modules/spdx-expression-parse/scan.js Module not found: Error: Can't resolve 'spdx-license-ids' in 'D:\Xampp\htdocs\project \node_modules\spdx-expression-parse'

ERROR in ./node_modules/spdx-expression-parse/scan.js Module not found: Error: Can't resolve 'spdx-license-ids/deprecated' in 'D:\Xampp \htdocs\project\node_modules\spdx-expression-parse'

I have at the moment

mix.webpackConfig({
    node: {
        fs: "empty",
        node_child: "empty",
        child_process: "empty",
        spdx_expression_parse: "empty",
        spdx_exceptions: "empty",
    },

stefan7 started a new conversation Node Modules Are Installed But Are Not Found

Hi, I am running node.js on windows and am struggling now for hours with this error. I did install with npm install ... all this modules that seem to be missing. The module folders exist in Laravel project and I installed globally as well. What am I missing?

ERROR in ./node_modules/require-directory/index.js Module not found: Error: Can't resolve 'fs' in 'D:\Xampp\htdocs\project\node_modules require-directory'

ERROR in ./node_modules/spdx-expression-parse/scan.js Module not found: Error: Can't resolve 'spdx-license-ids/deprecated' in 'D:\Xampp \htdocs\project\node_modules\spdx-expression-parse' @ ./node_modules/spdx-expression-parse/scan.js 5:10-48