Cyber Monday! Get 25% off for as long as you keep your subscription. New subscribers only.

paboo

paboo

Member Since 5 Years Ago

My

Experience Points
2,950
Total
Experience

2,050 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
5
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 1
2,950 XP
Nov
04
3 weeks ago
Activity icon

Replied to Can I Send Request With Cookie In Laravel Unit Test. This Is My Way But Still Working

@sinnbeck $response return header is object but from app or postman return its array so can i convertJsonResponse toArray thanks

Activity icon

Replied to Can I Send Request With Cookie In Laravel Unit Test. This Is My Way But Still Working

we login from social. when you login with social we will return cookie have api-token. first time you login with social you will register accout on our server. so i fake cookie for register thanks

Activity icon

Replied to Can I Send Request With Cookie In Laravel Unit Test. This Is My Way But Still Working

when i try dd($response), Cookie return []. whats happen guy

Activity icon

Started a new Conversation Can I Send Request With Cookie In Laravel Unit Test. This Is My Way But Still Working



public function testRegisterUserSuccess()
    {
        $this->faker = Factory::create();
        $data = [
            User::FAMILY_NAME =>  $this->faker->randomElement(['ド','ダオ']),
            User::GIVEN_NAME => $this->faker->randomElement(['アイン', 'ウイアン']),
            User::FAMILY_NAME_KANA => $this->faker->randomElement(['ド','ダオ']),
            User::GIVEN_NAME_KANA =>$this->faker->randomElement(['アイン', 'ウイアン']),
            User::WORK_PREFECTURE_ID => 1,
            User::WORK_PREFECTURE_PUBLISH_TYPE => 'PRIVATE',
            User::SOCIETY_TYPE => 'student',
            User::SOCIETY_PUBLISH_TYPE => 'private',
            User::LANGUAGE => 'jp',
            User::NICK_NAME => 'uyen',
            User::IS_MAIL_RECEIVABLED => 1,
            User::WORK_ORGANIZATION_NAME => 'TakajouRei',
            User::WORK_CORPORATE_NUMBER => 1000,

        ];
        $record = [
            'family_name'=>'anh',
            'given_name_kana'=>'ダオ',
            'family_name_kana'=>'ダオ',
            'profile_publish_type'=>'private',
            'work_prefecture_id'=>1000,
            'work_prefecture_publish_type'=> 'private',
            'work_organization_name'=> 'asdasda',
            'given_name'=>'sada',
            'society_type'=>'student',
            'society_publish_type'=> 'asda',
            'language'=> 'VI',
            'nick_name'=>'asd',
            'is_mail_receivabled'=>1,
            'work_corporate_number'=> 1000

        ];
//        dd($data);
        $cookie = Cookie('api-token','e3ef09fa9434e65837193bd77ca7b281c6847f8b8554fe48d98694e3c7e40dc8');
        $response = $this->call('POST',route('user.register'),$record,$cookie);
//        $response = $this->postJson(route('user.register'),$record)->withCookie('api-token','e3ef09fa9434e65837193bd77ca7b281c6847f8b8554fe48d98694e3c7e40dc8');
        $response->assertStatus(200);
        $response->assertJsonStructure([
            'api_version',
            'data'=>['user_id'],

        ]);
    }

thanks for help guys

and this is log error from CMD


 vendor/bin/phpunit --filter=testRegisterUserSuccess
PHPUnit 8.5.8 by Sebastian Bergmann and contributors.

E                                                                   1 / 1 (100%)

Time: 129 ms, Memory: 18.00 MB

There was 1 error:

1) Tests\Feature\Apis\ApiRegisterUserTest::testRegisterUserSuccess
TypeError: Argument 4 passed to Symfony\Component\HttpFoundation\Request::createRequestFromFactory() must be of the type array, object given, called in /home/ket/Desktop/gcode/vendor/symfony/http-foundation/Request.php on line 410

/home/ket/Desktop/gcode/vendor/symfony/http-foundation/Request.php:1976
/home/ket/Desktop/gcode/vendor/symfony/http-foundation/Request.php:410
/home/ket/Desktop/gcode/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:464
/home/ket/Desktop/gcode/tests/Feature/Apis/ApiRegisterUserTest.php:64

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.


Nov
02
4 weeks ago
Activity icon

Replied to Can I Using Mockery But Dont Insert Data Into Database Guys?

@nakov is .env.testing working on laravel version 7 ? thanks

Activity icon

Started a new Conversation Can I Using Mockery But Dont Insert Data Into Database Guys?

i have issue with mocking in unit test. because method factory() will insert data but i dont want create that data how do i do that? thanks. and this is my shit code. thanks guys for help :D :(



<?php

namespace Tests\Feature;

use Mockery;
use Tests\TestCase;
use App\Models\User;
use App\Repositories\CategoryRepository;

class MockingTest extends TestCase
{
    /**
     * A basic feature test example.
     *
     * @return void
     */
    public function setUp():void
    {
        parent::setUp();
    }

   public function test_mock_authenticate()
    {
        $user = User::factory()->create();

        $this->actingAs($user, 'api')
            ->postJson('/api/auth/me')
            ->assertOk()
            ->assertExactJson([
                'id'=> $user->id,
                'name'=> $user->name,
                'email'=> $user->email,
                'email_verified_at'=> $user->email_verified_at,
                'created_at' => $user->created_at,
                'updated_at' => $user->updated_at
            ]);
    }
    public function tearDown(): void
    {
        parent::tearDown(); // TODO: Change the autogenerated stub
        Mockery::close();
    }
}

Oct
30
1 month ago
Activity icon

Replied to Class 'Symfony\Component\EventDispatcher\Event' Not Found

try upgrade your package follow this website

https://packagist.org/packages/laravel/laravel 

Oct
06
1 month ago
Activity icon

Started a new Conversation Some Body Get Error With Aws Using Package Aws/aws-sdk-php When Try Upgrade Version In Laravel

only that error i will end of project but that error

Class 'Symfony\Component\EventDispatcher\Event' not found

Oct
02
1 month ago
Activity icon

Replied to Redirect To Another Page After Download Xlsx File.

in version 3.1 you can redirect when downloaded.

return  \Excel::download(new ManageHeadExport($manageHeadsExport),'manage_head.xlsx');
         return redirect()->route('manage-head.index');

it's work for me

Oct
01
1 month ago
Activity icon

Replied to Class 'Symfony\Component\EventDispatcher\Event' Not Found

@snapey i upgrade version up to 8.4. but it still error i will using your recommended :D

Activity icon

Replied to Class 'Symfony\Component\EventDispatcher\Event' Not Found

@bobbybouwmann i was remove vendor and composer.lock many time but it's told me that error. when i try debug that error i found method putObject() it's not working

Activity icon

Replied to Laravel Upgrade From 6 To 7 Fails

i was upgrade my version up 8.4 from 5.5

the first remove your folder vendor/ and composer.lock. then try run command composer install -> and search your package in https://packagist.org/ follow laravel version

Activity icon

Started a new Conversation Class 'Symfony\Component\EventDispatcher\Event' Not Found

i was get bug from Event when i upload my image in server


Error
Class 'Symfony\Component\EventDispatcher\Event' not found in line 10

and this my code call Event

 public static function uploadFileStore($file, $nameDir, $redirect = 'Admin\Admin', $params = [])
    {
        $storage = \App\Common\Factory\Storage::getInstance()->getDriver();
        $rand = rand(1, 100000);
        $milliseconds = self::milliseconds();
        $file_name = $nameDir . '/' . $milliseconds . '-' . $rand . '-' . Utility::makeFilename($file->getClientOriginalName());
        try {
            $storage->put($file_name, $file->path());
            return $attachFile = $file_name;
        } catch (S3Exception $e) {
            return redirect()->action($redirect, $params)
                ->withError(__('messages.upload.validate.upload_error'));
        }
    }

code die after calling put method. and this is put method

public function put($key, $filePath)
    {
        $log = new Log('aws');
        try {
            $client = S3Client::factory($this->getConfigs());
            $response = $client->putObject(array(
                'Bucket' => $this->getBucket(),
                'Key' => $key,
                'SourceFile' => $filePath,
                'ContentType' => mimetype_from_filename($key),
            ));


            $log->addRecord("Success: put file", Log::INFO, ['data' => $response]);

            return $response;
        } catch (S3Exception $e) {
            $log->addRecord("Error: put file", Log::ERROR, ['data' => $e]);
        }
    }

and i try using another class

use Illuminate\Http\Testing\MimeType;

and i change method calling $key

'ContentType' => MimeType::from($key),


this code in line 10 in file vendor/guzzle/guzzle/src/Guzzle/Common/Event.php

Sep
29
2 months ago
Activity icon

Replied to How To Define The Name Of The Key Parameter

in our blade view param like this


action="{{route('head.show', ['id'=> $data->id])}}"

all balde in laravel using syntax but i dont want to edit it when using resource in controller. thanks @michaloravec for help i know ur solution is better than @sinnbeck but now i dont have time to refactor this code. thanks @sinnbeck @kingmaker_bgp @michaloravec and

wish you guys have nice day :D 

Activity icon

Started a new Conversation How To Define The Name Of The Key Parameter

hi guys,

i have this issue,

my project put parameter like this

action="{{route('head.update', ['id' => $data->id])}}"

and my router here:


Route::resource('/head', 'Admin\Head');



i was upgrade verison laravel from 5.5 to 8.4 but. run my project with error.

in route list is : /head/{head}/show

can i change it like this : /head/{id}/show . if i changed from head to id i dont havechange many files. thanks

Activity icon

Replied to SQL 2300 Integrity Constraint Violation: 1452 Cannot Add Or Update A Child Row: A Foreign Key Constraint Fails

hi sir, can you help me resolve this issue,

my project put parameter like this

action="{{route('head.update', ['id' => $data->id])}}"

and my router here:


Route::resource('/head', 'Admin\Head');



i was upgrade verison laravel from 5.5 to 8.4 but. run my project with error.

in route list is : /head/{head}/show

can i change it like this : /head/{id}/show . if i changed from head to id i dont havechange many files. thanks

Activity icon

Started a new Conversation SQL 2300 Integrity Constraint Violation: 1452 Cannot Add Or Update A Child Row: A Foreign Key Constraint Fails

i try create relationship in laravel with migration but it dont work this bug return when i run command:

		
php artisan migrate --path=/database/migrations/2020_09_29_140800_alter_table_users.php



In Connection.php line 671:
                                                                               
  SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update   
  a child row: a foreign key constraint fails (`hvn_macs_product`.`#sql-bf00_  
  8c18`, CONSTRAINT `users_id_foreign` FOREIGN KEY (`id`) REFERENCES `user_pe  
  rmissions` (`user_id`) ON DELETE CASCADE) (SQL: alter table `users` add con  
  straint `users_id_foreign` foreign key (`id`) references `user_permissions`  
   (`user_id`) on delete cascade)                                              
                                                                               

In PDOStatement.php line 119:
                                                                               
  SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update   
  a child row: a foreign key constraint fails (`hvn_macs_product`.`#sql-bf00_  
  8c18`, CONSTRAINT `users_id_foreign` FOREIGN KEY (`id`) REFERENCES `user_pe  
  rmissions` (`user_id`) ON DELETE CASCADE)                                    
                                                                               

In PDOStatement.php line 117:
                                                                               
  SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update   
  a child row: a foreign key constraint fails (`hvn_macs_product`.`#sql-bf00_  
  8c18`, CONSTRAINT `users_id_foreign` FOREIGN KEY (`id`) REFERENCES `user_pe  
  rmissions` (`user_id`) ON DELETE CASCADE)                                    
                                                                               



and this is my code and engine my BD is InnoDB

and my code in database


<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AlterTableUsers extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->foreign('id')->references('user_id')->on('user_permissions')->onDelete('cascade');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('users', function (Blueprint $table) {
            //
        });
    }
}


Sep
08
2 months ago
Activity icon

Replied to Why Asppear This Bug Guys . And I Try Get Data From Empty Filter

@bobbybouwmann when should i use DB::raw(); thanks bro :P

Activity icon

Replied to Why Asppear This Bug Guys . And I Try Get Data From Empty Filter

@bobbybouwmann thanks first time i try to use query builder thanks bro :D

Activity icon

Started a new Conversation Why Asppear This Bug Guys . And I Try Get Data From Empty Filter

this is my Errors

SQLSTATE[42S22]: Column not found: 1054 Unknown column '"Honda VietNam"' in 'field list' (SQL: select `"Honda VietNam"` as `head_name`, `cs`.`name` as `acc_id`, `cs`.`display_name` as `acc_name`, `cs`.`phone` as `acc_phone`, `list_device_allow`.`uuid`, `list_device_allow`.`updated_at` from `list_device_allow` inner join (SELECT * FROM users WHERE type = "MEMBER" AND type_cms = 1) as cs on `cs`.`id` = `list_device_allow`.`hid` where `list_device_allow`.`deleted_at` is null)

when filters is empty and this bug appear this bug. in my sql syntax. thanks bro for help.


 if (!empty($filters['filters']['type']))
        {
            switch ($filters['filters']['type']){
                case 1:
                    $deviceAllows
                        ->select([
                            '"Honda VietNam" as head_name',
                            'cs.name as acc_id',
                            'cs.display_name as acc_name',
                            'cs.phone as acc_phone',
                            'list_device_allow.uuid',
                            'list_device_allow.updated_at',
                        ])
                        ->join(DB::raw('(SELECT * FROM users WHERE type = "'.User::TYPE_MEMBER.'" AND type_cms = 1) as cs'), 'cs.id' , '=', 'list_device_allow.hid')
                    ;
                    if (isset($filters['filters']['phone']) && !empty($filters['filters']['phone'])){
                        $deviceAllows->where('cs.phone', 'LIKE' , "%{$filters['filters']['phone']}%");
                    }
                    break;
                case 5:
                    $deviceAllows
                        ->select([
                            '"Honda VietNam" as head_name',
                            'cs.name as acc_id',
                            'cs.display_name as acc_name',
                            'cs.phone as acc_phone',
                            'list_device_allow.uuid',
                            'list_device_allow.updated_at',
                        ])
                        ->leftJoin(DB::raw('(SELECT * FROM users WHERE type = "'.User::TYPE_MEMBER.'" AND type_cms = '.ADMIN_TYPE_HEAD.') as cs'), 'cs.id' , '=', 'list_device_allow.hid')
                    ;
                    if (isset($filters['filters']['phone']) && !empty($filters['filters']['phone'])){
                        $deviceAllows->where('cs.phone', 'LIKE' , "%{$filters['filters']['phone']}%");
                    }
                    if (isset($filters['filters']['head_id']) && !empty($filters['filters']['head_id'])){
                        $deviceAllows->whereRaw("FIND_IN_SET(:head_id, dealer_id)", ['head_id' => $filters['filters']['head_id']]);
                    }
                    break;
                case 2:
                case 3:
                case 4:
                    $deviceAllows
                        ->select([
                            'heads.name as head_name',
                            'head_staffs.name as acc_id',
                            'head_staffs.display_name as acc_name',
                            'head_staffs.phone as acc_phone',
                            'list_device_allow.uuid',
                            'list_device_allow.updated_at',
                        ])
                        ->join('head_staffs','head_staffs.id', '=', 'list_device_allow.hid')
                        ->join('heads', 'heads.id', '=', 'list_device_allow.head_id')
                    ;
                    if (isset($filters['filters']['phone']) && !empty($filters['filters']['phone'])){
                        $deviceAllows->where('head_staffs.phone', 'LIKE' , "%{$filters['filters']['phone']}%");
                    }
                    if (isset($filters['filters']['head_id']) && !empty($filters['filters']['head_id'])){
                        $deviceAllows->where("heads.id", $filters['filters']['head_id']);
                    }
                    break;
                case 6:
                    $deviceAllows
                        ->select([
                            'heads.name as head_name',
                            'head_staffs.name as acc_id',
                            'head_staffs.display_name as acc_name',
                            'head_staffs.phone as acc_phone',
                            'list_device_allow.uuid',
                            'list_device_allow.updated_at',
                        ])
                        ->join('head_staffs','head_staffs.id', '=', 'list_device_allow.hid')
                        ->join('manage_dealer', 'manage_dealer.id', '=', 'head_staffs.head_id')
                    ;
                    if (isset($filters['filters']['phone']) && !empty($filters['filters']['phone'])){
                        $deviceAllows->where('head_staffs.phone', 'LIKE' , "%{$filters['filters']['phone']}%");
                    }
                    if (isset($filters['filters']['head_id']) && !empty($filters['filters']['head_id'])){
                        $deviceAllows->where("manage_dealer.id", $filters['filters']['head_id']);
                    }
                    break;
            }
            return $deviceAllows->get();
        }
        $deviceAllows = $modelDeviceAllow->query()
            ->select([
                'heads.name as head_name',
                'head_staffs.id as acc_id',
                'head_staffs.display_name as acc_name',
                'head_staffs.phone as acc_phone',
                'list_device_allow.uuid',
                'list_device_allow.updated_at',
                'list_device_allow.type'
            ])
            ->join('head_staffs','head_staffs.id', '=', 'list_device_allow.hid')
            ->join('heads', 'heads.id', '=', 'list_device_allow.head_id');
        if (url()->current() == route('list-request'))
        {
            $deviceAllows->where('list_device_allow.type', DEVICE_ALLOW_TYPE_REQUEST);
        }elseif (url()->current() == route('list-allow'))
        {
            $deviceAllows->where('list_device_allow.type', DEVICE_ALLOW_TYPE_ALLOW);
        }
        return $deviceAllows->get();

Jun
30
5 months ago
Jun
29
5 months ago
Activity icon

Started a new Conversation Call To Undefined Function Intervention\Image\Gd\imagecreatefromjpeg()

in my docker file .yml

ARG PHP_VERSION

FROM php:${PHP_VERSION}-fpm

MAINTAINER ông bành tổ Đỗ Xuân Anh "[email protected]"
RUN apt-get update && \
    apt-get install -y \
    libfreetype6-dev \
    libwebp-dev \
    libjpeg62-turbo-dev \
    libpng-dev \
    nano \
    libgmp-dev \
    libldap2-dev \
    netcat \
    sqlite3 \
    libsqlite3-dev && \
    docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-webp-dir=/usr/include/  --with-jpeg-dir=/usr/include/ && \
    docker-php-ext-install gd pdo pdo_mysql pdo_sqlite zip gmp bcmath pcntl ldap sysvmsg exif \
&& a2enmod rewrite
RUN docker-php-ext-install exif
RUN echo "=====INSTALL COMPOSER====="
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
#RUN php -r "if (hash_file('sha384', 'composer-setup.php') === 'a5c698ffe4b8e849a443b120cd5ba38043260d5c4023dbf93e1558871f1f07f58274fc6f4c93bcfd858c6bd0775cd8d1') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
RUN php composer-setup.php
RUN php -r "unlink('composer-setup.php');"
RUN mv composer.phar /usr/local/bin/composer
RUN echo "=====INSTALL COMPOSER COMPLETED====="
RUN composer require "ext-gd:*" --ignore-platform-reqs
RUN composer install

what heppend with my docker file

thanks for help bros
Jun
01
5 months ago
Activity icon

Started a new Conversation I Want To Create Package Or Plugin In Command In Laravel. I Created Success CRUD In Laravel. But I Cant Create Name Of Plugin So Any Help Please

this is my code in console


namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;

class CreatePackage extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'create:pack';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Create plugin simple love <3 ';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {

        $name = $this->argument('name');
        $this->getParent($name);
    }

    public function getStub()
    {

    }

    public function getParent($name)
    {
        if(!file_exists($path = app_path($name)))
            mkdir($path, 0777, true);
    }

}

end this is my bug


                                                     
  Too many arguments, expected arguments "command".