Shirshak

Shirshak

Member Since 2 Years Ago

Experience Points 9,570
Experience
Level
Lessons Completed 82
Lessons
Completed
Best Reply Awards 0
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

28 Oct
2 months ago

Shirshak left a reply on How To Add Filter To Search?

@raspectpick hmm you can change query using relationship .

Shirshak left a reply on Dynamic Content And Repeatable Custom Field Groups (like ACF For WP)

@bbbb i mean just create a tool and use fields like you normally do while creating resource.

there would be no such required architecture.

Simply Create a resource tool name contact and you can insert fields like name email etc. Can you read docs which i have linked you will be clear.

24 Oct
2 months ago

Shirshak left a reply on How To Add Filter To Search?

tischu talked about general filter.

You wanted custom filter on BelongsToMany right. I think you can just go and edit this

public function judgeOperator{
    return (relationship stuffs)->where('role','judge');

}

If judgeOperator is used on many place you can define new method like this

judgeOperatorForNova

Like that.

I hope you get it

Shirshak left a reply on Resources Only Returning 1 Item

by the way jwt package don't have any problems :)

Now nova has guards so we can easily set default guard on nova .

Shirshak left a reply on Dynamic Content And Repeatable Custom Field Groups (like ACF For WP)

Currently I think you want resource tools

here is docs

https://nova.laravel.com/docs/1.0/customization/resource-tools.html#authorization

Use that package for repeatable fields.

Have fun :)

Shirshak left a reply on How To Deploy Nova In Shared Hosting

check php error log.

21 Oct
2 months ago

Shirshak left a reply on Will Node.js Replace PHP & Laravel?

I think rust will be future :) I have started to like it so much :)

18 Oct
2 months ago

Shirshak left a reply on Laravel Registering Package Route At Last?

Thanks :)

Correct solution was

Route::fallback(SpaController::class.'@index');

Shirshak started a new conversation Laravel Registering Package Route At Last?

How do i register a route after all other routes etc from various packages are registered?

I want to register this route

Route::get('/{any}', SpaController::class.'@index')->where('any', '.*');

Problem: I want it to be registered via package due to modular system.

So if i register it it will catch many routes like Laravel nova routes, Log Viewer routes so regex solution is really inefficeint

Is there any hook that run after all package has been registered?

24 Sep
3 months ago

Shirshak left a reply on Is Asset Loading In Nova Inefficient?

@Cronix i mean suppose you made a nova tool say "Medialibrary' and you required Vue as dependency. Then at final compiled file you will get Vue library in compiled file isn't it? let say his final compiled file is medialibrary.js . So medialibrary.js will have vue embedded in it.

And another developer made say "Colorpicker" then he will again require vue file as a dependencies and compile it . And his compiled file will again have vue. Let say his final output file is colorpicker.js

As a end user if i require both plugin "Medialibrary" and "Colorpicker". And the html source will have such output


                                <script src="/nova-api/scripts/media"></script> 
                <script src="/nova-api/scripts/colorpicker"></script>   

So both media and colorpicker are independed to each other. They both used vue file while compiling. Yes I know if they are compiled at same time node would have used only one time and webpack treesaking etc would have optimized it . But they are being run at different time and is being required at different time.

Meaning didn't we loaded vue two time .

THank you .

23 Sep
3 months ago

Shirshak started a new conversation Is Asset Loading In Nova Inefficient?

As much I know I can create tools,cards etc. But I think every such nova package has package.json folder. And there is vue as requirement . So while compiling it creates dist folder with compiled files. As those files are loaded on frontend.

Let say I required 15 nova packages. Each package has one vue and other common things. Considering Vue is 58 K are we loading 15* 58K for 15 packages.

Or I am wrong?

10 Sep
4 months ago

Shirshak left a reply on [Laravel Nova] Why Do Laravel Nova Use MapWithKeys Inside Validation?

@Cronix abit explanation please

dd((new static(static::newModel()))
        ->updateFields($request)
        ->mapWithKeys(function ($field) use ($request) {
            return $field->getUpdateRules($request);
        }),
        (new static(static::newModel()))
                    ->updateFields($request)
                    ->mapWithKeys(function ($field) use ($request) {
                        return $field->getUpdateRules($request);
                    })
        );

both seems to give same so what is it building ?

FieldCollection {#647
  #items: array:11 [
    "name" => array:2 [
      0 => "required"
      1 => "max:255"
    ]
    "username" => array:2 [
      0 => "unique:users,username,{{resourceId}}"
      1 => "max:100"
    ]
    "status" => []
    "email" => array:4 [
      0 => "required"
      1 => "email"
      2 => "max:255"
      3 => "unique:users,email,{{resourceId}}"
    ]
    "password" => array:3 [
      0 => "nullable"
      1 => "string"
      2 => "min:6"
    ]
    "created_at" => []
    "email_verified_at" => []
    "updated_at" => []
    "deleted_at" => []
    "last_access_at" => []
    "timezone" => []
  ]
}
FieldCollection {#688
  #items: array:11 [
    "name" => array:2 [
      0 => "required"
      1 => "max:255"
    ]
    "username" => array:2 [
      0 => "unique:users,username,{{resourceId}}"
      1 => "max:100"
    ]
    "status" => []
    "email" => array:4 [
      0 => "required"
      1 => "email"
      2 => "max:255"
      3 => "unique:users,email,{{resourceId}}"
    ]
    "password" => array:3 [
      0 => "nullable"
      1 => "string"
      2 => "min:6"
    ]
    "created_at" => []
    "email_verified_at" => []
    "updated_at" => []
    "deleted_at" => []
    "last_access_at" => []
    "timezone" => []
  ]
}

Shirshak started a new conversation [Laravel Nova] Why Do Laravel Nova Use MapWithKeys Inside Validation?

In this code

return static::formatRules($request, (new static(static::newModel()))
                    ->availableFields($request)
                    ->mapWithKeys(function ($field) use ($request) {
                        return $field->getUpdateRules($request);
                    })->all());

I don't get it why there is mapWithKeys() etc . You can also check at PerformsValidation.php file. I tried dd couple of time and see no effect of using mapWithKeys(). I

11 Jun
7 months ago

Shirshak left a reply on [Laravel Scout] Laravel Global Search Using Scout?

@rin4ik it assumes for single model bro? Any chance for multiple model?

Shirshak started a new conversation [Laravel Scout] Laravel Global Search Using Scout?

Suppose I have model like

Book Journal User

All of them have Scout Searchable Interface and have accessor for getting link and all of them have title and description

So for any three model we can do

$entity->title $entity->description $entity->show_link

But the problem is suppose I have a big search box in index page and user may search for title like "Karl Marx Communism" I am doing it like this

$book= Book::search(request()->get('q')); $journal = Journal::search(request()->get('q')); $user = User::search(request()->get('q'));

But problem is suppose journal have that title and book has that title in description However title of book needs to be prioritize instead of Book description. Is there any simple solution to such problem?

Priority should be

Title From any model Description from any model.

The problem is basically having global search across multiple model

02 Jun
7 months ago

Shirshak left a reply on Some Event Naming Convention.

Second list of convention sounds better .

Shirshak left a reply on Some Event Naming Convention.

Thank you :)

Shirshak started a new conversation Some Event Naming Convention.

Suppose there is a post model. I like the Jeffrey's way convention of using past tense. So for created I use convention of naming creating events like this:

PostWasCreated

But this event will fired after model has been successfully been created. So we need different event while the model is being created so we can intercept and change various data or stop creation of post. So what is naming convention for those situation like PostWasCreating which sounds a bit odd or PostIsCreating which seems like not in convention as its not in past tense.

Would it be alright if you share your naming convention thanks.

Thanks.

01 Jun
7 months ago

Shirshak started a new conversation Composer Local Package Inside Local Package

Suppose I want to have packages like this:

College/ (yahoo/college)
-composer.json
-src
----ClassA/ (yahoo/classa)
----ClassB/ (yahoo/classb)
----ClassC/ (yahoo/classc)

College is package which is made of packages like class A, class B, class C. So college package is just used for loading service providers of class A, class B and class C and other thing that happens in Laravel.

In main package I added repository to college and required yahoo/ college. And inside college's composer.json I added repository for class A ,class B and class C but the thing is from main folder when i do composer update it says classA, classB and classC are not found.

Here is composer.json of college package (just to show how classa is added at college composer.json file)

{
  "name": "yahoo/college",
  "type": "library",
  "authors": [
    {
      "name": "Shirshak",
      "email": "[email protected]"
    }
  ],
  "repositories":[
    {
      "type":"path",
      "url":"src/classa",
      "options":{
        "symlink":true
      }
    }
  ],
  "require":{
    "yahoo/classa": "@dev"
  },
28 May
7 months ago

Shirshak left a reply on Best Way To Load Seeds And Routes From A Package?

He may want to run seed with one command php artisan db:seed . But the problem with laravel is how can it determine order of seed file. I guess this is only reason why laravel don't provide ability to register seed

22 May
7 months ago

Shirshak started a new conversation Referencing Root Folder In Vue Files At Laravel

I have a Vue files for another modules at laravel/packages/shirshak/books/views/routes

But I need to references them from laravel/resources/js/backend/router/index.js (normal in laravel) .

Inside that index.js I need to import that books routes? How can i do that .

I guess there is better solution than this one

import BookRoutes from ../../../../packages/shirshak/books/views/routes

Is there any better solution than this.

In Vue Cli we can use @ to reference source folder ? How can i get for laravel projects

Thanks

15 May
8 months ago

Shirshak left a reply on CI Testing To Includepersonal Package?

@CJJ its a local package bro. And I encapsulated so that it can be maintained . Currently there are 4 packages like this. The problem is its abit tedious to make new repository commit it there etc.. ?

Its installed using composer repository so its not in vendor folder.

Shirshak started a new conversation CI Testing To Includepersonal Package?

I have a package folder at root level of Laravel Project. Inside project there is folder called blog. So basically its a blog package.

But I have test inside that blog package also.

So How do I trigger test when i run phpunit. Currently it trigger test which is inside Laravel/tests folder. I know I can add that Laravel/package/blog/tests folder but is there any recommendation?

02 Apr
9 months ago

Shirshak left a reply on Select 2 Not Working After Adding Vue.

there is laravel mix in laravel which is wrapper at webpack. So from webpack.config.js you can reach to js file where you can find vue. Vue is probably at boostrap.js file

Shirshak left a reply on Select 2 Not Working After Adding Vue.

check in assets/javascript there are plenty of vue files etc.. Its best if you can refer to webpack.config.js in root folder?

17 Mar
9 months ago

Shirshak left a reply on Same Type Of Route Skip If No Model Found?

@maslauskast i agree but its not flexible.

Shirshak left a reply on Same Type Of Route Skip If No Model Found?

@Sanctuary Yes but even though it is hacky the only problem i find is Route cannot be cached as you used clousure. I guess i need to make separate controller for such task only right? I guess framework don't have ability to skip routes on conditions

Shirshak started a new conversation Same Type Of Route Skip If No Model Found?

Suppose my route looks like this

Route::get('/{page_slug}','[email protected]');
// and in controller there is implicit route binding

Route::get('/{username}','[email protected]');
// in controller there is implicity route binding

The problem is if pages don't exist it will immediately show 404 pages . Is there any simple way if there is no pages with page slug move to username and even if username is not found then skip to another.

Thanks

24 Jan
11 months ago

Shirshak left a reply on Anyway To Run Sudo Command And Getting Output?

@burlresearch i just want those text to be in some file and updated regularly like 10 second so i can show live updates in website.

Shirshak left a reply on Anyway To Run Sudo Command And Getting Output?

@burlresearch I guess you want to say run cron job on ubuntu right or there are other way?

Shirshak started a new conversation Anyway To Run Sudo Command And Getting Output?

In ubuntu I can get the networking traffic details via

$ sudo iftop -t -s 1 -L 10

which gives result like this

interface: eth0
IP address is: 192.168.150.2
MAC address is: c0:3f:d5:f6:cb:d3
Listening on eth0
   # Host name (port/service if enabled)            last 2s   last 10s   last 40s cumulative
--------------------------------------------------------------------------------------------
   1 192.168.203.115                          =>      128Kb      128Kb      128Kb     31.9KB
     13.107.4.50                              <=     10.0Mb     10.0Mb     10.0Mb     2.50MB
   2 192.168.205.7                            =>      163Kb      163Kb      163Kb     40.9KB
     202.166.193.140                          <=     8.08Mb     8.08Mb     8.08Mb     2.02MB
   3 192.168.204.103                          =>      342Kb      342Kb      342Kb     85.5KB
     64.15.121.18                             <=     6.38Mb     6.38Mb     6.38Mb     1.60MB
   4 192.168.204.17                           =>     81.0Kb     81.0Kb     81.0Kb     20.2KB
     13.107.4.50                              <=     5.07Mb     5.07Mb     5.07Mb     1.27MB
   5 192.168.205.86                           =>     78.7Kb     78.7Kb     78.7Kb     19.7KB
     13.107.4.50                              <=     5.06Mb     5.06Mb     5.06Mb     1.26MB
   6 192.168.203.83                           =>     55.2Kb     55.2Kb     55.2Kb     13.8KB
     64.71.142.229                            <=     3.36Mb     3.36Mb     3.36Mb      859KB
   7 192.168.205.23                           =>     52.5Kb     52.5Kb     52.5Kb     13.1KB
     139.5.69.13                              <=     3.05Mb     3.05Mb     3.05Mb      781KB
   8 192.168.203.87                           =>     58.0Kb     58.0Kb     58.0Kb     14.5KB
     139.5.70.14                              <=     2.62Mb     2.62Mb     2.62Mb      671KB
   9 192.168.204.224                          =>     74.1Kb     74.1Kb     74.1Kb     18.5KB
     202.166.193.145                          <=     2.23Mb     2.23Mb     2.23Mb      571KB
  10 192.168.204.16                           =>     47.5Kb     47.5Kb     47.5Kb     11.9KB
     139.5.70.13                              <=     1.90Mb     1.90Mb     1.90Mb      487KB
--------------------------------------------------------------------------------------------
Total send rate:                                     3.01Mb     3.01Mb     3.01Mb
Total receive rate:                                  67.7Mb     67.7Mb     67.7Mb
Total send and receive rate:                         70.7Mb     70.7Mb     70.7Mb
--------------------------------------------------------------------------------------------
Peak rate (sent/received/total):                     3.01Mb     67.7Mb     70.7Mb
Cumulative (sent/received/total):                     771KB     16.9MB     17.7MB
============================================================================================

But we know we used sudo there. I am working for page in university where i can show this result interactivly probably on charts. But I cannot get the output as it need sudo command .

I made command like this

$ php artisan university:internet 

Which in turn calls that sudo command

I know it will give permissions error? Any way or hack to make it possible?

Thanks

14 Jan
1 year ago

Shirshak left a reply on Select 2 Not Working After Adding Vue.

thanks for info :) Both correct so cannot decide :)

Shirshak left a reply on Select 2 Not Working After Adding Vue.

Both answers are correct . Thanks for info.

Just knew vue js was not giving any changes to jQuery.

13 Jan
1 year ago

Shirshak started a new conversation Select 2 Not Working After Adding Vue.

I have a form and in javascript i enable select 2 like this: jQuery('.categories').select2()

And it works fine. But when i add vue like this just after above code like this

                    el: '#premium_book_form_body',
                    data: {
                        copy_type: 'hard_copy'
                   }
                });

select 2 from another field stop working. I haven't done anything to those element. Is there something i am missing?

Shirshak left a reply on Laravel Valet Not Working On Public Folder Symlink

@bobbybouwmann Yes you were indeed correct . Never expected storage facade would use APP_URL env variable. I thought only dusk uses it :D

Shirshak left a reply on Laravel Valet Not Working On Public Folder Symlink

actually it was due to use of Storage::disk('public') facade. And it uses APP_URL from .env file pointing to localhost. So change APP_URL from .env file fixed it. Thanks everybody :)

12 Jan
1 year ago

Shirshak left a reply on Any Laravel 5.5 PDF?

@Dunsti it is updated but not daily :)

Shirshak started a new conversation Laravel Valet Not Working On Public Folder Symlink

I have already run php artisan storage:link And i event went to public/storage/image/hello.jpg but when i go via url like this

xyz.test/storage/image/hello.jpg laravel valet shows 404.

What am i doing wrong here? Any Ideas

Thanks

08 Jan
1 year ago

Shirshak left a reply on Data Doesn't Updated In User Table

try dd($request->all)etc . It may be due to mass assignment etc.

Shirshak left a reply on Laravel Doesn't Pass Request Object

have you used namespaces properly. Like you can write use statement at top or use backslash \ for root otherwise it will be relative.

Shirshak started a new conversation Any Laravel 5.5 PDF?

I found only laravel 5.2 pdf but we know laravel docs has been changed too much . So are there any laravel 5.2 pdf available.

I think we can make script for that which can fetch latest .md files from laravel/docs github repository if it is not available.

Thanks.

18 Jul
1 year ago

Shirshak left a reply on Is There Anyway To Know Which Which Query Runned While Inserting Through Eloquent?

@Cronix that will show only for select isn't it ? Will it show for insertion?

@jlrdw yes but it is for 1time insertion . Can we see such for inserting many times?

Shirshak started a new conversation Is There Anyway To Know Which Which Query Runned While Inserting Through Eloquent?

I want to analyse which queried did run after inserting into database . It would be better if it list all those queries. Is there any tools and technique.

I know about events but they works only for select * isn't it?

Shirshak left a reply on Laravel Multi Insertion And Its Relationship

@JeffreyWay Is there any clean laravel like solution such problems ? I digged into framework i think there is support for such task isn't it?

Shirshak left a reply on Laravel Multi Insertion And Its Relationship

No bro It clearly means n+1 query so i didn't use it .

I just can directly insert like this

Question::insert($question)

as $question is array of array of required data in question table

Shirshak left a reply on Laravel Multi Insertion And Its Relationship

@zLegend How would you get $question at first loop?

Shirshak started a new conversation Laravel Multi Insertion And Its Relationship

We know about Model::insert() But how about its associated relationship?

We know we can have 100 question after form submit but corresponding question have around 4 answer (For multiple choice questions)

Our question data look like this

$question = [
 '1' =>[
        'name'='Who is first president of America'?
        ...
    ]
    ...
 '100' =>
    'name' = 'When did Christopher Colombus discovered America'
    ....

    ...
]

$answers = [
    '1'=>
        [
            '1' => 'Wilston Churcil',
            '2' => 'George Washinton'
            ....
        ]
        ...
    ...
]

$correct_answer = [
    '1'=>['2']
    ...
]

Relationship

  • Question has many Answers
  • Question has many Correct Answers

We are trying to upload many questions at once

We can clearly see if we don't go for laravel create otherwise we will run n+1 problems and for 100 question we may probably need 100 + 400 + 100 queries which is extremely inefficient?

If Question::insert() has returned id of inserted question then it would be easy but it just return Boolean ..

Is there anyway to solve such issue without using n+1 problem.

I tried using n+1 and background job but it is really extremely slow :(

Any solution and hacks would be ok :(

06 Jun
1 year ago

Shirshak left a reply on Laracasts Premium Registration Not Workin?

yea it seems buggy tried 4-5 times and it is working don't know what is happening :(

Shirshak left a reply on Broken Link

@JeffreyWay There is no even a one tab which should be there

https://laracasts.com/@brayniverse