Foks

Developer & owner at XevoTech

Member Since 11 Months Ago

Roskilde

Experience Points
18,970
Total
Experience

1,030 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
149
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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.

  • Community Pillar

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

Level 4
18,970 XP
May
13
21 hours ago
Activity icon

Started a new Conversation Laravel Socialite, Sanctum & Passport Together In One App

Hello!

I'm wondering how I would be able to install Laravel Passport as well as having Sanctum & Socialite. Any ideas?

Apr
22
3 weeks ago
Activity icon

Awarded Best Reply on Target Class [env] Does Not Exist.

@tisuchi I did.

But I solved it by stashing the changes in git, and then reset the branch to the last commit, and then I copied the tests from the stash and it worked. No clue why it broke, but it works now

Apr
21
3 weeks ago
Activity icon

Replied to Target Class [env] Does Not Exist.

@tisuchi I did.

But I solved it by stashing the changes in git, and then reset the branch to the last commit, and then I copied the tests from the stash and it worked. No clue why it broke, but it works now

Activity icon

Replied to Target Class [env] Does Not Exist.

@tisuchi Well it fixed some of it, but most of the test still fails

Apr
20
3 weeks ago
Activity icon

Replied to Target Class [env] Does Not Exist.

@tykus I don't have a .env.testing file, as it was working just fine without it before. I was aware of it was already there as a server variable, weren't sure if there was a difference.

Activity icon

Replied to Target Class [env] Does Not Exist.

@tykus My phpunit.xml has it already

<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true">
  <coverage processUncoveredFiles="true">
    <include>
      <directory suffix=".php">./app</directory>
    </include>
  </coverage>
  <testsuites>
    <testsuite name="Unit">
      <directory suffix="Test.php">./tests/Unit</directory>
    </testsuite>
    <testsuite name="Feature">
      <directory suffix="Test.php">./tests/Feature</directory>
      <directory suffix="Test.php">./Modules/Fortify/Tests/Feature</directory>
    </testsuite>
  </testsuites>
  <php>
    <server name="APP_ENV" value="testing"/>
    <server name="BCRYPT_ROUNDS" value="4"/>
    <server name="CACHE_DRIVER" value="array"/>
    <server name="DB_CONNECTION" value="sqlite"/>
    <server name="DB_DATABASE" value=":memory:"/>
    <server name="MAIL_MAILER" value="array"/>
    <server name="QUEUE_CONNECTION" value="sync"/>
    <server name="SESSION_DRIVER" value="array"/>
    <server name="TELESCOPE_ENABLED" value="false"/>
	<env name="TELESCOPE_ENABLED" value="false"/>
  </php>
</phpunit>

Activity icon

Started a new Conversation Target Class [env] Does Not Exist.

Hi!

I'm running on PHP 8, Laravel 8.37 (With Laravel Telescope & Horizon). The application is working just fine, but when I try to run my feature tests this comes

Target class [env] does not exist.

And all my test fails

Apr
14
4 weeks ago
Activity icon

Replied to API With Laravel Sanctum?

No, but it worked. Thanks!

Activity icon

Replied to API With Laravel Sanctum?

@corvs I'm on Laravel 8.36.2. The project started at Laravel 8.

Activity icon

Replied to API With Laravel Sanctum?

@corvs followed every step other than the adding middleware step. ( as it's for SPA's)

I test my API with PHPStorms HTTP-client-file.

Activity icon

Replied to API With Laravel Sanctum?

@corvs I didn't change the default config for Sanctum. Yes I have added the HasApiToken trait to my User model

Activity icon

Started a new Conversation API With Laravel Sanctum?

Hi!

I'm currently developing an API for one of my apps, however, it's my first time doing so.

But when I test the API, with a token from Sanctum it breaks completely. Stack trace: https://paste.xevotech.com/ziquqeqege.sql

I've created a UserController for my API, it looks like this:

<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Http\Resources\UserResource;
use App\Models\User;
use Illuminate\Http\Request;

class UserController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
     */
    public function index()
    {
        return UserResource::collection(User::all());
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }
}

My routes/api.php

<?php

use App\Http\Controllers\Api\UserController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});
Route::group(['middleware' => ['auth:api']], function() {
    Route::apiResource('users', UserController::class);
});

My UserResource.php

<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class UserResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return parent::toArray($request);
    }
}
Apr
11
1 month ago
Apr
09
1 month ago
Activity icon

Started a new Conversation Laravel Sail's NPM Uses Windows Path?

So I recently switched my development environment from Laragon to Laravel Sail, and I got it working today. However, when I run the command sail npm run dev it fails, and from the logs, I can see that it's due to Sail using the windows version of NodeJS.

[email protected]:~/lectero$ sail npm run dev

> dev
> npm run development


> development
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --config=node_modules/laravel-mix/setup/webpack.config.js

node:internal/modules/cjs/loader:927
  throw err;
  ^

Error: Cannot find module 'which-module'
Require stack:
- /var/www/html/node_modules/yargs/build/lib/command.js
- /var/www/html/node_modules/yargs/build/lib/yargs.js
- /var/www/html/node_modules/yargs/yargs.js
- /var/www/html/node_modules/yargs/index.js
- /var/www/html/node_modules/webpack-cli/bin/cli.js
- /var/www/html/node_modules/webpack/bin/webpack.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:924:15)
    at Function.Module._load (node:internal/modules/cjs/loader:769:27)
    at Module.require (node:internal/modules/cjs/loader:996:19)
    at require (/var/www/html/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at Object.<anonymous> (/var/www/html/node_modules/yargs/build/lib/command.js:12:21)
    at Module._compile (/var/www/html/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
    at Module.load (node:internal/modules/cjs/loader:972:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Module.require (node:internal/modules/cjs/loader:996:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/var/www/html/node_modules/yargs/build/lib/command.js',
    '/var/www/html/node_modules/yargs/build/lib/yargs.js',
    '/var/www/html/node_modules/yargs/yargs.js',
    '/var/www/html/node_modules/yargs/index.js',
    '/var/www/html/node_modules/webpack-cli/bin/cli.js',
    '/var/www/html/node_modules/webpack/bin/webpack.js'
  ]
}
ERROR: 1

How can I fix it?

Activity icon

Awarded Best Reply on Laravel Sail / Docker Is Slow

So I found out that it was the "bridge" that WSL2 uses to link Ubuntu. So what I ended up doing was moving the project into /home/<user>/<projectname> and then chmod the directory, and then Laravel Sail has fast responses.

Activity icon

Replied to Laravel Sail / Docker Is Slow

So I found out that it was the "bridge" that WSL2 uses to link Ubuntu. So what I ended up doing was moving the project into /home/<user>/<projectname> and then chmod the directory, and then Laravel Sail has fast responses.

Activity icon

Replied to Laravel Sail / Docker Is Slow

I haven't.

Apr
08
1 month ago
Activity icon

Replied to Laravel Sail / Docker Is Slow

@neilstee

Then I guess it's okay that it is slow? As long as it works and you know that the cause of slowness is your machine? Or the slowness is causing an issue on the Horizon part?

I haven't seen any issues with Horizon due to the slowness. (It's just annoying that it is slow)

I'll try with a fresh Laravel & Horizon install and report back.

Apr
07
1 month ago
Activity icon

Replied to Laravel Sail / Docker Is Slow

Also, have you tried installing WSL2? I see some threads that recommend using it for running Sail although I'm not familiar with it since I'm using Mac

@neilstee I'm running WSL2. It's an existing project that I'm trying to run with Sail.

I don't need it badly, but I'd prefer to make sure that everything works with Horizon before I deploy the new update.

Activity icon

Replied to Laravel Sail / Docker Is Slow

@neilstee I used Laragon before switching to Laravel Sail. My reason for switching is that I need to run horizon, as it's used in my production environment.

Activity icon

Replied to Laravel Sail / Docker Is Slow

@neilstee

I want to emulate my production environment, where I use Horizon. That's why I'd like to use Docker.

My laptop, which I'm currently on has 8Gb ram, and a 300GB SSD? Personally, I would like the laptop to have more ram.

Apr
06
1 month ago
Activity icon

Started a new Conversation Laravel Sail / Docker Is Slow

Hi!

I'm in the middle of changing my dev environment from Laragon to Laravel Sail.

However, when accessing 127.0.0.1 it takes a good time for the browser to even respond with some data.

Any ideas that could improve the response time?

Apr
02
1 month ago
Activity icon

Replied to Nova Graph Library

Okay, thank you

Activity icon

Started a new Conversation Nova Graph Library

What graph library does Nova use, is it open source? If not, can you recommend any alternatives?

Apr
01
1 month ago
Activity icon

Replied to Difference Between Forge And Envoyer?

Thank you for the reply @drehimself

Is there any good/quick guide on the usage of Forge and Envoyer together?

Activity icon

Started a new Conversation Difference Between Forge And Envoyer?

Hi!

I'm about to deploy my laravel app, and I'm wondering what I should use, Laravel Forge or Laravel Envoyer.

I would gladly take differences and similarities.

Best Regards

Mar
23
1 month ago
Activity icon

Replied to Searchable Select Input

Hmm, seems cool. But I'm currently interested in spending money on it, as I'm trying to learn as much of Livewire and AlpineJS as possible.

Activity icon

Replied to Searchable Select Input

@corvs There are some cases where I'd like it to be initially, but others where when the user actually enters something.

Activity icon

Replied to Searchable Select Input

@corvs I need to fetch data from the server, upon loading, as the select is requiring data from the server.

Do you have any other recommendations?

Activity icon

Replied to Searchable Select Input

I don't like the way it's made, I'd prefer a Livewire component instead.

Activity icon

Replied to Searchable Select Input

More like Select2, if you know it

Activity icon

Started a new Conversation Searchable Select Input

I'm currently working on an app that requires a searchable input, like where I can search states for a country in a form.

How would I go about it?

Mar
15
1 month ago
Activity icon

Replied to Storage Of QuillJS Content

Found out that it was missing an input event...

element.dispatchEvent(new Event('input'));
Activity icon

Replied to Storage Of QuillJS Content

Elarporate on the different approach?

Activity icon

Replied to Storage Of QuillJS Content

@snapey I've used the example you gave me, but for some reason whenever I submit the form, the hidden input's value is null? Any idea on how to fix that?

Activity icon

Replied to Storage Of QuillJS Content

Worked :)

Mar
14
1 month ago
Activity icon

Replied to Storage Of QuillJS Content

@snapey You don't happen to know how I can prevent the editor to disappear when I use form validation from Livewire?

Activity icon

Replied to Storage Of QuillJS Content

How did you store it in the database? Like what collumn type?

Activity icon

Started a new Conversation Storage Of QuillJS Content

Hi! I'm currently working on adding QuillJS to a project, and I'm currently stuck with how I should store QuillJS's content for later rendering?

Any thoughts/ideas?

Thanks in advance!

Feb
03
3 months ago
Activity icon

Replied to General Error: 1364 Field 'name' Doesn't Have A Default Value

It seems like it doesn't matter

Activity icon

Replied to General Error: 1364 Field 'name' Doesn't Have A Default Value

Fixed it. Thank you so much. What does the strict value even do?

Activity icon

Replied to General Error: 1364 Field 'name' Doesn't Have A Default Value

I've just checked, even tho I remove the paratheses it doesn't fix it. None of my factories uses the User Model other than the UserFactory

Activity icon

Started a new Conversation General Error: 1364 Field 'name' Doesn't Have A Default Value

Hi!

I'm currently sitting with an odd issue.

When I try to run $user = App\Models\User::factory()->create(); in Tinker, it giving me this error

Illuminate\Database\QueryException with message 'SQLSTATE[HY000]: General error: 1364 Field 'name' doesn't have a default value (SQL: insert into users (updated_at, created_at) values (2021-02-03 08:19:29, 2021-02-03 08:19:29)

However, it shouldn't as the factory does have a value for the name:

<?php

namespace Database\Factories;

use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;

class UserFactory extends Factory
{
    /**
     * The name of the factory's corresponding model.
     *
     * @var string
     */
    protected $model = User::class;

    /**
     * Define the model's default state.
     *
     * @return array
     */
    public function definition()
    {
        return [
            'name' => $this->faker->name(),
            'email' => $this->faker->unique()->safeEmail,
            'password' => 'yIXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
        ];
    }
}

And the name field is specified in my $fillables array:

<?php

namespace App\Models;

use App\Models\Academic;
use App\Traits\HasRoles;
use Database\Factories\UserFactory;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Foundation\Auth\User as Authenticatable;
use App\Traits\Notifiable;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;

class User extends Authenticatable
{
    use Notifiable, HasFactory, HasRoles;

    protected static $databaseNotificationClass = DatabaseNotification::class;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];

    /**
     * Returns the user's academic
     *
     * @return HasOne
     */
    public function academic(): HasOne
    {
        return $this->hasOne(Academic::class);
    }
}

I run on PHP 7.4 & Laravel 8.

I've tried the following:

  • Running composer dump-autoload -o
  • Restarted tinker
  • Made sure that my name is in $fillable
  • Running dump(new User()) which returned https://i.imgur.com/4peAxE9.png

I've posted this earlier today: https://laracasts.com/discuss/channels/laravel/general-error-1364-field-name-doesnt-have-a-default-value-1 Reposted as I marked a comment as "best answer" by a mistake.