FareedR

FareedR

Member Since 1 Year Ago

Experience Points
10,640
Total
Experience

4,360 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
23
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 3
10,640 XP
Apr
08
1 day ago
Activity icon

Replied to Using GroupBy On WhereColumn()

i tried this before but error occured " SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'stocks.stocks.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by (SQL: select * from stocks where profit > loss and stocks.deleted_at is null group by signal order by profit desc) " . is it best practices to change the strict status on mysql ?

Activity icon

Started a new Conversation Using GroupBy On WhereColumn()

how can i groupBy using whereColumn() ?

$profit_stocks = Stock::where(function($q){
	$q->whereColumn('profit','>','loss')->orderBy('profit','desc');
})->groupBy('signal')->get();

// database
id | profit | loss | signal |
1	4		2	ABC
2	4		3	ABC
// expected result 
ABC
Activity icon

Replied to In_array Key And List Of Data

my mistake on frontend . it solved now

Apr
07
2 days ago
Activity icon

Started a new Conversation In_array Key And List Of Data

so i got a form that need to tick (checkbox). and the tick(checkbox) is an array . am i missing somewhere ?

$is_contradicts    = $request->has('contradict');
$contradicts = [];

if($is_contradicts){
	$contradicts = $request->get('contradict');
}

foreach ($time_frames as $key => $time_frame){
	$analysis = new Analysis([
		'stock_id'      => $stock->id,
                'time_frame'    => $time_frame,
                'description'   => $descriptions[$key],
                'is_contradict' => in_array($key,$contradicts) ? 1 : 0
	]);
	$analysis->save();
}
//example contradicts
0 => '1'

dd(in_array($key,$contradicts); // false -- supposedly true right ??

//result
// db analyses
stock_id | time_frame | description | is_contradict
1			10			Week		0

// expected result
// db analyses
stock_id | time_frame | description | is_contradict
1			10			Week		1

Apr
01
1 week ago
Activity icon

Replied to How To Not Loop The Same Data In Foreach ?

actually the selection is for searching . and i already solved it by using this method ..

 $dates = $stocks->unique(function($item){
return Carbon::parse($item['created_at'])->format('Y-m-d');
});
Activity icon

Replied to How To Not Loop The Same Data In Foreach ?

actually created_at is timestamps . so it got date and time . how can i use unique method , wihout time ?

Activity icon

Started a new Conversation How To Not Loop The Same Data In Foreach ?

Currently I need to display selection of created_at for searching . How can I loop only ONE date . For an example

//db

id | title |created_at | 
1	A	2020-02-3
2	B	2020-02-3
3     	C	2020-02-3
4      D	2020-02-4

//current result
2020-02-3
2020-02-3
2020-02-3
2020-02-4

//expected result
2020-02-3
2020-02-4
Mar
19
3 weeks ago
Activity icon

Started a new Conversation Calculation On Data Array

How can I calculate total amount ?

$service_fee = 4
// deals
id | price | qty | 
1      100       1
2      100       1

        foreach($deals as $deal){
            $subTotal           = $deal->price*$deal->qty;
            $serviceCharge      = (100-$service_fee)/100;
            $seller_total_earn  = $subTotal*$serviceCharge;
        }
Mar
18
3 weeks ago
Activity icon

Started a new Conversation Error On Spatie/Browsershot

I already put puppeteer on global. But I still get this error . I google it still no luck . " No such file or directory ". The long error said "Exit Code: 1(General error)↵↵Working directory: MyPC/project/public↵↵Output:↵================↵↵↵Error Output:↵================↵{ Error: ENOENT: no such file or directory, open '/MyPC/project/storage/app/public/invoice/394787d3-c3fd-44cf-90a8-7bd9bcb60e1d/invoice_2020_3.pdf'↵ -- ASYNC --↵ at Page. "

The command "PATH=$PATH:/usr/local/bin NODE_PATH=


// Current Code
Browsershot::url(route('invoice',[$seller_id, $month, $year]))
        ->setNodeBinary(env('NODE_PATH'))
        ->setNpmBinary(env('NPM_PATH'))
        ->setOption('landscape', true)
        ->margins(10, 10, 10, 10)
        ->showBackground()
        ->emulateMedia("screen")
        ->format('A4')
        ->save(storage_path('app/public').'/invoice/'.$seller_id.'/'."invoice_".$year.'_'.$month.'.pdf');
Activity icon

Replied to Retrieve Data Based On Specific Date

I solved it by using this method . But how can i merge with year ?

Deal::whereHas('post',function ($q) use ($seller_id){
                    $q->withoutGlobalScopes(['activePost'])->where('user_id',$seller_id);
                })->whereIn('status',['Received','Completed'])->whereMonth('updated_at',$month)->get();
Activity icon

Started a new Conversation Retrieve Data Based On Specific Date

Currently make some feature for seller able to download invoice based on month. So seller can choose which month that they want . Somehow my query doesnt work and keep taking wrong data . Anyone can help ?

$month = "3" ( STRING ) 
$seller_id = 1
// database 
posts
id | title | user_id |
1       test	1
2      test2	2
deals
id | post_id | status |updated_at 
1	1		Received	2020-03-01
2	1		Received	2020-03-01
3	2		Completed	2020-02-01
4	2		Dealing		2020-03-01
$deal = Deal::whereHas('post',function ($q) use ($seller_id){
	$q->where('user_id',$seller_id);
	})->whereMonth('updated_at',$month)->where('status','Received')->orWhere('status','Completed')->get();

expected result 
$deal = 2 ( id => 1,2 )

current result = 3  ( id => 1,2,4 )
Activity icon

Started a new Conversation Add Custom Blade In Markdown

Currently working on with Markdown. And I added custom view for "image". But laravel.log sent me " View [image] not found. Anyone know how to fix it ? The reason i add new custom view for "image" because i want image that align center.

// vendor/mail/html/image.blade.php
<table class="action" align="center" width="100%" cellpadding="0" cellspacing="0" role="presentation">
    <tr>
        <td align="center">
            <table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation">
                <tr>
                    <td align="center">
                        <table border="0" cellpadding="0" cellspacing="0" role="presentation">
                            <tr>
                                <td>
                                    <img style="width:100px;" src="{{ $url }}">{{ $slot }}
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
// Markdown Notification
@component('mail::message')
@component('mail::image', ['url' => asset('/mailing_images/mail.png')])
@endcomponent

Hey {{ strtoupper($user->name) }},

Yahoooooo! Thanks for registering an account with us! 

Before we get started, we'll need to verify your email.

@component('mail::button', ['url' => $url, 'color' => 'amazon', 'transform' => 'text-uppercase'])
Verify Email
@endcomponent

Thanks, <br/>
{{ config('app.name') }} TEAM
@endcomponent

Mar
17
3 weeks ago
Activity icon

Started a new Conversation How To Make 2nd Row Align Right In Markdown ?

@component('mail::message')
@component('mail::image', ['url' => asset('/mailing_images/invoice.png')])
@endcomponent

Hey {{ strtoupper($deal->buyer->name) }},

Thank you for purchasing at ********! This is a copy of your receipt.

@component('mail::image', ['url' => asset('/mailing_images/invoice.png')])
@endcomponent

Purchase Details

@component('mail::table')
|  #            | Qty          | 	Price ($) 
| :----------  |:-------------:| 	--------: 
|Left Align|Center Align |Right Align
|Left Align|Right Align    |Right Align
@endcomponent


Thanks,<br>
{{ config('app.name') }} TEAM
@endcomponent

Mar
16
3 weeks ago
Activity icon

Replied to How Can I Put Space In .env ?

thankyou for your quick response . i didnt know .env can do that . lol

Activity icon

Started a new Conversation How Can I Put Space In .env ?

How can I change APP_NAME = MY RECIPE instead of APP_NAME = MY_RECIPE ?

Mar
10
4 weeks ago
Activity icon

Replied to How Can I Ignore Data That Equal With Another Field ?

instead of using "where" , im using "whereColumn" . didnt realized about that ..

$profit_stocks = Stock::whereColumn('profit','>','loss')->orderBy('profit','desc')->get();
$loss_stocks   = Stock::whereColumn('loss','>','profit')->orderBy('loss','desc')->get();	

// current result == expected result 
Activity icon

Replied to How Can I Ignore Data That Equal With Another Field ?

yes . im trying to get a single profit row .

use case : if profit equal to loss / loss equal to profit = dont display it if profit greater than loss / loss greater than profit = display it

Activity icon

Replied to How Can I Ignore Data That Equal With Another Field ?

oh wait sir , i tried to play around with the data

id | profit | loss |  name 
1        100        1	abc
2        1          100	abcd

// expected result 
Profit = abc
Loss = abcd

// current result 
Empty 

how can I change query on ->where('profit',0) ? 
Activity icon

Replied to How Can I Ignore Data That Equal With Another Field ?

thankyou for your time . is this the best practices to make a query ? what i mean is more readable point -> to the next line ?

Stock::where('loss','>','0')
                         ->where('profit', 0)
                         ->orderBy('loss','desc')
                         ->get();
Activity icon

Replied to How Can I Ignore Data That Equal With Another Field ?

im using the 2nd option . For loss , i get it right . Somehow for profit . i get it wrong . I fixed few LoC on your option

// controller 

$profit_stocks  = Stock::where('profit','>','0')->where('loss', '<>', 0)->orderBy('profit','desc')->get();
$loss_stocks    = Stock::where('loss','>','0')->whereNotIn('id',[$profit_stocks->pluck('id')])->orderBy('loss','desc')->get();

// current result 

Profit = abc, abcde
Loss   = abcd
Activity icon

Started a new Conversation How Can I Ignore Data That Equal With Another Field ?

// controller
$loss_stocks            = Stock::where('profit','>','0')->orderBy('profit','desc')->get();
$loss_stocks            = Stock::where('loss','>','0')->orderBy('loss','desc')->get();

// database

id | profit | loss | name |
1	1		1	abc
2	0		1	abcd
2	1		0	abcde

//expected result
Profit = abcde
Loss   = abcd

//current result
Profit = abc , abcde
Loss   = abc, abcd, abcde

Activity icon

Replied to Intersect Value In Array

its done . thank you !

Activity icon

Started a new Conversation Intersect Value In Array

How can i merge if the value is same

// controller 
foreach($stocks as $stock){
            $signals[] = explode('+',$stock->signal);
            $time_frames[] = explode(',',$stock->time_frame);
        }
return view('stocks.custom',compact('stocks','signals','time_frames'));

//database 

id | timeframe | signal |
1      300,300,3     PLT+SLT+TNT

// expected result in blade
300 : 3
PLT   TNT
+
SLT

// current result in blade
300 : 300 : 3
PLT   SLT    TNT
Activity icon

Replied to How Can I Iterate Imploded Data With Another Imploded Data ?

sorry for the late reply . all is good now . thank you for your time sir

Mar
09
1 month ago
Activity icon

Replied to How Can I Iterate Imploded Data With Another Imploded Data ?

im using the first one because more readable , but somehow the foreach doesnt work . what i get is " 5: test2" , only trigger the last index .

@foreach(array_combine(explode(',', $stock->time_frame), explode(',', $stock->signal)) as $key => $value)
	{{ $key }}: {{ $value}}
	@unless($loop->last)
	<br /> <span style="padding-left:10px;">+</span> <br />
	@endunless
@endforeach

Activity icon

Started a new Conversation How Can I Iterate Imploded Data With Another Imploded Data ?

// database

// stocks 
id | name | time_frame | signal
1       test	3,5			test1,test2


//expected result 
3 : test1
    +
5 : test 2

// current result ( because idk how to iterate another imploded data ) 
test1
   +
test2

// blade
<p style="font-size:15.5px; color:black; font-weight:900;">
	{!! str_replace('+', '<br /> <span style="padding-left:10px;">+</span> <br />', $stock->signal) !!}
</p>
	
Mar
06
1 month ago
Activity icon

Awarded Best Reply on Return Response As A Download Using Spatie/Browsershot

after make some changes . now it works. thank you for your time

// controller
	$data = [
            'name' => "stock_".$from.'_'.$to.'.pdf',
            'file' => \Storage::disk('public')->url("stock_".$from.'_'.$to.'.pdf')
        ];
        return $data;
// blade js
				var fileName = data.name;
                                const a = document.createElement('a');
                                a.style.display = 'none';
                                a.href = data.file;
                                a.download = fileName;
                                document.body.appendChild(a);
                                a.click();
Activity icon

Replied to Return Response As A Download Using Spatie/Browsershot

after make some changes . now it works. thank you for your time

// controller
	$data = [
            'name' => "stock_".$from.'_'.$to.'.pdf',
            'file' => \Storage::disk('public')->url("stock_".$from.'_'.$to.'.pdf')
        ];
        return $data;
// blade js
				var fileName = data.name;
                                const a = document.createElement('a');
                                a.style.display = 'none';
                                a.href = data.file;
                                a.download = fileName;
                                document.body.appendChild(a);
                                a.click();
Mar
05
1 month ago
Activity icon

Replied to Return Response As A Download Using Spatie/Browsershot

thank you for your reply . i've tried your code, the file is downloaded . but just a plain file . not a return from browsershot.

Activity icon

Started a new Conversation Return Response As A Download Using Spatie/Browsershot

Anyone using spatie/browsershot ? everything works . pdf file stored on storage. but for the frontend part. how can i return success with automatically download the pdf ?

public function stock_custom($from,$to)
    {
        $stocks = Stock::with(['analyses' => function ($query){
            $query->whereNotNull('time_frame')->whereNotNull('description');
        }])->whereBetween('created_at',[$from.' 00:00:00', $to.' 23:59:59'])->get();

        return view('stocks.custom',compact('from','to','stocks'));
    }

public function get_download_custom(Request $request)
    {
        $from   = $request->get('from');
        $to     = $request->get('to');

        Browsershot::url(route('stock.retrieve.custom', [$from,$to]))
        ->setNodeBinary(env('NODE_PATH'))
        ->setNpmBinary(env('NPM_PATH'))
        ->setOption('landscape', true)
        ->margins(10, 10, 10, 10)
        ->showBackground()
        ->emulateMedia("screen")
        ->format('A4')
        ->save(storage_path('app/public').'/'."stock_".$from.'_'.$to.'.pdf');

        $file_name = storage_path('app/public').'/'."stock_".$from.'_'.$to.'.pdf';
 
        return \Storage::disk('public')->download("stock_".$from.'_'.$to.'.pdf');
    }

//blade javascript

	swal({
                title: "Are you sure?",
                text: "Confirm with your input?",
                icon: "warning",
                buttons: true,
                dangerMode: true,
            })
            .then((willUpdate) => {
                if (willUpdate) {
                    $.ajax({
                        url : "{{ url('stocks-custom') }}",
                        type : "POST",
                        data : {
                            '_method' : 'POST',
                            'from': from,
                            'to': to
                        },
                        success: function(){
                            // i've no idea what to put here. 
                        },
                        error : function(){
                            swal({
                                title: 'Opps...',
                                text : data.message,
                                type : 'error',
                                timer : '1500'
                            })
                        }
                    })
                } else {
                    //
                }
            });
Activity icon

Replied to How Can I Ignore " + " In Blade For The Last Index Of Array ?

from a 10++ LoC become 1 LoC . like a charm . thank you for your response !

Activity icon

Started a new Conversation How Can I Ignore " + " In Blade For The Last Index Of Array ?

// database
id | signal |
1     PLT+PLG 

// blade
@php 
    $signals = explode('+', $stock->signal->signal);
@endphp
@if(count($signals) > 1)
    @foreach($signals as $signal) 
        {{ $signal }} <br/> + <br/>
    @endforeach
@else
	{{ $signals[0] }} 
@endif

// current result 
PLT
+
PLG
+

// expected result
PLT
+
PLG
Mar
04
1 month ago
Activity icon

Started a new Conversation Add New Value In System Setting

My use case is : if system settings does not have the value " Day " ( an example ) , field value will add " Day " in the system settings . Involved with array . User might put 2 value " Day " and " Weekend " . And of course , key must be sequence based on database .

// controller
$signals = $request->get('signal') // might be an array , might not . 
$default_signal         = Helper::getSetting('signal');
$json_default_signals   = json_decode($default_signal,true);
$counter_signal         = count($json_default_signals);
foreach($signals as $signal){
    // idk how to iterate 
}
// database 
key |     value 
signal	[{"key":1,"text":"3","value":"3"},{"key":2,"text":"15","value":"15"},{"key":3,"text":"60","value":"60"},{"key":4,"text":"300","value":"300"},{"key":5,"text":"Daily","value":"Daily"},{"key":6,"text":"Weekly","value":"Weekly"}]
Activity icon

Replied to Validation Passed On Required_if

its a long conversation here . it solved now . thankyou so much ! and thank you for your time .

Activity icon

Replied to Validation Passed On Required_if

use case : if user select option "1:5" , div class time_frame_type will show , else, div class time_frame_type will not show .

<div class="form-group row">
    <div class="col-12">
        <select name="type" class="form-control signal" data-toggle="select2" data-placeholder="Select signal type">
            <option></option>
            <option value="PTH">PTH</option>
	    <option value="1:5">1:5</option>
        </select>
    </div>
</div>
<div class="time_frame_type" style="display:none;">
    <h4 class="header-title mb-4">
        Analysis Signal Type
        <a href="javascript:void(0)" class="ml-3 btn btn-primary btn-sm add_button_time_frame_type">Add timeframe type</a>
    </h4>

    <div class="field_wrapper_time_frame_type">
        <div id="time_frame_type_container">
            <div class="form-group row">
                <div class="col-3">
                    <select name="time_frame_type[]" class="form-control" data-toggle="select2" data-placeholder="Timeframe">
                        <option></option>
                        @foreach($time_frames as $time_frame)
                        <option value="{{ $time_frame['value'] }}">{{ $time_frame['text'] }}</option>
                        @endforeach
                    </select>
                </div>
                <div class="col-9">
                    <input type="text" class="form-control" name="description_type[]" placeholder="Description">
                </div>
            </div>
        </div>
    </div>
</div>

// javascript
$("select.signal").change(function(){
    var signal = $(this).children("option:selected").val();

    if(signal == '1:5'){
        $('.time_frame_type').show()
    }else{
        $('.time_frame_type').hide()
    }
});
Activity icon

Replied to Validation Passed On Required_if

i got some improvement but when i select other than "1:5". it still required . i tried delete it the code below .. still passed eventho already defined nullable ..

'description_type.*'  =>  'required|'
'time_frame_type.*'  =>  'required|'
Activity icon

Replied to Validation Passed On Required_if

https://imgur.com/ZbTUBZz

this is result of dd. the input that i explain before this is time_frame_type and description_type , both append when user select "1:5" ( javascript )

Activity icon

Replied to Validation Passed On Required_if

i tried . still passed . idk why ...

Activity icon

Replied to Validation Passed On Required_if

a string "1:5" sir .

Activity icon

Replied to Validation Passed On Required_if

still passed . i forgot to tell you guys that the input from javascript . i bet there is no big deal with it right ?

Activity icon

Replied to Validation Passed On Required_if

still passed .. am i define it in correct way ?

            'time_frame_type'   => 'required_unless:type,1:5',

Activity icon

Replied to Validation Passed On Required_if

the situation right now is i choose 1:5 . but validation still passed .

Activity icon

Started a new Conversation Validation Passed On Required_if

My use case is : if user click selection on value " 1:5 " ( accept as a string ), then user required to fill a few input . so my validation as below. how ever, validation still passed eventho i didn't fill the input

type' => 'required',
'time_frame_type'   => 'required_if:type,1:5',
'description_type'  => 'required_if:type,1:5',
Mar
03
1 month ago
Activity icon

Started a new Conversation Cannot Retrieve Other Field

How can I get "signal" in my query? I already put 'signal' in select method. i get an error "SELECT list is not in GROUP BY clause and contains nonaggregated.... " . I reuse my previous method code, everything works.

// database 
id | stock_id | signal 
1          1              ABCD
2          1              EFGH

// query
 $stocks = Stock::with(['signals' => function ($query){
	$query->select(['stock_id'])->groupBy('stock_id');
}])->get();
Mar
02
1 month ago
Activity icon

Replied to How Can I Hide Data That Has Been Deleted ?

i still get unwanted records .

        $most_followed_stocks   = FollowStock::with(['stock' => function ($query){}])->get();

Activity icon

Replied to How Can I Hide Data That Has Been Deleted ?

yup it is a timestamp . i already put it on Stock.php. idk why it didn't work ..

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Stock extends Model
{
    use SoftDeletes;
    protected $fillable = ['user_id', 'name', 'scanner', 'method', 'tactical', 'entry_price', 'target_price', 'stop_price', 'volume', 'event', 'profit', 'loss'];
    protected $dates = ['created_at'];

    public function user()
    {
        return $this->belongsTo(User::class);
    }
}

?>
Activity icon

Started a new Conversation How Can I Hide Data That Has Been Deleted ?

I cannot find any of docs to not display deleted data .

// database 
follow_stocks 
id | stock_id |
1          1
stocks 
id | deleted_at |
1        now()

// controller
most_followed_stocks   = FollowStock::with(['stock' => function ($query){
            $query->withoutTrashed();
        }])->select('stock_id',\DB::raw('count(*) as followed_count'))->groupBy('stock_id')->orderBy('followed_count','desc')->get();

        dd($most_followed_stocks); // still getting the data
Activity icon

Awarded Best Reply on How Can I Take All Value In Checkbox Array ?

im using isset method to solved this .

 'is_contradict' => isset($contradicts[$key]) ? $contradicts[$key] : 0

Activity icon

Replied to How Can I Take All Value In Checkbox Array ?

im using isset method to solved this .

 'is_contradict' => isset($contradicts[$key]) ? $contradicts[$key] : 0

Activity icon

Replied to How Can I Take All Value In Checkbox Array ?

is this valid for array checkbox too ?