kbuczynski

kbuczynski

Software Engineer at BuildEmpire

Member Since 5 Months Ago

Manchester

Experience Points
5,960
Total
Experience

4,040 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
50
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.

Level 2
5,960 XP
Nov
21
1 week ago
Activity icon

Replied to Call To Undefined Method Dotenv\Repository\RepositoryBuilder::create()

Thanks @jlrdw I had a look again at the composer.json and found out that i missed collision and it had wrong version

Activity icon

Started a new Conversation Call To Undefined Method Dotenv\Repository\RepositoryBuilder::create()

Hello. I have just upgrade one of my smaller project from Laravel 7 to 8 After the successful upgrade with Laravel upgrade guide I am not able to run php artisan test anymore and get error stack in terminal

   Error 

  Call to undefined method Dotenv\Repository\RepositoryBuilder::create()

  at vendor/nunomaduro/collision/src/Adapters/Laravel/Commands/TestCommand.php:129
    125|      */
    126|     protected function clearEnv()
    127|     {
    128|         if (!$this->option('env')) {
  > 129|             $repositories = RepositoryBuilder::create()
    130|                 ->make();
    131| 
    132|             $envs = Dotenv::create(
    133|                 $repositories,

      +14 vendor frames 
  15  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

I have tried to run composer update and composer install after removing vendor dir but did not helped :/

Nov
20
1 week ago
Activity icon

Replied to PHP Unit Testing Return 500 On Post Json

Small update After suggestion from @tykus I had a look closer and turns out my Request Validation had wrong syntax

public function rules(): array
    {
        return [
            'type' => 'required|max:50|unique:App\CrmCompanyType,type',
        ];
    }

After correcting this mistake it worked !

Nov
14
2 weeks ago
Activity icon

Replied to PHP Unit Testing Return 500 On Post Json

I am not sure on that name gonna confirm it in a morrning I think something is going wrong with it The table should be called test_crm_company_type :o

Activity icon

Replied to PHP Unit Testing Return 500 On Post Json

No but I do run

        parent::setUp();

        $this->artisan('passport:install', ['--no-interaction' => true]);
        $this->artisan('key:generate', ['--no-interaction' => true]);
        $this->artisan('db:seed', ['--class' => 'CountrySeeder']);
        $this->artisan('db:seed', ['--class' => 'DatabaseSeeder']);
        $this->artisan('db:seed', ['--class' => 'TestingSeeder']);

in the setUp in the TestCase.php file

Activity icon

Replied to PHP Unit Testing Return 500 On Post Json

HI thanks for the reply I have DatabaseMigration as a trait in my file I tried use RefreshDatabase; but it throws foreign key error as database is either not seeded or seeding runs first on the SetUp

Activity icon

Started a new Conversation PHP Unit Testing Return 500 On Post Json

Hello. I have created small unit test to test a post route to my API. However the unit tests return 500 on it and never hits the controller and IDK why :(

The error: [previous exception] [object] (PDOException(code: 42S02): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'perparson_test.test_lar_App\\CrmCompanyType' doesn't exist at /home/kbuczynski/Documents/projects/PerParsonV2/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:67) [stacktrace]

My route looks like this

Route::namespace('Api\Crm')
     ->group(function () {
         Route::group(['prefix' => 'crm', 'middleware' => 'auth:api'], function () {
             Route::group(['prefix' => 'type'], function () {
                 Route::get('/', '[email protected]')
                      ->name('crm_type_index');
                 Route::get('/{id}', '[email protected]')
                      ->name('crm_type_show');
                 Route::post('/', '[email protected]')
                      ->name('crm_type_store');
                 Route::put('/{id}', '[email protected]')
                      ->name('crm_type_update');
                 Route::delete('/{id}', '[email protected]')
                      ->name('crm_type_delete');
             });
         });
     });

And test function

    public function testPostNewType()
    {
        $post = ['type' => 'New Test Type'];

        $this->actingAs($this->standardUser, 'api')
             ->postJson('/api/crm/type', $post)
             ->assertStatus(Code::HTTP_CREATED)
             ->assertJsonFragment($post);
    }
Oct
22
1 month ago
Activity icon

Replied to Laravel PHPUnit Testing Issue

Small update thanks to @automica i manage to unlock the tables with simple query he gave me as a example. Also manage to determinate which actions cause the lock and fixed it

many thanks <3

Oct
16
1 month ago
Activity icon

Replied to Laravel PHPUnit Testing Issue

I have debug this further and turns out posgress is locking the transaction casing drop to wait for the release of previous one .

Idk yet how to solve this but at least i got that far

Activity icon

Replied to Laravel PHPUnit Testing Issue

Thanks for the help with a debug @automica It showed me what query its failing on

I found out it hangs on (as part of databasemigration trait) drop table "migrations","oauth_auth_codes","oauth_access_tokens","oauth_refresh_tokens","oauth_clients","oauth_personal_access_clients","users","organisation_user","organisations","password_resets","jobs","failed_jobs","roles","abilities","permissions","preferences","assigned_roles","shared_buckets","shared_assets","shared_asset_folders","shared_asset_shared_font","shared_fonts","shared_font_shared_theme","shared_themes","cultures" cascade

and this occurs in dbal package which is at version 2.10.4

Do you have any further tips how to debug this ?

Oct
15
1 month ago
Activity icon

Replied to Laravel PHPUnit Testing Issue

I try that thanks :) @automica

Activity icon

Replied to Laravel PHPUnit Testing Issue

@bugsysha I agree its is a tough cookie but I would like to know if there is anything I can do on my end to debug this so I can understand why it hangs. something like print out extra msg on the screen or in the log file would be very helpful

@talinon already run using the arguments and i discover that it was hanging on migrate:refresh runned by the DatabaseMigration trait.

Activity icon

Replied to Laravel PHPUnit Testing Issue

Thanks @automica @bugsysha I updated the XML just to make sure. sadly it still hangs :(

Activity icon

Replied to Laravel PHPUnit Testing Issue

The tests are already using DatabaseMigrations only Do you have an example of phpunit.xml for Laravel 6 that i can compare with ?

Activity icon

Replied to Laravel PHPUnit Testing Issue

HI @automica Sadly it still hangs :(

Activity icon

Replied to Laravel PHPUnit Testing Issue

Hmm... Running now I update the result once its done

Activity icon

Started a new Conversation Laravel PHPUnit Testing Issue

Hi I have an rest api application which uses PostgreSQL multi-schema solution to store data base on a subdomain instance.

While running the unit test is hang half way threw after upgrading the application from 5.8 to ^6.0 Laravel. Further debugging shows it hangs at specific point (around 48% done threw going all the test) when it tries to run migrate:fresh as part of a database migration trait used in the php test file.

The test env uses a database is set up on docker (I tried memory setup too same issue)

The tests has been run individually and they all work fine (passing and everything) just hangs when I try to run them all.

How do I debug it? I tried stepping threw the code not showing anything. Is there a way I can try to print out the migration output or enable some sort of extra login.

I am happy to provide more information if I can but I am not able to share any code.

Edit:

I tried running it on mysqlite but it still hangs

I have debug this further and turns out postgres is locking the transaction casing drop to wait for the release of previous one .

Idk yet how to solve this but at least i got that far

Sep
07
2 months ago
Activity icon

Replied to Laravel Paypal Multi User Account Setup

Following my comment There is a override method $provider->setApiCredentials($config); which u can pass your own $config

Activity icon

Replied to Laravel Paypal Multi User Account Setup

Ah I see @abingpj that should not be a problem if you would look at the https://github.com/srmklive/laravel-paypal and read the code for the PayPal service the constructor for it does accept config string|array which are used as the config. This is all from what I manage to read in last 5min.

I recommend reading the code it self not just the documentation to understand how it all works :)

Activity icon

Replied to Laravel Paypal Multi User Account Setup

From what I understand a secret and id value is a part of API keys needed to make a connection to PayPal API.

If use would want to add such keys to your application it should be stored in the database and fetch when needed to make a connection to the service.

If you want you application to connect only to one PayPal account then you should specify them in the .env file and fetch them from there when needed.

Aug
13
3 months ago
Activity icon

Replied to Route Problem Returns 403 - Not Executing Controller Either

Ahh I have just facepalm yes that was it I must have missed it :(

Thanks for the helo :D

Activity icon

Replied to Route Problem Returns 403 - Not Executing Controller Either

since this is a api.php file The route is example.com/api/crm/1/address

I did try to put route as / but with the same result

I am using Laravel Passport for api auth maybe I implemented it badly

Aug
12
3 months ago
Activity icon

Started a new Conversation Route Problem Returns 403 - Not Executing Controller Either

Hi

I been working on my API and for some reason at one point the POST route started to return 403 error

This is the part of api.php file which contains the routes for the group

 Route::group(['prefix' => 'crm'], function () {
        //CRM [/api/crm/{?id}]
        Route::get('', 'Api\Application\Crm\[email protected]');
        Route::get('{id}', 'Api\Application\Crm\[email protected]')
             ->where('id', '[0-9]+');
        Route::post('', 'Api\Application\Crm\[email protected]');
        Route::put('{id}', 'Api\Application\Crm\[email protected]')
             ->where('id', '[0-9]+');
        Route::delete('{id}', 'Api\Application\Crm\[email protected]')
             ->where('id', '[0-9]+');

        //CRM Addresses [/api/crm/{id}/address/{?id}]
        Route::group(['prefix' => '{id}/address', 'where' => ['id' => '[0-9]+']], function () {
            Route::get('', 'Api\Application\Crm\[email protected]');
            Route::get('{addressId}', 'Api\Application\Crm\[email protected]')
                 ->where('addressId', '[0-9]+');

            Route::post('', 'Api\Application\Crm\[email protected]');
        });
    });

I might have messed up and order or something but everything is working upto the last part which is

Route::post('', 'Api\Application\Crm\[email protected]');

At that point i am getting This action is unauthorized. error :(

Aug
11
3 months ago
Activity icon

Replied to Laravel With Homestead Unit Testing Keeps Using Local DB For Migrations

I think that was it I dont see migration getting removed anymore and no new data added either :)

Activity icon

Replied to Laravel With Homestead Unit Testing Keeps Using Local DB For Migrations

This is the model

User.php

<?php

namespace App\Models\Application;

use Eloquent;
use Illuminate\Auth\Authenticatable as AuthenticableTrait;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Laravel\Passport\HasApiTokens;

/**
 * Class User
 *
 * @package App\Models\Application
 * @mixin Eloquent
 */
class User extends Model implements Authenticatable
{
    use HasApiTokens;
    use AuthenticableTrait;

    protected $fillable = [
        'email', 'password'
    ];

    protected $hidden = [
        'password',
    ];
}
Activity icon

Started a new Conversation Laravel With Homestead Unit Testing Keeps Using Local DB For Migrations

Hi I have setup 2nd pgsql DB with homestead but migration and testing are still running of my main one instead of the testing one. I have no idea why and how.

database.php


'pgsql_testing' => [
            'driver'         => 'pgsql',
            'url'            => env('TEST_DATABASE_URL'),
            'host'           => env('TEST_DB_HOST', '127.0.0.1'),
            'port'           => env('TEST_DB_PORT', '5432'),
            'database'       => env('TEST_DB_DATABASE', 'forge'),
            'username'       => env('TEST_DB_USERNAME', 'forge'),
            'password'       => env('TEST_DB_PASSWORD', ''),
            'charset'        => 'utf8',
            'prefix'         => '',
            'prefix_indexes' => true,
            'schema'         => 'public',
            'sslmode'        => 'prefer',
        ],

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>
        </testsuite>
    </testsuites>
    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">./app</directory>
        </whitelist>
    </filter>
    <php>
        <server name="APP_ENV" value="testing"/>
        <server name="BCRYPT_ROUNDS" value="4"/>
        <server name="CACHE_DRIVER" value="array"/>
        <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="DB_CONNECTION" value="pgsql_testing"/>
    </php>
</phpunit>

.env

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:hRoKKhMvY0GC7votogxW908/ynDvQ2NTrnVyoVEuK7M=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=pgsql
DB_HOST=localhost
DB_PORT=5432
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

TEST_DB_HOST=localhost
TEST_DB_PORT=5432
TEST_DB_DATABASE=homestead_testing
TEST_DB_USERNAME=homestead
TEST_DB_PASSWORD=secret

Unit test files TestHelper.php

<?php


namespace Tests\helpers;

use App\Models\Application\User;

trait TestSetUpHelper
{
    public function provisionApplication()
    {
        $this->passwordInit();

        factory(User::class, 1)->create(
            [
                'email' => '[email protected]',
            ]
        );

        $this->user1 = User::findOrFail(1);
    }


    private function passwordInit()
    {
        $this->artisan('passport:install --force');
    }
}

UserTest.php

<?php

namespace Tests\Unit;

use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\helpers\TestSetUpHelper;
use Tests\TestCase;

class UserTest extends TestCase
{
    use TestSetUpHelper;
    use DatabaseMigrations;
    use DatabaseTransactions;

    public function setUp(): void
    {
        parent::setUp();

        $this->provisionApplication();
    }

    /**
     * A basic api login test
     *
     * @return void
     */
    public function testUserLogin()
    {
        $userLoginDetails = [
            'email'    => '[email protected]',
            'password' => 'password',
        ];

        $response = $this->actingAs($this->user1, 'api')
                         ->postJson('/api/auth/login', $userLoginDetails)
                         ->assertJsonStructure(['access_token', 'token_type', 'expires_at']);

        $response->assertStatus(200);
    }
}

Aug
08
3 months ago
Activity icon

Replied to Relationship In DB Does Not Exist

Thanks @geordiejackson that was it a simple typo that I have misted a very big thumbs up for you

Activity icon

Started a new Conversation Relationship In DB Does Not Exist

HI I been trying to connect my tables together in postgres but I am keep getting a SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "crm_company_addresses" does not exist

I can not figure out what is causing the problem and I would like to understand what I am doing wrong

Migration order

Migrating: 2014_10_12_000000_create_users_table
Migrated:  2014_10_12_000000_create_users_table (0.01 seconds)
Migrating: 2014_10_12_100000_create_password_resets_table
Migrated:  2014_10_12_100000_create_password_resets_table (0.01 seconds)
Migrating: 2016_06_01_000001_create_oauth_auth_codes_table
Migrated:  2016_06_01_000001_create_oauth_auth_codes_table (0.01 seconds)
Migrating: 2016_06_01_000002_create_oauth_access_tokens_table
Migrated:  2016_06_01_000002_create_oauth_access_tokens_table (0.01 seconds)
Migrating: 2016_06_01_000003_create_oauth_refresh_tokens_table
Migrated:  2016_06_01_000003_create_oauth_refresh_tokens_table (0 seconds)
Migrating: 2016_06_01_000004_create_oauth_clients_table
Migrated:  2016_06_01_000004_create_oauth_clients_table (0.01 seconds)
Migrating: 2016_06_01_000005_create_oauth_personal_access_clients_table
Migrated:  2016_06_01_000005_create_oauth_personal_access_clients_table (0 seconds)
Migrating: 2019_08_19_000000_create_failed_jobs_table
Migrated:  2019_08_19_000000_create_failed_jobs_table (0.01 seconds)
Migrating: 2020_08_08_133810_create_crm_companies_table
Migrated:  2020_08_08_133810_create_crm_companies_table (0 seconds)
Migrating: 2020_08_08_150735_create_crm_companies_address_table
Migrated:  2020_08_08_150735_create_crm_companies_address_table (0.01 seconds)

Migration for crm_companies_table

    public function up()
    {
        Schema::create('crm_companies', function (Blueprint $table) {
            $table->id();
            $table->string('company_name');
            $table->timestamps();
        });
    }

Migration for crm_companies_address_table

public function up()
    {
        Schema::create('crm_companies_addresses', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('crm_company');
            $table->string('address_line_1');
            $table->string('address_line_2');
            $table->string('city');
            $table->string('post_code');
            $table->string('country');
            $table->timestamps();

            $table->foreign('crm_company')->references('id')->on('crm_companies')->onDelete('cascade');
        });
    }

Model CrmCompany

class CrmCompany extends Model
{
    public function address()
    {
        return $this->hasMany('App\Models\Application\Crm\CrmCompanyAddress', 'crm_company');
    }

}

Model CrmCompanyAddress

class CrmCompanyAddress extends Model
{
    public function crmCompany() {
            return $this->hasOne('App\Models\Application\CrmCrmCompany', 'crm_company');
    }
}

Jun
26
5 months ago
Activity icon

Replied to Any Suggestions For "Laravel Projects" To Build :) ?

Sorry been away for a bit...

hmm something simple like writing a library for wikipedia api that can be used with laravel sounds already like lot of fun

Jun
22
5 months ago
Activity icon

Replied to Laravel CMS - What Do You Suggest

Right I get you now but this is still just going step by step and specking out what functions you need and how you want to handle it

Activity icon

Replied to Requesting Modal HTML With Ajax How To Handle

i see... is there way to have content passed to them too from the $user object too so the fields will get filled for the edit modal ?

Activity icon

Replied to Laravel CMS - What Do You Suggest

I think this is more of a project management type of a question. You should spec out your customer requirements and work out what can you achieve withing 2-3 weeks time (a sprint) then work your way to the end feature by feature.

Activity icon

Started a new Conversation Requesting Modal HTML With Ajax How To Handle

Hi I wonder about how should I restructure my controllers. Each time I try to edit or remove something an ajax is fired to fetch modal HTML onto my page which is generated using PHP.

I wonder whats the best way to handle/structure the controllers. Should I move all the ajax request for modal to its own controllers or leave it where they are

this is an example of user controller any sort of review would be great :)

/**
 * Class UsersController
 * Controller for Admin User Interactions
 *
 * @package App\Http\Controllers
 */
class UsersController extends Controller
{
    private array  $params;
    private string $returnUrl;

    public function __construct()
    {
        $this->params = [
            'pageTitle' => 'Users',
            'usersdata' => User::paginate(10),
        ];

        $this->returnUrl = URL::to('/admin/users');
    }

    /**
     * Index function to return a index html
     *
     * @return Factory|View
     */
    public function show()
    {
        $this->params['user'] = new User();

        return view('admin.users.index', $this->params);
    }

    /**
     * Function to return a ajax modal or process a "New User" request
     *
     * @param Request $request
     *
     * @return Factory|JsonResponse|RedirectResponse|View|object
     * @throws Throwable
     */
    public function create(Request $request)
    {
        $request->validate(
            [
                'name'  => 'required | string',
                'email' => 'required | email',
            ],
            [
                'name.required'  => __('app_admin_user.name_validation_required'),
                'name_string'    => __('app_admin_user.name_validation_string'),
                'email.required' => __('app_admin_user.email_validation_required'),
                'email.email'    => __('app_admin_user.email_validation_email'),
            ]
        );

        if (!empty(User::where('email', $request->email)->first())) {
            return redirect()
                ->intended($this->returnUrl)
                ->withErrors([__('app_admin_user.user_validation_exist')]);
        }

        $requestData = $request->only(['name', 'email', 'password']);

        $user = new User();
        $user->addNewUser((object)$requestData);

        return redirect()
            ->intended($this->returnUrl)
            ->with('alert_success', __('app_admin_user.user_validation_create_success', ['email' => $user->email]));
    }

    /**
     * Return a ajax modal or process edit request
     *
     * @param int     $id
     * @param Request $request
     *
     * @return JsonResponse|object
     */
    public function edit(int $id, Request $request)
    {
        $request->validate(
            [
                'id'    => 'required | integer',
                'email' => 'required',
                'name'  => 'required | string',
            ],
            [
                'id.required'    => __('app_admin_user.id_validation_required'),
                'id.integer'     => __('app_admin_user.id_validation_integer'),
                'email.required' => __('app_admin_user.email_validation_required'),
                'name.required'  => __('app_admin_user.name_validation_required'),
                'name_string'    => __('app_admin_user.name_validation_string'),
            ]
        );

        $user = User::where('id', $id)->firstOrFail();

        $requestData = $request->only('id', 'email', 'password', 'name');

        $user->updateUser((object)$requestData);
        return redirect()
            ->intended($this->returnUrl)
            ->with('alert_success', __('app_admin_user.user_validation_update_success', ['email' => $user->email]));
    }

    /**
     * Get Modal for create form
     *
     * @return JsonResponse|object
     */
    public function showModalCreate()
    {
        $response = new stdClass();

        $modalOptions = new ModalFormComponentOptions("/admin/user/create", 'POST');
        $modalOptions->setHeading('app_admin_user.user_modal_new_header');

        $response->body = (new CustomBladeComponent(ModalForm::class, $modalOptions))
            ->toHTML(view('admin.users.modal_create'));

        return response()
            ->json($response)
            ->setStatusCode(200);
    }

    /**
     * Get Modal for edit form
     *
     * @param int $id
     *
     * @return JsonResponse|object
     */
    public function showModalEdit(int $id)
    {
        $response = new stdClass();

        $user = User::where('id', $id)->firstOrFail();

        $modalOptions = new ModalFormComponentOptions("/admin/users/edit/$id", 'POST');
        $modalOptions->setHeading(_('app_admin_user.user_modal_edit_header', ['name' => $user->name]));

        $response->body = (new CustomBladeComponent(ModalForm::class, $modalOptions))
            ->toHTML(view('admin.users.modal_edit', ['user'=> $user]));

        return response()
            ->json($response)
            ->setStatusCode(200);
    }
}
Activity icon

Replied to Any Suggestions For "Laravel Projects" To Build :) ?

I always recommend as a start idea to pick an API and do something with it. Maybe it will turn into something fun.

Activity icon

Replied to PostgreSQL Error :SQLSTATE[23502]: Not Null Violation: 7 ERROR

As I suspected the id is just a integer if you would change it to be a increments the SQL error should resolve

Activity icon

Replied to PostgreSQL Error :SQLSTATE[23502]: Not Null Violation: 7 ERROR

Can we see your migration file with the table structure ?

I would think the id is not set as auto increment but I cant confirm without seeing the database table structure

Jun
15
5 months ago
Activity icon

Replied to How To Refactor A Large Function Into A Smaller One?

Hmm thought one I must say as refactoring code is never easy.

The list you have provided surly help and I think each of these should be its own private function which then can be called within the processPayment()

Your code has many if statements and checks so each which can be easily turn into function If x is true execute functions.