tisuchi

Sr. Software Engineer at Avana.asia

Member Since 4 Years Ago

Dhaka, Bangladesh

Experience Points
631,395
Total
Experience

0 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
1560
Lessons
Completed
Best Reply Awards
563
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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 50
631,395 XP
Jan
19
21 hours ago
Activity icon

Awarded Best Reply on Install Bootstrap In VueJS

@rhugvedadesai98

I have the same issue before.

Check these steps. I figure it out this way

http://laravel-school.com/snippet/how-to-add-bootstrap-in-vuejs-43

Activity icon

Replied to Install Bootstrap In VueJS

@rhugvedadesai98

I have the same issue before.

Check these steps. I figure it out this way

http://laravel-school.com/snippet/how-to-add-bootstrap-in-vuejs-43

Jan
18
1 day ago
Activity icon

Awarded Best Reply on Count() Not Working

@van-india

It's because bed is the property of your $list object.

If you want to use count(), then you need to use it on the $list object.

For example-

{{ $list->count() }}
Activity icon

Replied to Ajax Return Error 500 With Laravel 5.8

@ahmed_bondok2006

It's because you haven't passed two parameters in AllProductController constructor. You have to pass two parameters there since you defined two arguments in the constructor of your controller.

Activity icon

Replied to Count() Not Working

@van-india

It's because bed is the property of your $list object.

If you want to use count(), then you need to use it on the $list object.

For example-

{{ $list->count() }}
Activity icon

Replied to Laravel Strange 419 Behavior

@hsntngr

For your case, if it is only for a long time waiting issue, then check this discussion. I believe you will find the right solution there-

https://stackoverflow.com/questions/31449434/handling-expired-token-in-laravel

Activity icon

Replied to Laravel Strange 419 Behavior

@hsntngr

In that case, you have to make sure that in your post submission, you have set csrf token properly

For example-

<form action="/some/action" method="POST">
    @csrf

    ...
    

Check more: https://laravel.com/docs/6.x/csrf

Activity icon

Replied to How To Store And Show Image Fields With File Type, File Size, And With Dimensions?

@neeraj1005

Actually @tray2 suggested the link to make your life easier. The intervention is a well-known image manipulation package in PHP.

Of course, there are other way around where you need to do a lot. You can check it in the php documentation.

This is a sample function. There are more functions you can search for based on your requirements. https://www.php.net/manual/en/function.getimagesize.php

Activity icon

Replied to Laravel Strange 419 Behavior

@hsntngr

It seems it's the CSRF issue.

Have you set up the CSRF properly?

BTW, are you using ajax for the post request or Laravel form directly?

Activity icon

Replied to Factory - Use Attributes Of Recently Created Record

@brltdxd

There are many ways to figure it out. You can go with @tray2 solution.

Or you can simply try this-

...

'product_id' => $product = factory(Product::class),
'original_price' => $product->product_id,
...

Or you can call it on top of your return.

$factory->define(OrderProduct::class, function (Faker $faker) {
    $product = factory(Product::class);
    
    return [
        'order_id' => factory(Order::class),
        'product_id' => $product,
        'original_price' => $product->product_id, /* Must use the price generated from 'product_id' */
        'quantity' => $faker->randomDigitNotNull,
    ];
});

And of course, you may find some other way around, if you search more.

Activity icon

Awarded Best Reply on How To Create The Dockerfile?

@hnkorap88

No, Dockerfiles are single containers (services) by design as I know so far. Laradock provides a docker-compose file that references multiple dockerfiles. However, you could create a smaller docker-compose file that only starts the containers you need (let's say a webserver with php, a database server and redis).

Laradock ships with a way to many containers in docker-compose, that is why the tutorial tells you to specify which containers you want to run.

Check more: https://laradock.io/getting-started/

docker-compose up -d nginx mysql

But if you specify a minimal docker-compose.yml, you just can type

docker-compose up -d

without any additional arguments

Jan
17
2 days ago
Activity icon

Awarded Best Reply on Passing Variable From One Controller To The Another Controller

@snapkwi

The parameters sent with the redirect function are added to the query string of the generated url. So if you want to access them in the other controller's function, you have to get the value from the request object.

For example-

class ControllerTwo extends Controller
{
    public function index()
    {
        $SetNumber = request()->get('SetNumber');

        return view('pages.spotifyApi')->with('SetNumber', $SetNumber);
    }
}
Activity icon

Replied to Passing Variable From One Controller To The Another Controller

@snapkwi

The parameters sent with the redirect function are added to the query string of the generated url. So if you want to access them in the other controller's function, you have to get the value from the request object.

For example-

class ControllerTwo extends Controller
{
    public function index()
    {
        $SetNumber = request()->get('SetNumber');

        return view('pages.spotifyApi')->with('SetNumber', $SetNumber);
    }
}
Activity icon

Replied to Laravel 5.5 Controller

@timmypro

Can you show your CountryController?

Activity icon

Awarded Best Reply on Laravel Join With Multiple Tables

@brad_fresh99

I think your relations goes like this:

Stores -> (n*n)StoreProducts -> Products -> (n*1)Brands

which StoreProducts is a joining table between Stores and Products. With this assumption, I would use something like this:

In the Store model,

public function products(){
    return $this->belongsToMany(\App\Product::class, "store_products"); 
}

In the Products model,

public function stores(){
    return $this->belongsToMany(\App\Store::class, "store_products");
}

In the StoreProducts model,

public function store(){
    return $this->belongsTo(\App\Store::class);
}

public function product(){
    return $this->belongsTo(\App\Product::class);
}

This way the relationship is created. Then you can use something like this:

$stores = \App\Store::whereHas("products", function($q) use ($brandId){
    return $q->where("brand_id", $brandId);
});

This will give you the stores in which the brand exists.

Activity icon

Replied to How To Create The Dockerfile?

@hnkorap88

No, Dockerfiles are single containers (services) by design as I know so far. Laradock provides a docker-compose file that references multiple dockerfiles. However, you could create a smaller docker-compose file that only starts the containers you need (let's say a webserver with php, a database server and redis).

Laradock ships with a way to many containers in docker-compose, that is why the tutorial tells you to specify which containers you want to run.

Check more: https://laradock.io/getting-started/

docker-compose up -d nginx mysql

But if you specify a minimal docker-compose.yml, you just can type

docker-compose up -d

without any additional arguments

Activity icon

Replied to Laravel Join With Multiple Tables

@brad_fresh99

I think your relations goes like this:

Stores -> (n*n)StoreProducts -> Products -> (n*1)Brands

which StoreProducts is a joining table between Stores and Products. With this assumption, I would use something like this:

In the Store model,

public function products(){
    return $this->belongsToMany(\App\Product::class, "store_products"); 
}

In the Products model,

public function stores(){
    return $this->belongsToMany(\App\Store::class, "store_products");
}

In the StoreProducts model,

public function store(){
    return $this->belongsTo(\App\Store::class);
}

public function product(){
    return $this->belongsTo(\App\Product::class);
}

This way the relationship is created. Then you can use something like this:

$stores = \App\Store::whereHas("products", function($q) use ($brandId){
    return $q->where("brand_id", $brandId);
});

This will give you the stores in which the brand exists.

Activity icon

Replied to Is It Worth Using Passport Routes?

@chris1981

Again it depends on what kinds of api you want to build and which part exactly you want to protect via token.

If I get you correctly, just imagine that you want to create an API for a blog.

// Public routes
GET     /articles           
GET     /article/slug       

// Protected routes
GET     /article/create     - middleware: auth:api
POST    /article/store      - middleware: auth:api
GET     /article/update     - middleware: auth:api
PUT     /article/put        - middleware: auth:api
...
...

Here, for accessing the public routes, your clients doesn't need to have the access token.

Correct me if I am wrong.

Activity icon

Awarded Best Reply on Laravel Nova 404 Error

@alexgodbehere79

Have you renamed all the id columns to include the resource name, eg professions_id. I think it is required. Although make sure that you have changed that as described in the documentation.

It turns out that changing the column name is unnecessary, and actually creates this error. So leave them as id. Note that you can actually change column names, it's just that in this case (with Nova) it resulted in an error.

Activity icon

Replied to Factory - Use Attributes Of Recently Created Record

@brltdxd

You should have another factory for product, then you can easily do this way-

'original_price' => factory(Product::class)->create()->product_id

The full code will be like this-

$factory->define(OrderProduct::class, function (Faker $faker) {
    return [
        'order_id' => factory(Order::class),
        'product_id' => factory(Product::class),
        'original_price' => factory(Product::class)->create()->product_id, /* Must use the price generated from 'product_id' */
        'quantity' => $faker->randomDigitNotNull,
    ];
});
Activity icon

Replied to Laravel Nova 404 Error

@alexgodbehere79

Have you renamed all the id columns to include the resource name, eg professions_id. I think it is required. Although make sure that you have changed that as described in the documentation.

It turns out that changing the column name is unnecessary, and actually creates this error. So leave them as id. Note that you can actually change column names, it's just that in this case (with Nova) it resulted in an error.

Activity icon

Replied to Laravel Nova 404 Error

@alexgodbehere79

Do the laravel logs contain any errors?

Activity icon

Replied to Laravel Join With Multiple Tables

@brad_fresh99

Do you want the stores which contain a brand?

Activity icon

Awarded Best Reply on Laravel Update Method Is Not Working

@brad_fresh99

Try this:

{!! Form::model($post, ['action' => ['[email protected]', $post->id], 'method' => 'PUT']) !!}

If your route is a resource:

Route resource

Route::resource('post','PostController');

Form update

{!! Form::model($post, ['route' => ['post.update', $post->id], 'method' => 'PUT']) !!}
Activity icon

Replied to Sql Injection In Laravel

@beracah.kings

You better show your code here. SQL Injection always depends on the way you write your code.

Activity icon

Replied to Is It Worth Using Passport Routes?

@chris1981

Since API is stateless, so you have validated updates or creates data. In that case, I cannot think anything else except tokenization.

Now the question is do you want to generate your own token system or use the passport. Of course, I will prefer to use laravel passport in this scenario because it will reduce your workload and will give you an updated and competible code with the different versions of laravel all the time.

Activity icon

Awarded Best Reply on PHP Array_map() Help

@a4family

What if you try this?

$milestones = str_replace(array('[', ']', '"'),'',$milestones);

Since you try to remove square brackets and double-quotes.

Activity icon

Awarded Best Reply on How To Get Total Files From A Directory?

@myszon

Could you try adding in your config/filesystems.php file a user_images key:

'user_images' => [
    'driver' => 'local',
    'root'   => public_path() . '/storage/',
],

After that, try in your code to access via useR_images by doing below:

Storage::allFiles('user_images');

Check more: https://laravel.com/docs/5.0/filesystem#basic-usage

Activity icon

Awarded Best Reply on Laravel Remove Offset From The Query

@girliosalama95

Anyways, you can reset the $limit property:

$query = TestModel::where('a', 'b')->limit(100);
$query->limit = null;
$unlimited = $query->get();
Activity icon

Awarded Best Reply on How To Increase Search Filed Width?

@bilalarshad21

You need to add css inside css/jquery.dataTables.css file:

.dataTables_filter input {
    width: 450px !important; 
}
Activity icon

Replied to Laravel Remove Offset From The Query

@girliosalama95

Anyways, you can reset the $limit property:

$query = TestModel::where('a', 'b')->limit(100);
$query->limit = null;
$unlimited = $query->get();
Activity icon

Replied to How To Get Total Files From A Directory?

@myszon

Could you try adding in your config/filesystems.php file a user_images key:

'user_images' => [
    'driver' => 'local',
    'root'   => public_path() . '/storage/',
],

After that, try in your code to access via useR_images by doing below:

Storage::allFiles('user_images');

Check more: https://laravel.com/docs/5.0/filesystem#basic-usage

Activity icon

Replied to How To Increase Search Filed Width?

@bilalarshad21

You need to add css inside css/jquery.dataTables.css file:

.dataTables_filter input {
    width: 450px !important; 
}
Activity icon

Replied to Laravel Remove Offset From The Query

@girliosalama95

I am wondering why are you using limits at first?

Activity icon

Awarded Best Reply on Laravel Join Multiple Tables

@sonukumar99

Yes you can query for model A and eager load the rest of the models:

$modelA->with(['modelB.modelD', 'modelC'])->get();

To make sure it works you need a relationship on model A for model B and model C, and a relationship on model B for model D.

Activity icon

Replied to POST Route

@antoine_herbert

You might be following some unnecessary steps, to be honest. I am not sure what exactly is your business logic, but you may reduce some steps.

Calling the api endpoint directly is more meaningful to me, isn't that?

That's why I suggest you check the link. You may google it, you will find more tutorials about it. Check whichever you like.

Activity icon

Replied to Correct Query

@afoysal

I personally also tell you to follow @snapey 's verbose approach that is more organized and meaning.

Activity icon

Replied to POST Route

@antoine_herbert

There are some issues in your code. Especially the way you defined your form action, that is not the correct way. Normally the laravel api is prefixed by api/ that you have missed in your action.

So, I recommend you to check this entry-level tutorial to understand how to use laravel and vue JS together.

https://www.itsolutionstuff.com/post/laravel-vue-js-axios-post-request-example-and-demoexample.html

Activity icon

Awarded Best Reply on Laravel SortBy() Condition Is Not Working

@sukhchainsingh88

What if you try simply this?

...
->orderBy(DB::raw('CASE WHEN ...'))
...
Activity icon

Awarded Best Reply on Laravel Localised With VueJS

@michaelritung89

Try useing vue-i18n:

$ npm install vue-i18n

Add it to you Vue app:

import Vue from 'vue'
import App from './App'
import router from './router'
import VueI18n from 'vue-i18n'
Vue.use(VueI18n)

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  template: '<App/>',
  components: { App }
})

Check more: https://kazupon.github.io/vue-i18n/

Activity icon

Awarded Best Reply on Laravel Store Is Not Working

@rargyx

I think It is the problem of the name. Add name="bank_name" in select attribute and try:

               <div class="form-group mb-2">
                    <select class="form-control" name="bank_name">
                        <option value="" selected disabled>Select Bank</option>
                        <option value="bank1">BANK1</option>
                        <option value="bank2">BANK2</option>
                        <option value="bank3">BANK3</option>
                        <option value="bank4">BANK4</option>
                        <option value="bank5">BANK5</option>
                    </select>
                </div>
Jan
16
3 days ago
Activity icon

Awarded Best Reply on Laravel Get Parent Data In Relationship

@su3158y

You should use whereHas instead of with to check child existence.

$customers = Customer::whereHas('items', function($query){
    return $query->where('status', 2);
})->get();

dd($customers);

I assume you already defined the proper relationship between Customer and Item.

Activity icon

Replied to Laravel Localised With VueJS

@michaelritung89

Try useing vue-i18n:

$ npm install vue-i18n

Add it to you Vue app:

import Vue from 'vue'
import App from './App'
import router from './router'
import VueI18n from 'vue-i18n'
Vue.use(VueI18n)

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  template: '<App/>',
  components: { App }
})

Check more: https://kazupon.github.io/vue-i18n/

Activity icon

Replied to Laravel SortBy() Condition Is Not Working

@sukhchainsingh88

What if you try simply this?

...
->orderBy(DB::raw('CASE WHEN ...'))
...
Activity icon

Replied to Laravel Store Is Not Working

@rargyx

I think It is the problem of the name. Add name="bank_name" in select attribute and try:

               <div class="form-group mb-2">
                    <select class="form-control" name="bank_name">
                        <option value="" selected disabled>Select Bank</option>
                        <option value="bank1">BANK1</option>
                        <option value="bank2">BANK2</option>
                        <option value="bank3">BANK3</option>
                        <option value="bank4">BANK4</option>
                        <option value="bank5">BANK5</option>
                    </select>
                </div>
Activity icon

Awarded Best Reply on Laravel Asset() Is Not Showing The File Properly

@sukhchainsingh88

Try asset('public/js/app.js'), and find a way to serve your site from the public, not from root.

asset('public/js/app.js')
Activity icon

Replied to Laravel Get Parent Data In Relationship

@su3158y

You should use whereHas instead of with to check child existence.

$customers = Customer::whereHas('items', function($query){
    return $query->where('status', 2);
})->get();

dd($customers);

I assume you already defined the proper relationship between Customer and Item.

Activity icon

Replied to Laravel Join Multiple Tables

@sonukumar99

Yes you can query for model A and eager load the rest of the models:

$modelA->with(['modelB.modelD', 'modelC'])->get();

To make sure it works you need a relationship on model A for model B and model C, and a relationship on model B for model D.

Activity icon

Replied to PHP Array_map() Help

@a4family

What if you try this?

$milestones = str_replace(array('[', ']', '"'),'',$milestones);

Since you try to remove square brackets and double-quotes.