somnathsah

somnathsah

Member Since 1 Year Ago

Experience Points 9,540
Experience
Level
Lessons Completed 6
Lessons
Completed
Best Reply Awards 13
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.

08 Aug
3 months ago

somnathsah left a reply on Concatenate The Variable Value With String Message

replace your return statment with this

return redirect()->back()->with('alert-success', 'orderd successfully inserted, Amount = Rs.' . $total_price); 

means replace ',' with '.'

27 Jul
3 months ago

somnathsah left a reply on Error In Maatwebsite To Export Excel File In Laravel

@AbdulBazith try changing

$sheet->fromArray($sales_array);

with this one

$sheet->fromArray($sales_array, null, 'A1', false, false);

this will add header

somnathsah left a reply on Problem In Appending Html Data After Ajax Success With Laravel

@AbdulBazith can you please share the final code you are using?

somnathsah left a reply on Problem In Appending Html Data After Ajax Success With Laravel

@AbdulBazith try changing below line

 $.each (data, function (value) {

with this one

 $.each (data, function (key, value) {

this will work

somnathsah left a reply on Problem In Appending Html Data After Ajax Success With Laravel

@AbdulBazith can you please try console.log(data) before the loop, so that i can have a look of the data object.

26 Jul
3 months ago

somnathsah left a reply on Problem In Table Display In Javascript In Laravel

you can change your code to something like this. this should work.

var res='''
 $.each (data, function (value) {
        
            res +=
            '<tr>'
        '<td>'+value.id+'</td>'
        '<td>'+value.date+'</td>'
        '<td>'+value.time+'</td>'
        '<td>'+value.no_of_litre+'</td>'
        '<td>'+value.note+'</td>'
        '</tr>';

   });
20 Jul
3 months ago

somnathsah left a reply on Laravel 5.6 "Page Not Found" Problem

If you have setup new LARAVEL application then you need to generate the application key. You use the following commands

php artisan cache:clear
php artisan key:generate
04 May
6 months ago

somnathsah left a reply on Laracasts Forum Does Not Handle CSRF Token Expiry Gracefully; Login Fails Silently

@cbj4074 we can implement a JS code which will logout from the site after the session time gets expired, redirect to login page and replace the login page with button something like "login again"

somnathsah left a reply on Laracasts Forum Does Not Handle CSRF Token Expiry Gracefully; Login Fails Silently

Yes @jirdw this is about the forum :-), but in case someone want to handle this error.

somnathsah left a reply on Error While Updating Composer

You need to install all the php extension required for this laravel version .

Below is the reference for installaing ext-mbstring, similarly you can install all other missing extensions. https://askubuntu.com/questions/491629/how-to-install-php-mbstring-extension-in-ubuntu

somnathsah left a reply on How To Validate The Maximal Salary To Be Greater Than The Minimum Salary?

@nero create a validator object of input element like below

$validator = Validator::make($data, [
    'email' => 'required|email',
]);

Suppose you have any other input field like email then create the validator object and use that as below.

$validatedData =$validator->sometimes([ 'min_salary' , 'max_salary' ], 'required', function($data){
    return $data->max_salary >$data->min_salary;
});

$validatedData will have a response that it is validated or not

somnathsah left a reply on How To Validate The Maximal Salary To Be Greater Than The Minimum Salary?

You can use the following validation rule.

$validatedData = $request->validate([ 'min_salary' , 'max_salary' ], 'required', function($data){
    return $data->max_salary >$data->min_salary;
});
09 Jan
10 months ago

somnathsah left a reply on Laravel Insert Method Getting Error In Sql Server

Thanks @topvillas for your help. But is there any other laravel method which can insert bulk records and not using the bind param way. So that I can overcome sqlserver restriction.

07 Jan
10 months ago

somnathsah left a reply on Laravel Insert Method Getting Error In Sql Server

Yes @rob897 I checked, this is the restriction from sql server side.

How can I use laravel insert method to insert large numbers of records, having more then 2100 bind params in sql server database?

05 Jan
10 months ago

somnathsah started a new conversation Laravel Insert Method Getting Error In Sql Server

Hi,

I am using sql server as my database and need to insert large number of records . But while using below code

 AgentData::insert($data);

getting error

 SQL Server supports a maximum of 2100 parameters.  
SQLSTATE[IMSSP]: Tried to bind parameter number 2101.  SQL Server supports a maximum of 2100 parameters

above code is working fine when I break my array into chunk and execute insert statement for each chunk.

Thanks in advance,

26 Dec
10 months ago

somnathsah left a reply on Is There Any Method In Eloquent To Delete A Part Of Data Or Append A Part In Json Data Type Column?

@insight You can cast your json to array and use that json value as normal value of object and can perform add/delete operation as a normal column.

for your reference : https://laravel.com/docs/5.5/eloquent-mutators#array-and-json-casting

somnathsah left a reply on Password Reset Route Not Found

@omarsow94 verify that your App\User model implements the Illuminate\Contracts\Auth\CanResetPassword contract.

and check that you password_reset table in place.

for reference please check https://laravel.com/docs/5.5/passwords#introduction

somnathsah left a reply on Password Reset Route Not Found

@omarsow94 Could you please share the link you are getting in the email?

somnathsah left a reply on Password Reset Route Not Found

Route for resetting password is

Route::post('/password/reset', 'Auth\[email protected]');

So change your

<form action="" method="post">

to

<form action="/password/reset" method="post">

This might work for you.

somnathsah left a reply on Advise On How To Approach A Situation (Jobs, Scheduler, Multi Workers )

@Yahav in cron job you can include the following command

* * * * * php /path-to-your-project/artisan schedule:run >> /dev/null 2>&1

This is the beginning part of the laravel scheduler. When cron job will run this command laravel check all the due job and run those jobs.

please read this : https://laravel.com/docs/5.5/scheduling#introduction it might help you

somnathsah left a reply on Advise On How To Approach A Situation (Jobs, Scheduler, Multi Workers )

You can achieve this with laravel scheduler and cron job on linux or scheduler task on windows. What you need to do is store scheduling time and details in database for a job, and run the laravel scheduler for interval of a minute or something which will check any scheduling job and run that job at specified time.

please follow the link : https://laravel.com/docs/5.5/scheduling

20 Dec
10 months ago

somnathsah left a reply on Laravel Excel : Remove Extra Space From File Header And Values

Thanks @Dry7, Yes I saw this earlier, this is good solution. But is there anything which I add in config of excel or direct call any method on my reader object to remove the extra spaces from header and values.

somnathsah started a new conversation Laravel Excel : Remove Extra Space From File Header And Values

Hi,

I am using Laravel excel package to read excel file. I want to know, Does it provide any method which I can use to remove extra spaces from all header and values of the file? I don't want to use function like trim for each rows.

Thanks in advance,

04 Dec
11 months ago

somnathsah left a reply on Change End Of Line Character When Generating Code With Php Artisan Make Commands

you can use php constant PHP_EOL , which is platform independent.

15 Nov
11 months ago

somnathsah left a reply on Convert Mysql Query To Laravel ORM Query

You can create query something like below: {code} DB::table('payments', function($query) { $query->join('tickets') ->on('payments.receipt', '=', 'tickets.receipt'); }) ->select('payment', 'total', 'transid') ->get(); {code} reference : https://laravel.com/docs/5.5/queries

06 Oct
1 year ago

somnathsah left a reply on Inserting Multiple Records At Once

@jerauf please use print_r to print the $publish_on and paste the result here, So that we can check that correct array is being created.

28 Sep
1 year ago

somnathsah left a reply on Auth()->id() Doesn't Work; But If I Hardcode It, It Does

I think you need to pass auth object to your anonymous function as you have passed the thread.

somnathsah left a reply on Auth()->id() Doesn't Work; But If I Hardcode It, It Does

Try using below instead of auth()->id(), it might work.

 Auth::id();
26 Sep
1 year ago

somnathsah left a reply on Artisan Not Working After Updating PHP

I think this library is missing so you can try installing this by bellow command

composer require laravelcollective/html

somnathsah left a reply on Artisan Not Working After Updating PHP

Run the below command after running composer. This might work

php artisan optimize
08 Sep
1 year ago

somnathsah left a reply on Execute Artisan Command From Code

Here is the example by which you can call artisan command programmatically

https://laravel.com/docs/5.4/artisan#programmatically-executing-commands

somnathsah left a reply on How To Pass A POST Data Array From One View To Another? Or How To Correctly Submit And Display Information Simultaneously?

You can send the view file from first method like something below

response()->json([view::make('viewFile', [
            'data'  => $request
]

Here you can pass the $request object to the second view file and can access in second view.

01 Sep
1 year ago

somnathsah left a reply on Problem In Route

You can run the below command and verify if correct route is being created.

php artisan route:list

And also check no duplicate route has been created and you don't have any redirect call for the route localhost/quiz in method for route localhost/site/quiz

19 Jul
1 year ago

somnathsah left a reply on TokenMismatchException On Form Post From Inside A Table

@kfirbe Yes, I used the same solution for for one of my previous task.

But for now there is two scenarios.

  1. One for which all the element of the table which will get posted. for this I have added form element at top before table tag.
  2. For one more case I need to post some element of the same above table not the complete table. So I want add this element into another form. something like below.
<form>
    <input type="hidden" name="_token" value="{{csrf_token()}}">
    
    <table>
        // ...
       <form>
            <input type="hidden" name="_token" value="{{csrf_token()}}">
            //input element
       </form>
    </table>
</form>

somnathsah left a reply on TokenMismatchException On Form Post From Inside A Table

Thanks @kfirba for your reply. I fixed the closing tag, but issue is still persist. Actually the issue is with nesting of form inside of table. I have faced the same issue previously but that time i found some alternate way.

but this time I am unable to find any other way. So if anyone has workaround for nesting form inside a table which does not throw TokenMismatchException, that will be very helpful for me.

somnathsah started a new conversation TokenMismatchException On Form Post From Inside A Table

Hi,

I am getting TokenMismatchException while posting a form which is present in table row.

below is the part of code.

   <table class="table table-hover table-bordered table-striped text-center">
            <thead style="background-color: #e0e0e0;"> 
                <th>Key Name</th>
                <th>Status</th>
            </thead>
            <tbody>
                    <tr class="goalRow">
                       <form id='clientGoalsRow' method='post' action='{{ url("client_goals/save_program_goals") }}' class="form-horizontal">
                        <input type="hidden" name="_token" value="{{ csrf_token()}}">
                        <td>
                            {{ $value['keyName'] }}
                        </td>
                        <td>
                            <div class="form-group">
                                <select id="goalStatus" name="goalStatus[]" onchange="" class="goalStatus form-control">
                                    <option value="enabled"  @if ($value['status'] == 'enabled') {{ "selected" }} @endif>Enabled</option>
                                    <option value="disabled" @if ($value['status'] == 'disabled') {{ "selected" }} @endif>Disabled</option>
                                </select>
                            </div>
                        </td>
                    </tr>
            </tbody>
        </tbale>

NOTE : Can not put form before the table. And need to post this part of code only not complete table which also has some other form element.

Thanks, Somnath

10 Jul
1 year ago

somnathsah left a reply on How To Search For Multiple Words?

@derrickrozyay I tried query like below and it returned the result as you are needed

select * from table where $term like concat('%',column, '%')

So, what I wanted to say is reverse all your where clause like below

where(DB::raw(concat('%', $term, '%') , 'LIKE', 'items.description')

NOTE : I am using sql server for my database please find similar function for concat in your corresponding DB.

15 Jun
1 year ago

somnathsah left a reply on Select Statement Set Null Column Defualt Value To 0

@okawei I am not using model instance for querying. I am using DB::table() to do the query. for example I am creating a query like this.

DB::table('test')
->select(DB::raw('isnull(column, 0)'))->get();

So, isnull function is not working, My database is SQL server.

somnathsah started a new conversation Select Statement Set Null Column Defualt Value To 0

Hi,

I am creating a query and executing it in sqlserver. I want to set null column value to 0 in select statement using method like coalesce, isnull but it is throwing error. "can not access empty property".

any help will be much appreciated.

Thanks, Somnath

30 May
1 year ago

somnathsah left a reply on 5.4 Month Validation Error

I ran the same code which you have posted. it works fine for me. Please check the data type of month field if you are getting this dynamically.

or you can try checking printing the for each value from 01 to 12 and can check if data type is same for all. you can do the var_dump for that as below.

var_dump($data['month']);

somnathsah left a reply on Blade Textarea With Php Tags

put your code in tag {!! !!}. like below.

{!! !!}

Code in this tag will not get parsed.

somnathsah left a reply on Undefined Variable

I Think you are missing to send variable $comments from controller to view.

somnathsah left a reply on How To Fetch Original Array Value

@Vikrant if your above array is a part of Illuminate\Support\Collection object then toArray() method should work on this object.

here are list of all method which you can use on the collection object. https://laravel.com/docs/5.4/collections#available-methods