zaster

Member Since 5 Years Ago

Experience Points
30,670
Total
Experience

4,330 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
101
Lessons
Completed
Best Reply Awards
7
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 7
30,670 XP
Jun
10
2 days ago
Activity icon

Started a new Conversation Textarea Component - Getting The Text To Display - Jetstream Modal

How can i get to display Test inside the textarea

<textarea {{ $attributes->merge(['class' => 'border-gray-300 focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 rounded-md shadow-sm w-full']) }}>
    {{ $slot }}
</textarea>
<x-textarea>test</x-textarea>

Edit : I am using a modal in this case

<div>
    <x-jet-button wire:click="createShowModal">
        {{ __('Create Quotation') }}
    </x-jet-button>

    {{-- Modal Form --}}
    <x-jet-dialog-modal wire:model="modalFormVisibility">

        <x-slot name="title">
              {{ __('Create Quotation') }}
        </x-slot>

        <x-slot name="content">

                 <x-textarea>test</x-textarea>

        </x-slot>

        <x-slot name="footer">
            <x-jet-secondary-button wire:click="$toggle('confirmingLogout')" wire:loading.attr="disabled">
                {{ __('Cancel') }}
            </x-jet-secondary-button>
            <x-jet-secondary-button wire:click='create' wire:loading.attr='disabled'>
                {{ __('Submit') }}
            </x-jet-secondary-button>
        </x-slot>
    </x-jet-dialog-modal>
</div>

Jun
07
5 days ago
Activity icon

Replied to Form Validation - Dd();

@snapey Thank you. That was the issue.

Activity icon

Replied to Form Validation - Dd();

@davy_yg

dd('Test');

didn't work

Activity icon

Started a new Conversation Form Validation - Dd();

Validation works perfectly. The dd function doesn't work.

<?php

namespace App\Http\Livewire\FormValidation;

use Livewire\Component;

class Test extends Component
{
    public $name;
    public $email;
    public $phone;
    public $msg;


    public function submitForm()
    {
        $this->validate([
            'name' => 'required',
            'email' => 'required|email',
            'phone' => 'required|digits:10',
            'msg' => 'required|min:20',
        ]);

        //dd('Test');
        dd($this->name, $this->email, $this->phone, $this->msg);
    }

    public function updated($fields)
    {
        $this->validateOnly($fields, [
            'name' => 'required',
            'email' => 'required|email',
            'phone' => 'required|digits:10',
            'msg' => 'required|min:20',
        ]);
    }

    public function render()
    {
        return view('livewire.form-validation.test');
    }
}

<div class="p-4">
<form wire.submit.prevent="submitForm()">
    <input wire:model.lazy='name'type="text" name="name" placeholder="Name">
    @error('name') <p class="text-red-400">{{ $message }}</p> @enderror
    <br><br><br>

    <input wire:model.lazy='email'type="email" name="email" placeholder="Email">
    @error('email') <p class="text-red-400">{{ $message }}</p> @enderror
    <br><br><br>

    <input wire:model.lazy='phone'type="text" name="phone" placeholder="Phone">
    @error('phone') <p class="text-red-400">{{ $message }}</p> @enderror
    <br><br><br>

    <textarea wire:model.lazy='msg' name="msg" cols="30" rows="10" placeholder="Message"></textarea>
    @error('msg') <p class="text-red-400">{{ $message }}</p> @enderror
    <br><br><br>

    <button class="p-2 border-2 border-indigo-400 rounded-xl">Submit</button>

</form>

</div>
Activity icon

Replied to Livewire Hydrate Not Working ?

@silencebringer I was following the screen casts and somethings have changed i guess. https://laravel-livewire.com/screencasts/hooks

Activity icon

Replied to Livewire Hydrate Not Working ?

@silencebringer Corrected it , But the issue remain the same. (I was trying various things to sort this out)

Activity icon

Started a new Conversation Livewire Hydrate Not Working ?

After the component is initialized, when i type something, the $name should output Peter. But it doesn't.

<?php

namespace App\Http\Livewire\Lifecycle;

use Livewire\Component;

class HelloWorld extends Component
{

    public $name = 'Jelly';
    //public $hydrate;

    public function mount()
    {
        $this->name = "John";
    }

    public function hydrate()
    {
        //$this->hydrate = 'Peter';
       $this->name = 'Peter';
    }


    public function render()
    {
        return view('livewire.lifecycle.hello-world');
    }
}

<div class="p-4">
    <input type="text" wire:model='name'>
    <br><br>
    Hello {{ $name }}
</div>

Jun
05
1 week ago
Activity icon

Started a new Conversation Wire:submit.prevent Vs Wire.submit

What is the difference between wire:submit.prevent vs wire.submit

They both submits the form without any issue.

I know that wire:submit.prevent is the one to use

But why?

Edit : Is it to prevent the page refresh when a form submission is done

Activity icon

Replied to Livewire Cannot Pass Arbitrary Value To Model

@randy_johnson

Check if you are using any web browser extensions such as "Live Server Web Extension". If yes, Switch off it an try again.

Jun
02
1 week ago
Activity icon

Replied to Laravel Help

@kony It is possible. But it is not the recommended way.

Please search for DBMS Normalization or check the below link

https://www.javatpoint.com/dbms-normalization

Activity icon

Replied to Laravel Help

@kony

In that case you can have something like this

skills table

$table->id();
$tabel->integer('skill_level_id');
$tabel->integer('progress_level_id');
$table->text('heading');
$table->text('subHeading');
$table->text('description');

skill_levels table

$table->id();
$table->string('name');

progress_levels table

$table->id();
$table->string('name');

Please read

https://laravel.com/docs/8.x/eloquent-relationships#one-to-many

Activity icon

Replied to User And Company - Relationship

@isalmi that approach will be a problem since this project heavily depends on "Companies"

May
31
1 week ago
Activity icon

Replied to User And Company - Relationship

@bugsysha I just saw this.

But then how are you handling permissions if the user doesn't have the company?

In that case, is there a way to have NULL mentioned in the company_id field and kind of work on a gate or policy( I have no idea)

My other option is, like i mentioned before, When the user creates a user profile, if the user doesn't have a company(E.g. - Freelancer) then that user can click on a checkbox saying (No Company). Then when this user gets saved to the system automatically a company will be created to his name (inside the companies table) and it will enable a boolean saying(Virtual company). I think this is the simplest way(Kind of a workaround, may not suit for all)

Activity icon

Replied to User And Company - Relationship

@bugsysha

So is this what you are saying(Polymorphic Approach)

bills table

id
payment_details_id

payment_details table

id
paymentable_id
paymentable_type

companies and users tables will be the parents of payment_details table

Activity icon

Replied to User And Company - Relationship

@bugsysha

This is based on multiple user , multiple roles and multiple companies

I already have this table(for permission purpose)

company_user

company_id
user_id
role_id

If i go with the payment_details approach

I have no idea how i am going to handle the permissions side of the app

Edit : I am trying to figure this out(working on the database architecture).

May
30
1 week ago
Activity icon

Replied to Can I Run Multiple Command With Artisan Serve Laravel?

@tusharkha012

You can create a new tab in your terminal and run the other artisan commands(Let php artisan serve run in the old tab).

That's what i do

Activity icon

Replied to Undefined Variable

@deepjyoti

Try to test this and understand

app/Http/Livewire/Test.php


<?php

namespace App\Http\Livewire;

use Livewire\Component;

class Test extends Component
{
    public function render()
    {
        
        return view('livewire.test', [
            'test' => 'Test from Livewire',
        ]);
    }
}

resources/views/livewire/test.blade.php


<div>
   {{ $test }}
</div>


This is the laravel blade file not the livewire blade file

resources/views/welcome.blade.php

<html>
<head>
    ...
    @livewireStyles
</head>
<body>
    <livewire:test />

    ...

    @livewireScripts
</body>
</html>

routes/web.php

Route::get('/', function () {
    return view('welcome');
});

May
29
2 weeks ago
Activity icon

Replied to User And Company - Relationship

@bugsysha say Bob is a freelancer and he is registered as a vendor in my system.

Bob does some freelancing work and we need to pay him.

How should i create a bill through our system

The ordinary bills table looks like

id
company_id
...
Activity icon

Replied to User And Company - Relationship

@bugsysha In case if we need to have a list of Actual Companies

Activity icon

Replied to User And Company - Relationship

@bugsysha So if that user doesn't have an actual company. We can automatically create a company under his name (E.g. - Bob) and then have an indicator(boolean) such as actual_company inside users table

Activity icon

Replied to User And Company - Relationship

@orest But then, considering a Bill is created to a Company

bills table has

company_id

as a foreign key. Now if Bob has no company , how can i create a bill without a company_id ?

Should i have

user_id

Also included to the bills table ?

There should be a better way of doing it

Activity icon

Replied to Database Gets Empty - With Php Artisan Test

@automica

I have been running

php artisan config:cache

through a combination of artisan commands without understanding them(Using Alias).

E.g. -

php artisan cache:clear
php artisan config:cache

Now i have corrected those

Actually there is no need to run

php artisan cache:clear && php artisan config:clear

as you have mentioned.

Thank you @automica

Activity icon

Started a new Conversation User And Company - Relationship

User and Company has a Many to Many relationship.

Sometimes the User will not have a company. In that case,

Should we just create a Company

E.g. - Bob has no company , but since we need the company_id to be used in other tables (Such as Invoices , Bills etc....)

Should we proceed as Bob user has a Bob company (For reference purpose) ?

Activity icon

Started a new Conversation Bill Payment - Company And User

The User and Company has a Many to Many relationship.

When a Bill is issued, mostly it will be issued through a Company.

Rarely there will be a User without a Company. In that case the bill should be issued through a User.

Should i have the bills table as

id
company_id(Nullable)
user_id(Nullable)
May
27
2 weeks ago
Activity icon

Replied to Break Of Concerns - Structure - SOLID Principles

@automica So one model to represent one table

There shouldn't be

app/Models/Employee/User.php

app/Models/Admin/User.php

Even when there are lot of different business logic to be included to Employee User and Admin User

Then may be those should be included using interfaces or something(Which is i am yet to find out)

Activity icon

Replied to Break Of Concerns - Structure - SOLID Principles

@martinbean

What about this

Controllers

app/Http/Controllers/Admin/UserController.php	//Used as AdminUserController in routes

app/Http/Controllers/Employee/UserController.php	//Used as EmployeeUserController in routes

Models

app/Models/Employee

app/Models/Admin

Activity icon

Started a new Conversation Break Of Concerns - Structure - SOLID Principles

I need to get an opinion on my folder structure. I am in the very beginning stages of studying SOLID Concepts

In employee section there will be sales people and they will need to get individual sales reports

app/Employee/Reports/Repositories/SalesRepository.php

Admin section will need to get overall company sales reports

app/Admin/Reports/Repositories/SalesRepository.php

Basically , IIs Having entire separate sections as Employee and Admin the way to move ahead?

Activity icon

Replied to Form Repeater For Laravel

@lacoder

In my opinion, it would be best if you could learn either jquery or livewire to achieve something like that

You could use jquery(without a plugin)

https://www.youtube.com/watch?v=KqDpESFmLrg

or livewire to do this(without a plugin) - Livewire seems to be the most preferred , in the Laravel community

https://www.youtube.com/watch?v=iuIEqOcQi6g

Edit :

https://github.com/DubFriend/jquery.repeater

has not been updated for almost 4 years, So it is better that you don't use that plugin.

May
26
2 weeks ago
Activity icon

Replied to Database Gets Empty - With Php Artisan Test

@automica I tried that and it didn't work. So i deleted it.(the .env.testing)

Activity icon

Replied to Database Gets Empty - With Php Artisan Test

@tray2

I am not using

DatabaseMigrations in any of my test classes

I use RefreshDatabase in all of my test classes

Also now i changed my test database from sqlite to mysql

phpuni.xml

	   <server name="APP_ENV" value="testing"/>
        <server name="BCRYPT_ROUNDS" value="4"/>
        <server name="CACHE_DRIVER" value="array"/>
        <server name="DB_CONNECTION" value="mysql"/>
        <server name="DB_DATABASE" value="mydb_testing"/>
        <server name="MAIL_MAILER" value="array"/>
        <server name="QUEUE_CONNECTION" value="sync"/>
        <server name="SESSION_DRIVER" value="array"/>
        <server name="TELESCOPE_ENABLED" value="false"/>

created the mysql database (mydb_testing)

and why is it deleting data in my application database , when i run tests (mydb) ?

Activity icon

Started a new Conversation Database Gets Empty - With Php Artisan Test

This happens with

        <server name="DB_CONNECTION" value="sqlite"/>
        <server name="DB_DATABASE" value=":memory:"/>

phpunit.xml

<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
         bootstrap="vendor/autoload.php"
         colors="true"
>
    <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">./tests/Feature1</directory> -->
        </testsuite>
    </testsuites>
    <coverage processUncoveredFiles="true">
        <include>
            <directory suffix=".php">./app</directory>
        </include>
    </coverage>
    <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"/>
    </php>
</phpunit>
May
25
2 weeks ago
Activity icon

Awarded Best Reply on Web App And API In Same Laravel Project?

@jeevamugunthan

routes/web.php

Route::get('/', function () {
    return "Hi from web";
});

http://127.0.0.1:8000/

Outputs

Hi from web

routes/api.php

Route::get('/', function () {
    return "Hi from api";
});

http://127.0.0.1:8000/api/

Outputs

Hi from api

For more information on APIs

https://www.youtube.com/playlist?list=PL8p2I9GklV45xlp9M1NKOqwJxDAXBrCuf https://www.youtube.com/watch?v=MT-GJQIY3EU

Edit :

Web routes use the web middleware

Api routes use the api middleware

https://github.com/laravel/laravel/blob/master/app/Http/Kernel.php#L29-L44

May
24
2 weeks ago
Activity icon

Replied to Testing - Single Test Feature

@bugsysha I have selected @martinbean 's answer as the BEST ANSWER because it let me run a single test class + outputs the test cases of that single class(which i was expecting as default)

Activity icon

Started a new Conversation Laravel - DataTables

I am using the TALL Stack as my preferred technology stack for my current project.

This project has a lot to do with Data Tables. I have used https://datatables.net/ previously.

How should i proceed

Activity icon

Replied to Testing - Single Test Feature

@martinbean This works with some warnings

PHP Warning:  Declaration of PHPUnit\Util\TestDox\CliTestDoxPrinter::printHeader(): void should be compatible with PHPUnit\TextUI\DefaultResultPrinter::printHeader(PHPUnit\Framework\TestResult $result): void in /usr/share/php/PHPUnit/Util/TestDox/CliTestDoxPrinter.php on line 118
PHPUnit 9.5.4 by Sebastian Bergmann and contributors.

User (Tests\Feature\User)
 ✔ A guest can access welcome page
 ✔ A guest can access login page
 ✔ A guest can access register page
Call to undefined method SebastianBergmann\Timer\Timer::resourceUsage()

Activity icon

Replied to Testing - Single Test Feature

vendor/bin/phpunit tests/Feature/UserTest.php

Activity icon

Replied to Test Function Names

@automica Thank You.

Activity icon

Replied to Testing - Single Test Feature

@sergiu17

vendor/bin/phpunit tests/Feature/UserTest.php

Works but without the log

Edit : Without the test descriptions

This is what i get

PHPUnit 9.5.4 by Sebastian Bergmann and contributors.

...                                                                 3 / 3 (100%)

Time: 00:00.284, Memory: 22.00 MB

OK (3 tests, 11 assertions)
Activity icon

Replied to Testing - Single Test Feature

Outputs

Cannot open file "tests/Feature/UserTest".
Activity icon

Replied to Test Function Names

@automica

Tests does work without : void

E.g.

/**
     * @test
     *
     * @return void
     */
    public function a_guest_can_access_welcome_page()
    {
        $response = $this->get('/');

        $response->assertSee('Log in');
        $response->assertSee('Register');

        $response->assertSuccessful();
    }

Is it ok to proceed like that ?

From Where did you find the assertSuccessful() method ? What should i use when it is a different assert status such as

$response->assertStatus(403);
Activity icon

Replied to Testing - Single Test Feature

@sergiu17

Nope. Still the same result.

Activity icon

Started a new Conversation Testing - Single Test Feature

php artisan test --filter UserTest

gives the below output

 PASS  Tests\Feature\AuthUserTest
  ✓ an auth user can visit user profile page

   PASS  Tests\Feature\UserTest
  ✓ a guest can access welcome page
  ✓ a guest can access login page
  ✓ a guest can access register page

I need to run only the UserTest Feature

Activity icon

Replied to Web App And API In Same Laravel Project?

@jeevamugunthan Please mark it as solved.

Activity icon

Replied to If Basket Is Full, Another Product Disabled

@rootking

I think you are in the wrong place, to post a question on symfony.

Activity icon

Replied to Web App And API In Same Laravel Project?

@jeevamugunthan

routes/web.php

Route::get('/', function () {
    return "Hi from web";
});

http://127.0.0.1:8000/

Outputs

Hi from web

routes/api.php

Route::get('/', function () {
    return "Hi from api";
});

http://127.0.0.1:8000/api/

Outputs

Hi from api

For more information on APIs

https://www.youtube.com/playlist?list=PL8p2I9GklV45xlp9M1NKOqwJxDAXBrCuf https://www.youtube.com/watch?v=MT-GJQIY3EU

Edit :

Web routes use the web middleware

Api routes use the api middleware

https://github.com/laravel/laravel/blob/master/app/Http/Kernel.php#L29-L44