sujancse

Software Engineer at Portonics Limited

Member Since 3 Years Ago

Dhaka, Bangladesh

Experience Points
36,900
Total
Experience

3,100 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
144
Lessons
Completed
Best Reply Awards
32
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 8
36,900 XP
Feb
19
1 week ago
Activity icon

Replied to Eloquent Model Not Returning Any Data From Table Having Multiple Indexes.

It's so much possible that your query (conditions/logic) is not matching any record @pdm1991

Activity icon

Replied to No Such Table

Did you ran migration @jgravois ?

Jan
23
1 month ago
Activity icon

Replied to Count Number Of Rows

Of course, you can use limit https://laravel.com/docs/6.x/queries#ordering-grouping-limit-and-offset

$limit = 10;
$users = User::where('name', 'like', '%'.$request->name.'%')->limit($limit)->get();
Jan
16
1 month ago
Activity icon

Replied to Add Values On Two Arrays

@duckz_1209 for substruction you can use

$array1 = [100,100,100];

$array2 = [50,100,25];

$subtracted = array_map(function ($x, $y) { return $x - $y; } , $array1, $array2);

And for addition

$array1 = [100,100,100];

$array2 = [50,100,25];

$added = array_map(function ($x, $y) { return $x + $y; } , $array1, $array2);

If values a numeric.

Activity icon

Replied to Add Values On Two Arrays

@duckz_1209

$array1 = [100,100,100];

$array2 = [50,100,25];

$array_new = array_merge(array_diff($array1, $array2), array_diff($array2, $array1));

https://stackoverflow.com/questions/3507419/getting-unique-values-from-2-arrays

Activity icon

Replied to SQLSTATE[HY000]: General Error

@aeonfox don't you have an auto increment column on your migration?

Jan
14
1 month ago
Activity icon

Replied to I Changed Update

it should be

public function update(Request $request, Product $product)
{
    $data = [
        'title' => $request->title,
        'body' => $request->body,
        'user_id' => auth()->id(),
        'price' => $request->price
    ];
    
    if($request->has('image')) {
        $image = $request->file('image');
        $filename = time().$image->getClientOriginalName(); // best practice is to use time() function for unique name
        $image->move(public_path('images/products'), $filename);
        // $productImage = $request->file('image')->getClientOriginalName(); // no need of this lline
        
        $data['image'] = $filename;
    }

    $product->save($data);
}

As the the Product should be an existing one

Jan
07
1 month ago
Activity icon

Replied to Submit Doesn't Work

@theldess format your html code, you will have the answer

Jan
02
1 month ago
Activity icon

Replied to Condition In Select Eloquent Relation

@fareedr format the date like

$date = Carbon::today()->format('Y-m-d');

As you are using whereDate it's expecting date as string like 2020-01-02

Activity icon

Replied to How To Display Sum() Data In View File

@armancs You can use collection helper sum() https://laravel.com/docs/6.x/collections#method-sum like

$totalamountdaily = Invoices::where('user_id', auth()->user()->id)->whereDate('created_at', Carbon::today())->get()->sum('total_amount');
Jan
01
1 month ago
Activity icon

Replied to Profile View Doesn't Load Images

@branimir_11 as @jlrdw said laravel has a powerful helper method asset() for handling assets. https://laravel.com/docs/6.x/helpers#method-asset

The asset function generates a URL for an asset using the current scheme of the request (HTTP or HTTPS):

Activity icon

Replied to Laravel Read Image From Public Folder

@rully https://laravel.com/docs/6.x/helpers#method-asset

{{ asset("thumbnail/$blog->IMAGE") }} // double qoute used

or

{{ asset('thumbnail').'/'.$blog->IMAGE) }}
Dec
31
1 month ago
Activity icon

Replied to RedirectTo Login

First of all you have to override default registration system to prevent login on register.

This article https://laracasts.com/discuss/channels/laravel/laravel-verification-without-email?page=1#reply=564876 can help you @mehmetanbaki

Activity icon

Replied to How To Get Class Attribute In Layout?

What are you trying to do actually @dicanio?

Activity icon

Replied to Login Issue

What did you get @mehmetanbaki?

Activity icon

Replied to How To Add Background-image Css Property In Laravel 6?

@ishtiak122 Just use the asset helper like

background-image: url({{ asset('images/myimage.jpg') }});
Activity icon

Replied to Vuejs Course - Having Issues With Axios.post

@iskamwebsite so on your very first load of your page errors object is null and it's still trying to access errors.get('name') on v-text. So you have to do like

<span class="help is-danger" v-text="errors ? errors.get('name') : ' ' "></span>
Activity icon

Awarded Best Reply on How Does Laravel Differentiate Url

Because your route has wild card here Route::get('people/{person_id}','[email protected]');

Route::get('people/{person_id}','[email protected]'); // here
Route::get('people/search','[email protected]')->name('search');

it's getting hit whatever you type after people/...... It is not related to the named route but route order.

Activity icon

Replied to How Does Laravel Differentiate Url

Because your route has wild card here Route::get('people/{person_id}','[email protected]');

Route::get('people/{person_id}','[email protected]'); // here
Route::get('people/search','[email protected]')->name('search');

it's getting hit whatever you type after people/...... It is not related to the named route but route order.

Activity icon

Replied to Error When Changing Controller Functions

Did your code work before change @pain12 ?

Activity icon

Replied to Route Not Working For Package Controller With Auth Middleware

Then try clearing your route-cache like php artisan route:clear

Activity icon

Replied to JavaScript Function In Foreach

@kingsleyo you need a dynamic class name here like

{% for ad in ads %}
...
    <a class="btn"  onclick="showNumber({{ad.user.id}})" class="showNumber{{ad.user.id}}"><span class="fa fa-phone"></span> View Phone Number</a>

    <input class="phonenum" style="display: none;" type="text" value="{{ ad.user.phone }}">
...
{% endfor %}

and

<script type="text/javascript">
  function showNumber(id) {
    var phone = $('.phonenum' + id).val();
    $('.showNumber' + id).html(phone);
   // e.target.innerHTML = e.target.parent.querySelector('.phonenum').value;
  }
</script>

And then access by dynamic class

Activity icon

Replied to Route Not Working For Package Controller With Auth Middleware

@slimdeluxe you are not properly logged in. Please check your authentication.

Dec
30
1 month ago
Activity icon

Replied to How To Remove Non Useful Spaces For Search Input

@mostafalaravel try window.location.href = "?q="+this.searchKey.replace(/\s\s+/g,' '); Instead of window.location.href = "?q="+this.searchKey.replace(/\s/g,'');

https://stackoverflow.com/questions/1981349/regex-to-replace-multiple-spaces-with-a-single-space

Dec
21
2 months ago
Activity icon

Replied to Get Parameter From Url In Laravel

Use request()->input(‘to’); request()->input(‘from’);

Activity icon

Replied to How To Get Unique Items From $result_description But Pagination?

Why not do like

$Candidate =Candidate::where('description','LIKE', "%{$keyword}%")
            ->orWhereHas('industry', function ($q)use ($keyword) {
                $q->where('name','LIKE', "%{$keyword}%"); // or email <> ''
                $q->orWhere('email', $keyword); // newly added
            })
            ->orWhereHas('experiences', function ($q)use ($keyword) {
                $q->where('job_title','LIKE', "%{$keyword}%"); // or email <> ''
                $q->orWhere('email', $keyword);  // newly added
            })
            ->paginate(10);

you will have your results filtered by name as well as email

Activity icon

Replied to Conditions On Nested Relationships

Try

$records = Area::where('project_id', $projectId)
            ->with(['vaccinations'   => function ($query) use ($fromDate, $toDate) {
                if ($fromDate != '' && $toDate != '') {
                    $query->whereRaw('created_at BETWEEN ? AND ?', [$fromDate, $toDate]);
                }
            }])
            ->has('vaccinations.animal', function ($query) use ($uniqueId, $rfid) {
                if ($uniqueId != '') {
                    $query->where('unique_id', 'LIKE', '%' . $uniqueId . '%');
                }
                if ($rfid != '') {
                    $query->where('rf_id', 'LIKE', '%' . $rfid . '%');
                }
            })
            ->get();

Now vaccinations will be retrieved if at least one animal is present, please checkout the docs https://laravel.com/docs/6.x/eloquent-relationships#querying-relationship-existence

Dec
19
2 months ago
Activity icon

Replied to Updating Email Field

Can you show us your insertion code and model @bromira?

Activity icon

Awarded Best Reply on How To Get Average Rating Value?

Average rating value of what? @hnkorap88, you are just sharing your model.

Activity icon

Replied to How To Pass Populated Data To Include View?

Then you won't be able to check for selected option. I think that's not good practice @drewlim7

Activity icon

Replied to Route Parameter Validation

First of all, you don't want the logic in controller, second middleware is like a shield and $request is available there. As you are preventing the hit from hitting the controller middleware is the only place left for you. Where you can check your logic and redirect the user. If middleware is like a shield then why do you think it's not suitable @singhwithlaravel?

Activity icon

Replied to How To Get Average Rating Value?

Average rating value of what? @hnkorap88, you are just sharing your model.

Activity icon

Replied to How To Pass Populated Data To Include View?

Now try this @drewlim7

<select id="country" name="country" {{$class ? "class=$class" : ""}} required>
        <option value=""> Select a country </option>

        @foreach($selected_location as $location)
            <option value="{{ $location }}" {{ old('country') == $location ? 'selected' : '' }}>{{ $location }}</option>
        @endforeach

    </select>
Activity icon

Awarded Best Reply on Trying To Get Property 'multiple_doc' Of Non-object

At first the name multipledocs in

public function multipledocs()
    {
        return $this->belongsTo('App\Document','doc_id');
    }

should be multipledoc as it belogs to Document

Second: You have to eager load multipledoc like $doc = Document::with('multipledoc')->where('user_id','=',$id)->first();

My suggestion please go through https://laravel.com/docs/6.x/eloquent-relationships#one-to-many this docs

Activity icon

Replied to How To Pass Populated Data To Include View?

@drewlim7 you are echoing using {{ }} in $campaignDetail->target_location here like

@include('partials.all-countries',['class' => "form-control",'selected_location' => "{{$campaignDetail->target_location}}"])

The quotes " and {{ }} are not needed here use

@include('partials.all-countries',['class' => "form-control",'selected_location' =>$campaignDetail->target_location])

Instead of

@include('partials.all-countries',['class' => "form-control",'selected_location' => "{{$campaignDetail->target_location}}"])
Activity icon

Replied to Lumen Data Validation Fails

I am asking for table column name is it id or user_id on myuser_table @ben_01 ?

Activity icon

Replied to Trying To Get Property 'multiple_doc' Of Non-object

At first the name multipledocs in

public function multipledocs()
    {
        return $this->belongsTo('App\Document','doc_id');
    }

should be multipledoc as it belogs to Document

Second: You have to eager load multipledoc like $doc = Document::with('multipledoc')->where('user_id','=',$id)->first();

My suggestion please go through https://laravel.com/docs/6.x/eloquent-relationships#one-to-many this docs

Activity icon

Replied to Lumen Data Validation Fails

So here you are checking user_id against myuser_table's id, Is it id or user_id in your myuser_table @ben_01?

Activity icon

Replied to How To Pass Populated Data To Include View?

@drewlim7 remove {{ from your include like

@include('partials.all-countries',['class' => "form-control",'selected_location' =>$campaignDetail->target_location])

This is what making echo="" e