Shirshak

Experience

9,210

0 Best Reply Awards

  • Member Since 2 Years Ago
  • 82 Lessons Completed
  • 0 Favorites

11th June, 2018

Shirshak left a reply on [Laravel Scout] Laravel Global Search Using Scout? • 1 month ago

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

Shirshak started a new conversation [Laravel Scout] Laravel Global Search Using Scout? • 1 month ago

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

2nd June, 2018

Shirshak left a reply on Some Event Naming Convention. • 1 month ago

Second list of convention sounds better .

Shirshak left a reply on Some Event Naming Convention. • 1 month ago

Thank you :)

Shirshak started a new conversation Some Event Naming Convention. • 1 month ago

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.

1st June, 2018

Shirshak started a new conversation Composer Local Package Inside Local Package • 1 month ago

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"
  },

28th May, 2018

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

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

22nd May, 2018

Shirshak started a new conversation Referencing Root Folder In Vue Files At Laravel • 2 months ago

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

15th May, 2018

Shirshak left a reply on CI Testing To Includepersonal Package? • 2 months ago

@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? • 2 months ago

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?

2nd April, 2018

Shirshak left a reply on Select 2 Not Working After Adding Vue. • 3 months ago

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. • 3 months ago

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

17th March, 2018

Shirshak left a reply on Same Type Of Route Skip If No Model Found? • 4 months ago

@maslauskast i agree but its not flexible.

Shirshak left a reply on Same Type Of Route Skip If No Model Found? • 4 months ago

@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? • 4 months ago

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

24th January, 2018

Shirshak left a reply on Anyway To Run Sudo Command And Getting Output? • 5 months ago

@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? • 5 months ago

@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? • 5 months ago

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

14th January, 2018

Shirshak left a reply on Select 2 Not Working After Adding Vue. • 6 months ago

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

Shirshak left a reply on Select 2 Not Working After Adding Vue. • 6 months ago

Both answers are correct . Thanks for info.

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

13th January, 2018

Shirshak started a new conversation Select 2 Not Working After Adding Vue. • 6 months ago

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 • 6 months ago

@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 • 6 months ago

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 :)

12th January, 2018

Shirshak left a reply on Any Laravel 5.5 PDF? • 6 months ago

@Dunsti it is updated but not daily :)

Shirshak started a new conversation Laravel Valet Not Working On Public Folder Symlink • 6 months ago

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

8th January, 2018

Shirshak left a reply on Data Doesn't Updated In User Table • 6 months ago

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

Shirshak left a reply on Laravel Doesn't Pass Request Object • 6 months ago

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? • 6 months ago

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.

18th July, 2017

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

@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? • 1 year ago

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 • 1 year ago

@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 • 1 year ago

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 • 1 year ago

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

Shirshak started a new conversation Laravel Multi Insertion And Its Relationship • 1 year ago

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 :(

6th June, 2017

Shirshak left a reply on Laracasts Premium Registration Not Workin? • 1 year ago

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 • 1 year ago

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

https://laracasts.com/@brayniverse

Shirshak left a reply on Broken Link • 1 year ago

@Jeffrey Way Yes this is bug in site. I tried to open that link in computer all link points to google.

What is happening without beautiful laracasts ?

Shirshak started a new conversation Laracasts Premium Registration Not Workin? • 1 year ago

I have exactly 9$ and i deposited it today. But it says um no you don't have insufficeint balance??

Do you need to pay for taxes like that also? confused :(

19th September, 2016

Shirshak left a reply on Why Laravel Not Returning Eloquent Model Data As Integer But Returns String? • 1 year ago

@Thijmen Yes it works. And i have encountered several problem with other field like category id etc.. should i use $casts variable on all of them?

Shirshak left a reply on Why Laravel Not Returning Eloquent Model Data As Integer But Returns String? • 1 year ago

@Thijmen Is it only in laravel 5.3 ? I think this used to work in laravel 5.2?

Shirshak started a new conversation Why Laravel Not Returning Eloquent Model Data As Integer But Returns String? • 1 year ago

I am new to laravel. And i have database migration User which looks like this:

     $table->increments('id');
  $table->increments('id');
        $table->string('name');
        $table->string('email')->unique();
        $table->string('password');
        $table->integer('is_admin')->unsigned()->default(0);

I created a admin middleware with the help of is_admin (above)

inside admin midleware it looks like this

if (Auth::user()->is_admin !== 1) { return redirect('home'); }

As it was always returning false I used dd() function

When I used dd() functionI was surprised :( dd(Auth::user()->id) returns 1 which is integer dd(Auth::user()->is_admin) returns "1 " which is string

So my if condition is failing .

I wonder why it is returning string when my database schema have already specified is_admin is integer?

27th March, 2016

Shirshak left a reply on Anyway Of Generating Bulk Controller In L5.2? • 2 years ago

@mehany Thanks :) I think this should be integrated inside box at least :)

Shirshak started a new conversation Anyway Of Generating Bulk Controller In L5.2? • 2 years ago

I have around 30 routes in laravel ? But you know to create controller from 30 routes is very difficult at least for me?

Is there no way to generate controller by just giving routes so that i should not manually type php artisan make:controller ArticleController etc??

Thanks

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.