Dunsti

Dunsti

Member Since 1 Year Ago

Bayreuth

Specialist Web Development at Cybex GmbH

Experience Points 16,560
Experience Level 4

3,440 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 11
Lessons
Completed
Best Reply Awards 25
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.

19 Jun
5 days ago

Dunsti left a reply on Vue - Parse JSON String

Try this:

this.content = JSON.parse(content);
04 Jun
2 weeks ago

Dunsti left a reply on Purifier For Vuejs ?

I'm using this one, and it works fine for me: https://bootstrap-vue.js.org

17 May
1 month ago

Dunsti left a reply on How Do You Install A Vue.js Package Into Laravel?

I think you have installed the package correctly, but look at the code:

:show="show"

This variable controlls if the vodal is displayed, and show is set to an initial value of false

I guess you just need to set this to true ... ?

14 May
1 month ago

Dunsti left a reply on Best Practice For Validation And Dry Principle

One way could be, to create the JavaScript validation rules on the backend.

put the rules in a placeholder and fill it while rendering the view:

something like this in your template:

<script>{{ $rules }}</script>

something like this in your controller

return view('myform', ['rules' => ' ... ']);
03 May
1 month ago

Dunsti left a reply on Not Working Laravel + Vuejs In Laravel App

you can also try this:

import Myheader from './components/Myheader';
import Myfooter from './components/Myfooter';

const app = new Vue({
    el: '#app',
    components:{
    Myheader,
    Myfooter
}
});
02 May
1 month ago

Dunsti left a reply on Not Working Laravel + Vuejs In Laravel App

The error-message says, that you don have a template defined in your component.

<template>
</template>

produces this error. Write some code in between the template-tags!

Dunsti left a reply on Not Working Laravel + Vuejs In Laravel App

tags are case-insesitive.

component Myheader will be <myheader> in the template

Names are converted to kebab-case:

component MyHeaderwould then be <my-header> in the template

25 Apr
1 month ago

Dunsti left a reply on Image Uploads To Tmp Instead Of Correct Location

$post->name = $path . '/' . $name;

because in $request->name is still the temp-name.

Dunsti left a reply on Trouble Understanding How A Vue Plugin Is Working

I guess that part is required:

new Vue({
  el: '#app',
  render: h => h(App),
})

because it rerenders your app

Dunsti left a reply on Image Uploads To Tmp Instead Of Correct Location

$name = $file->getClientOriginalName();
$path = 'public/images';
...
$post->name = $request->name; // here you should use $path . $name instead
23 Apr
2 months ago

Dunsti left a reply on How Much Of Code Syntax You Guys Remember?

more important than the syntax is to have an understanding on how to do certain things. For example: "Do I use a for- or a while-loop for this problem?" or "Do I use IF- or Switch-statements for this?".

Other than that I can only repeat what was already said: php.net, Laravel docs, w3schools, google, etc. are all legit tools for our daily work.

10 Apr
2 months ago

Dunsti left a reply on Returning Count To Blade

Did you pass $admin to the view?

Docu here: https://laravel.com/docs/5.8/views#passing-data-to-views

Dunsti left a reply on 'confirmationKey' Doesn't Have A Default Value When Registering User

read the SQL-Error:

SQL: insert intousers(name,email,password,updated_at,created_at)

confirmationKey is missing there.

did you define the confirmationKey in your User-Model?

02 Apr
2 months ago

Dunsti left a reply on How To Use Serveral Databases

The values in the env-file are only placeholders for values in config-files. You can use the env()-function to get the values from the env-file. You can name the variables in your env-file like you want.

You can configure your databases in the connection-section in your config/database.php-file. (see the env()-calls to get the values from the env-file)

If you have more than one DB-connection, you can specify which connection to use in your Model:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Flight extends Model
{
    /**
     * The connection name for the model.
     *
     * @var string
     */
    protected $connection = 'connection-name';
}

also see the Laravel-Doku for that: https://laravel.com/docs/5.8/configuration https://laravel.com/docs/5.8/eloquent

Dunsti left a reply on How To Create A Custom Message In A Request Class.

you can add the user input with the :input placeholder

like so:

return [
            'email' => 'The email :input is already taken.',
        ];
26 Mar
2 months ago

Dunsti left a reply on Vue: Removing First Element From Array And Iterating Over It

Why don't you use array.shift() ?

It gives you the first element of an array and automatically removes it.

https://www.w3schools.com/jsref/jsref_shift.asp

20 Mar
3 months ago

Dunsti left a reply on How Does The /storage Directory Permissions Keep Getting Set Back To 755?

I had a similar problem - in my case GIT was responsible for this: every time I used a git pull the folder-rights were reset because the wrong rights were commited.

Maybe that's a possible explanation for your case?

14 Mar
3 months ago

Dunsti left a reply on Edit Route And Select Option Form

you need to name your select correct:

´´´ ´´´

15 Feb
4 months ago

Dunsti left a reply on Error In Save Data

Try with this route instead:

Route::post('profile/document', [email protected]')->name('profile.docs');
18 Jan
5 months ago

Dunsti left a reply on Artisan Commands

look in /vendor/laravel/framework/Illuminate/Foundation/Console

Dunsti left a reply on Check Domain Name Is Formed Correctly

If you only want to check for correct syntax, I would do that with a regex match:

http://regexlib.com/REDetails.aspx?regexp_id=391

28 Nov
6 months ago

Dunsti left a reply on Undefined Variable: Category

In $categories you have all categories, but in the form you only want to delete one category at once.

You need a for-each-loop in your view like this:

@foreach($categories as $category)

<form action="{{ route('categories.destroy', ['id' => $category->id]) }}" method="post">
    {{ method_field('delete') }}
    @csrf
    <div class="form-group">
        <label for="categories">Category:</label>
        <select name="{{ category->id }}">{{ category->name }}</select>
    </div>
    <div class="form-group">
        <button type="button" class="btn btn-danger">Delete</button>
    </div>
</form>

@endforeach
16 Nov
7 months ago

Dunsti left a reply on Uploading File Return Response Code 413 - Payload Too Large

not sure if this is a problem, but all documentations i saw for nginx have a small "m" instead of the "M" you have.

Maybe just also try to set

''' client_max_body_size 0; '''

to turn limit off completely

Dunsti left a reply on Uploading File Return Response Code 413 - Payload Too Large

You also need to increase the value for "memory_limit" in your php.ini

06 Apr
1 year ago

Dunsti left a reply on Return Products With Select Subcategories

What is that Connect_magazine_subcategory_category for? This is not needed.

class Magazine_subcategory extends Model
{
    protected $fillable = [ 'name' ];
    protected $table = 'magazine_subcategories';

    public function categories()
    {
        return $this->belongsToMany('App\Magazine_category', 'magazine_category_subcategory',  'subcategory_id', 'category_id');
    }

    public function products()
    {
        return $this->belongsToMany('App\Product', 'product_subcategory', 'subcategory_id', 'product_id');
    }
}

and

class Product extends Model
{


    protected $fillable = [
        'nazwa',
        'cena',
        'kopis',
        'dopis',
        'n_img',
        'subkategoria',
    ];

    public function subcategories()
    {
        return $this->belongsToMany('App\Magazine_subcategory', 'product_subcategory', 'product_id', 'subcategory_id');
    }
}

Use this, if you want your pivot-table to be named product_subcategory (like you have in your migration)

Or change the tablename in your migration, to the Laravel-default for pivot tables:

class CreateProductSubcategoryTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('magazine_subcategory_product', function (Blueprint $table) {
             $table->increments('id');
             $table->integer('product_id')->unsigned();
             $table->integer('subcategory_id')->unsigned();
        });

        Schema::table('magazine_subcategory_product', function (Blueprint $table) {
             $table->foreign('product_id')->references('id')->on('products');
        });

        Schema::table('magazine_subcategory_product', function (Blueprint $table) {
             $table->foreign('subcategory_id')->references('id')->on('magazine_subcategories');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('magazine_subcategory_product');
    }
}

I would suggest to take the Laravel-default. Convention over Configuration!

05 Apr
1 year ago

Dunsti left a reply on Return Products With Select Subcategories

You either need to pass the correct pivot-tablename in your Magazine_subcategory-Model (function products() )

or you need to rename the pivot-table magazine_subcategory_product instead of subcategory_product

26 Mar
1 year ago

Dunsti left a reply on Hidden Field In API Resource Using Conditional Attributes?

Conditional attributes are good for adding fields to a collection, but you want to remove a value from the collection.

You could use the except-Collectionmethod:

MangaResource::collection($this->collection)->except(['description']);
11 Mar
1 year ago

Dunsti left a reply on Dusk Tests Without Breaking Live Database?

From the Laravel-Documentation:

In addition, you may create a .env.testing file in the root of your project. This file will override the .env file's variables when running PHPUnit tests or executing Artisan commands with the  --env=testing switch.

Just set up another database-connection in your .env.testing file and run the migrations, so you have your database-structure.

I haven't done much testing yet, but from what I saw so far, many use Sqlite for this.

27 Feb
1 year ago

Dunsti left a reply on Category In Urls

I guess, you see this too complicated.

lets say, you have a route like this:

Route::get(
            '/{category}/{article}}',
            ['as' => 'article.detail', 'uses' => '[email protected]']
        );

then your ArticleController receives the two fields {category} and {article} as parameters:

public function show(Category $category, Article $article)
{
    ...
}

You then have a complete Category-Model and a complete Article-Model available in your Controller-method. You could possibly do something like this: dump($article->name)

But: in your URL you would need to enter the IDs of the category and article you want. This works, but it doesn't look that good.

You can change the field that is used for the URL in your Model like this:

    /**
     * Defines the attribute that is used to route to the object
     */
    public function getRouteKeyName()
    {
        return 'name';
    }

this would use the name-field in your Database to fetch the correct Model you use in the controller.

Does that help?

Dunsti left a reply on Artisan Command From Package Not Recognized When Calling From PHP

You need to either use Artisan in your class, or you need to access it like this:

$exitCode = \Artisan::call(...

Dunsti left a reply on Class DatabaseSeeder Does Not Exist

You need a file called DatabaseSeeder.php in your database/seeds-Folder.

This is an example, that comes with a fresh laravel-installation:

<?php
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        // $this->call(UsersTableSeeder::class);
    }
}

In this file you set up your seed-process (which seeders should be called and in which order)

23 Feb
1 year ago

Dunsti left a reply on I Want To Change The Directory Of Errors Blade Files

you can change this in different ways:

1.) in your config/view.php you have an array paths - if you add a new folder here, then Laravel will search all paths (with /errors at the end) until it finds the correct error-page. (You should then delete the folder errors in /views otherwise it will take these)

    'paths' => [
        realpath(base_path('resources/views')),
        realpath(base_path('resources/views/foo')),
    ],

Now your error-templates reside in resources/views/foo/errors

2.) you can override the renderHttpException()-method in your app/Exception/Handler.php

something like this example:

    protected function renderHttpException(HttpException $e)
    {
        $status = $e->getStatusCode();

        $paths = collect(config('view.paths'));

        view()->replaceNamespace('errors', [resource_path('views/foo/bar'), __DIR__.'/views',

        if (view()->exists($view = "errors::{$status}")) {
            return response()->view($view, ['exception' => $e], $status, $e->getHeaders());
        }

        return $this->convertExceptionToResponse($e);
    }

Now your error-templates reside in resources/views/foo/bar (without /errors at the end)

18 Feb
1 year ago

Dunsti left a reply on How Can I Access Images From Storage And Use It For Products

The webserver can only serve files, that are in /public - so either copy your files in a folder under /public or create a symlink.

See here: https://laravel.com/docs/5.6/filesystem#the-public-disk

Dunsti left a reply on Route::bind Has No Affect On Resource Routes

 if I try to hit "/user/someHashedId/edit", I get a 404 error

maybe that's just a typo? users vs. user ?

Dunsti left a reply on Why Validator Only Return Validation.required Not The Message In Res/lang/xx/validator.php ?

Does your locale in /config/app.php match the foldername xx ?

15 Feb
1 year ago

Dunsti left a reply on Include A Foreach Looped Variable From Controller To Blade

yes, sorry ... my fault (damn copy&paste)

that's the correct function for your Model:

public function getDiffAttribute()
{
    $startTime = Carbon::parse($this->starttime);
    $diff = $this->endtime->diffInMinutes($startTime);

    return $diff;
}

use $this instead of $cleanObj

Dunsti left a reply on Include A Foreach Looped Variable From Controller To Blade

I would create a virtual attribute to your model:

in your Clean-Model:

class Clean extends Model
...
protected $appends = [
    'diff',
]
...
...
public function getDiffAttribute()
{
    $startTime = Carbon::parse($cleanObj->starttime);
        $diff = $cleanObj->endtime->diffInMinutes($startTime);

    return $diff;
}

Now you have a new attribute you can use in your view:

{{ $clean->diff }}
13 Feb
1 year ago

Dunsti left a reply on Undefined Variable: Data In View.

as far as I know, the ->with() - method is not able to pass arrays to your view. It is only for single values.

see here: https://laravel.com/docs/5.5/views#passing-data-to-views

Try this syntax:

return view('AdminPanel', compact('data'));

Dunsti left a reply on BBP For Routes

There are a few reasons why to direct routes towards a controller:

03 Feb
1 year ago

Dunsti left a reply on Simple Regex Validation Fails

1.) You need to escape special characters that have a function in RegEx (not only ' and ").

I'm not sure, but in my Regex I also have the / at the beginning and end.

Try this:

'regex:/[\[email protected]$\*\(\)_=\?;\':\",.]/'),
15 Jan
1 year ago

Dunsti left a reply on Any Laravel 5.5 PDF?

ok, in fact it is updated if there are changes ;)

08 Jan
1 year ago

Dunsti left a reply on Any Laravel 5.5 PDF?

This one is updated daily: https://leanpub.com/laravel-5

24 Dec
1 year ago
23 Dec
1 year ago

Dunsti left a reply on Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException No Message

Which method do you use in your <form> in your template?

If the route is post() (like it is in your routes) then you also need POST as method in your form.

If you have POST as method in the <form>-Tag, look if you have a hidden-input-field called _method.

More details here: https://laravel.com/docs/5.5/routing#form-method-spoofing

Dunsti left a reply on How To Avoid Mutiply 'to' When Sending Subscribe Email For Each User

instead of to() you should use bcc()

like this:

Mail::to($yourself)
    ->bcc($otherusers)

Where $yourself is a User-object that will be seen by everyone and $otherusers is a collection of all other User-objects. All users within the bcc() will not be visible to other recipients.

22 Dec
1 year ago

Dunsti left a reply on Homestead Error On Windows

What you are trying to do will not work. The folders-Section is there to map a windows-folder (on your host-machine) to a linux-folder (inside your VM)

folders:
    - map: c:/your_windows_path to /your_linux_path
20 Dec
1 year ago

Dunsti left a reply on Homestead Error On Windows

\u00D4\u00C7\u00F6 these are unicode-characters! (See the output of your error-message)

Try to find them, and eliminate them:

  • Check your Homestead.yaml if there are such characters (maybe with a hex-editor)
  • Check the encoding of Homestead.yaml (if it is UTF-8, make sure it is without BOM)
  • Check the encoding of your ssh-keys (id_rsa and id_rsa.pub) - here again, if it is UTF-8 make sure it is without BOM

Hope that helps.