evripidesk

Experience

860

0 Best Reply Awards

  • Member Since 11 Months Ago
  • 1 Lesson Completed
  • 0 Favorites

18th September, 2018

evripidesk left a reply on Laravel API Validation • 20 hours ago

I try it but still not working

evripidesk started a new conversation Laravel API Validation • 23 hours ago

Hello! I get an array from my frontend (Ionic) and I want to validate if there is an empty value, like the example below, the 0 has value the 1 doesnt has

(2) [{…}, {…}]
0: {value: "test"}
1: {value: ""}
length: 2
__proto__: Array(0)

I try the below but is not working for the 1 that has empty value, the validation is working if the array is totally empty

      $validator = Validator::make($input, [

        'exc' => 'array|required',
        'exc.*' => 'required',
      ]);

10th September, 2018

evripidesk left a reply on Read/Unread News • 1 week ago

@Vilfago yeap you are very correct!

evripidesk left a reply on Read/Unread News • 1 week ago

Hello! Thank you both, I tried with pivot table but for each news in relationship I get all users that read this new Model

      return $this->belongsToMany('App\User')->withPivot('user_id');
    }```
Controller
```$news = News::with('users','readnew')
      ->orderBy('created_at','DESC')
      ->paginate(20);```

7th September, 2018

evripidesk started a new conversation Read/Unread News • 1 week ago

I have made a fuction to laravel project to post news, if a user open a new then I add to table the newid and userid so I will know who open it, now I want to display in bold the unread news I try with a relationship but I didnt manage to do it

my model News


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

class News extends Model
{
  use SoftDeletes;

  protected $fillable = [
    'titles',
    'content',
    'user_id',
    'filename',
    'publish',
    'category',
  ];
  protected $dates = ['deleted_at'];

  public function users() {
      return $this->belongsTo('App\User','user_id');

  }
//Auth::user()->id
  public function readnew() {
      return $this->hasMany('App\Readnews','user_id',Auth::user()->id);

  }
}```

19th August, 2018

evripidesk left a reply on Laravel Blade Multidimensional Array • 1 month ago

@Cronix thank you very very much!! You are the best

evripidesk left a reply on Laravel Blade Multidimensional Array • 1 month ago

So I made this

            <tbody>
              @foreach ($chests['chest'] as $exerciseName => $daysArray)
                  <tr>
                      <td>{{ $exerciseName }}</td>
                @foreach ($daysArray as $day)

                      <td >{{  $day }}</td>
                @endforeach
                      <td>{{ $chests['hints'][$exerciseName][0] }}</td>
                  </tr>
              @endforeach

              </tbody>

But how I made my table pretty? :)

Exercises   Days    Hints
Chest Press 1   2   3   4   alo
Flys    3   4   alo2

evripidesk left a reply on Laravel Blade Multidimensional Array • 1 month ago

@Cronix I dont need the sum I need the actual value eg

Chest Press | 1 | test1
Flys        | 3,4 | test2

18th August, 2018

evripidesk started a new conversation Laravel Blade Multidimensional Array • 1 month ago

I have the below arrays and I want to get it in laravel blade as HTML table

"Chest Press" => array:1 [▼
 0 => "1"
]
"Flys" => array:2 [▼
0 => "3"
1 => "4"
]
]

array:2 [▼
"Chest Press" => array:1 [▼
0 => "test1"
]
"Flys" => array:1 [▼
  0 => "test2"
]
]```
I try the below but I dont get right HTML table, its correct the first two columns but the third columnt is not, any ideas how to print it on HTML table

  ```<table class="table table-striped table-hover table-reflow">
            <thead>
                <tr>
                  <th>Exercises</th>
                  <th>Days</th>
                  <th>Hints</th>


                </tr>
            </thead>
        <tbody>

        @foreach($chests['chest'] as $chest => $exc)
            <tr>
                <td>{{$chest}}</td>
                @foreach($exc as $key => $value)
                    <td>
                         <strong>{{$value}},</strong>
                    </td>
                @endforeach

        @endforeach

        @foreach($chests['hints'] as $hint => $hin)


                @foreach($hin as $key => $value)
                    <td>
                         <strong>{{$value}}</strong>
                    </td>

                @endforeach

              </tr>
        @endforeach

          </tbody>```

17th August, 2018

evripidesk started a new conversation Old Data For Checkbox • 1 month ago

How can I get the old value for the below check box

                    @for ($i = 0; $i < $days; $i++)
                      <label><input type="checkbox" name="{{str_replace(' ', '_', $chest->name)}}_days[]"
                        value="{{$i+1}}">{{$i+1}}</label>

                    @endfor```

10th August, 2018

evripidesk left a reply on Laravel Search Delete • 1 month ago

@Snapey thank you so so much, now all are fine!

evripidesk left a reply on Laravel Search Delete • 1 month ago

I make a soft delete function and in my query I am using withTrashed()

evripidesk left a reply on Laravel Search Delete • 1 month ago

sorry for some reason didn't displayed now I edited the post and shows the method

evripidesk left a reply on Laravel Search Delete • 1 month ago

html:

<form action="{{action('[email protected]', Hashids::encode($sub['id']))}}" method="POST">
            {{csrf_field()}}
            {{method_field('DELETE')}}
            <button type="submit" class="m-portlet__nav-link btn m-btn m-btn--hover-danger m-btn--icon m-btn--icon-only m-btn--pill"
            data-tr="tr_{{$sub['id']}}"
            data-toggle="confirmation"
            data-btn-ok-label="Delete" data-btn-ok-icon="fa fa-remove"
            data-btn-ok-class="btn btn btn-danger"
            data-btn-cancel-label="Cancel"
            data-btn-cancel-icon="fa fa-chevron-circle-left"
            data-btn-cancel-class="btn btn btn-default"
            data-title="Are you sure you want to delete ?"
            data-placement="left" data-singleton="true"
            > <i class="glyphicon glyphicon-trash"></i></button>
          </form>```

Controller
public function destroy($id)
{
  $id=Hashids::decode($id);
  $id = implode(',', $id);

  $sub = Subs::find($id);
  $sub->delete();

  return back()->with('success', 'Subscription Plan has been deleted');

}```

evripidesk left a reply on Laravel Search Delete • 1 month ago

@Snapey I am using the form but when redirect back after delete I get the above error, the form that I am using is the form that you post

evripidesk left a reply on Laravel Search Delete • 1 month ago

@Saikishore I get the same error

evripidesk left a reply on Laravel Search Delete • 1 month ago

@v0sn all working fine, but when I use my search form to find a subscription and I press the delete then I get the error MethodNotAllowedHttpException

evripidesk left a reply on Laravel Search Delete • 1 month ago

@v0sn but the route delete already include to Route::resource('subscriptions','SubsController');

evripidesk left a reply on Laravel Search Delete • 1 month ago

@Snapey I try it but when I use my search form to find the subscription plan and I delete a record I get throw new MethodNotAllowedHttpException($others);

evripidesk left a reply on Laravel Search Delete • 1 month ago

I have it Route::resource('subscriptions','SubsController');

9th August, 2018

evripidesk started a new conversation Laravel Search Delete • 1 month ago

When I make search and I get the search results, I try to delete a record , its deleted show the message that successfully deleted but after I get the error throw new MethodNotAllowedHttpException($others);

`public function destroy($id) { $id=Hashids::decode($id); $id = implode(',', $id);

  $sub = Subs::find($id);
  $sub->delete();
  return response()->json(['success'=>"Subscription Plan Deleted 
  successfully.", 'tr'=>'tr_'.$id]);

}

Call Function

a href="{{action('[email protected]', Hashids::encode($sub['id']))}}" class="btn btn-danger btn" data-tr="tr_{{$sub['id']}}" data-toggle="confirmation" data-btn-ok-label="Delete" data-btn-ok-icon="fa fa-remove" data-btn-ok-class="btn btn btn-danger" data-btn-cancel-label="Cancel" data-btn-cancel-icon="fa fa-chevron-circle-left" data-btn-cancel-class="btn btn btn-default" data-title="Are you sure you want to delete ?" data-placement="left" data-singleton="true"> Delete </a>

Routes Route::post('/subscriptions/search/results','[email protected]'); Route::get('/subscriptions/restore/{id}', '[email protected]');

30th November, 2017

evripidesk started a new conversation Listbox Move Items • 9 months ago

I have the below listbox that transfer values to other listbox, is working fine but I want to take the values in split show I can use json

html

<?php 

div class="subject-info-box-1">
                    <select name="product_list"  multiple = "multiple"size="20" id="lstBox1" style="width: 250px;" class ="form-control" >
                      @foreach($array['product_name'] as  $product_name['product_name'])
                        @foreach($array['product_directions'] as  $product_directions['product_directions'])

                          <?php $i++ ?>
                          <option  value="{{$product_name['product_name']}}, {{$product_directions['product_directions']}}" style="font-weight:bold" > {{ $i}} ) {{$product_name['product_name']}} {{$product_directions['product_directions']}} </option>
                          @endforeach
                      @endforeach
              </select> </td>
              
            </div>

          <td>    <div class="subject-info-arrows text-center">
                <input type="button" id="btnRight" value=">" class="btn btn-default" /><br />
                <input type="button" id="btnLeft" value="<" class="btn btn-default" /><br />
                <input type="button" id="btnAllRight" value=">>" class="btn btn-default" /><br />
                <input type="button" id="btnAllLeft" value="<<" class="btn btn-default" />
              </div> </td>

            <td>  <div class="subject-info-box-2">
                <select autofocus name = "pending_products[]" multiple="multiple" size="20" id='lstBox2' style="width: 250px;" class="form-control">
                </select> </td>




          <center><button type="submit" id='submit' class="btn btn-success" style="margin-left:38px" >Pending Products</button></center>

javascript

<?php 

<script type="text/javascript">
$('#submit').click(function() {
    $('#lstBox2 option').prop('selected', true);
});
(function () {
    $('#btnRight').click(function (e) {
        var selectedOpts = $('#lstBox1 option:selected');
        if (selectedOpts.length == 0) {
            alert("Nothing to move.");
            e.preventDefault();
        }
        $('#lstBox2').append($(selectedOpts).clone());
        $(selectedOpts).remove();
        e.preventDefault();
    });
    $('#btnAllRight').click(function (e) {
        var selectedOpts = $('#lstBox1 option');
        if (selectedOpts.length == 0) {
            alert("Nothing to move.");
            e.preventDefault();
        }
        var retVal = confirm("Do you want to transfer all drugs to PENDING list ?");
        if( retVal == true ){
        $('#lstBox2').append($(selectedOpts).clone());
        $(selectedOpts).remove();
        e.preventDefault();
      }
    });
    $('#btnLeft').click(function (e) {
        var selectedOpts = $('#lstBox2 option:selected');
        if (selectedOpts.length == 0) {
            alert("Nothing to move.");
            e.preventDefault();
        }
        $('#lstBox1').append($(selectedOpts).clone());
        $(selectedOpts).remove();
        e.preventDefault();
    });
    $('#btnAllLeft').click(function (e) {
        var selectedOpts = $('#lstBox2 option');
        if (selectedOpts.length == 0) {
            alert("Nothing to move.");
            e.preventDefault();
        }
        $('#lstBox1').append($(selectedOpts).clone());
        $(selectedOpts).remove();
        e.preventDefault();
    });


}(jQuery));

Now I get the below

array:2 [▼ "_token" => "RgqpyEVz8ji659bZguBup3fW0YiC0vcRtk186AM2" "pending_products" => array:1 [▼ 0 => "CD Player, Electronics" ] ]

But I want to get it like this:

array:2 [▼ "product_name" => array:1 [▼ 0 => "CD Player" ] "product_directions" => array:1 [▼ 0 => "Electronics" ] ]

25th November, 2017

evripidesk left a reply on Add Show Textbox • 9 months ago

also below its my html code

      <form action="{{action('[email protected]', $id)}}" method="post">
<h5 class="text-center">Product</h5>
        <section class="container">
        <div class="table table-responsive">
        <table class="table table-responsive table-striped table-bordered">
        <thead>
          <tr>
              <td>Product Name</td>
              <td>Details</td>
              <td>Remove</td>
            </tr>
        </thead>
        <tbody id="TextBoxContainer" name="TextBoxContainer" method="post" >
        </tbody>
        <tfoot>
          <tr>
            <th colspan="5">
            <button id="btnAdd" type="button" class="btn btn-primary" data-toggle="tooltip" data-original-title="Add more controls"></i>+ Add&nbsp;</button></th>
          </tr>
        </tfoot>
        </table>
        </div>
        </section>

evripidesk left a reply on Add Show Textbox • 9 months ago

@Sergiu17 thank you, I changed it but I still I cannot get the value of this textbox,

24th November, 2017

evripidesk left a reply on Add Show Textbox • 9 months ago

what I have to specify, what value, I need to send to html post

evripidesk started a new conversation Add Show Textbox • 9 months ago

I have the below script to add / remove text boxes but I don't know how to post the value

<?php 
<script type="text/javascript">


$(function () {

$("#btnAdd").bind("click", function () {
var div = $("<tr />");
div.html(GetDynamicTextBox(""));
$("#TextBoxContainer").append(div);
});
$("body").on("click", ".remove", function () {
$(this).closest("tr").remove();
});
});
function GetDynamicTextBox(value) {


return '<td><textarea name = "product"  type="text" ' + value + '" class="form-control" /></td>'  + value + '" /></td>'+ '<td><textarea name = "prescription" type="text"' + value + '" class="form-control" /></td>' + '<td><button type="button" class="btn btn-danger remove">X</button></td>'
}

</script>

20th November, 2017

evripidesk left a reply on After Refresh Go Back • 9 months ago

@RamjithAp Perfect I correct the line from ''' return redirect('products/'.$id.'/history'); to ''' return redirect('products/'.$id.'/history/view'); ''' and is working perfect

thank you man

evripidesk left a reply on After Refresh Go Back • 9 months ago

I try it but I get blank page updated code

<?php 
 public function searchSecurityCode($id)
     {
       $id=Hashids::decode($id);
       $id = implode(',', $id);

       $security_code = Session::get('security_code');

       $this->validate(request(), [
           'q' => 'required'],
           [
               'q.required'    => 'Please type the security code ',

           ]);
            $q = Input::get ( 'q' );

            $success = Clients::where(function($query) use ($id,$q) {
                                          $query->where('id', 'LIKE', $id)
                                                  ->where('security_code', 'LIKE', $q);

                                      })->get();


            if(count($success) > 0) {
              Session::forget('security_code');
              Session::forget('name');
              $products = Products::with('user’,’clients’)->where(‘client_id','LIKE',$id)->paginate(10);
              $resetsecuritycode = Clients::find($id);
              $resetsecuritycode->security_code = str_random(10);
              $resetsecuritycode->save();
              Session::put('products',$products);


             }else
            return redirect()->back()->with('status', 'No record founded!');


     }

     public function viewhistory($id)
     {
        $products = Session::get('products');
        return redirect('products/'.$id.'/history')-> withProducts($products);
     }

Routes Route::post('/clients/{id}/history/', '[email protected]'); Route::get('/clients/{id}/history/view', '[email protected]');

19th November, 2017

evripidesk left a reply on After Refresh Go Back • 9 months ago

I dont have any get for this, do I need this if yes which method can I use for get (eg)

evripidesk started a new conversation After Refresh Go Back • 10 months ago

I have the below code that is search for security code (that is in my db) and I use form to search it, is working fine but if I hit the refresh button (browser) then I get back with the error , No record found how can I stop it and with the refresh get the normal details

<?php 
 public function searchSecurityCode($id)
     {
       $id=Hashids::decode($id);
       $id = implode(',', $id);

       $security_code = Session::get('security_code');

       $this->validate(request(), [
           'q' => 'required'],
           [
               'q.required'    => 'Please type the security code ',

           ]);
            $q = Input::get ( 'q' );

            $success = Clients::where(function($query) use ($id,$q) {
                                          $query->where('id', 'LIKE', $id)
                                                  ->where('security_code', 'LIKE', $q);

                                      })->get();


            if(count($success) > 0) {
              Session::forget('security_code');
              Session::forget('name');
              $products = Products::with('user’,’clients’)->where(‘client_id','LIKE',$id)->paginate(10);
              $resetsecuritycode = Clients::find($id);
              $resetsecuritycode->security_code = str_random(10);
              $resetsecuritycode->save();

              return view(‘clients.history')->withClients($products);

             }else
            return redirect()->back()->with('status', 'No record founded!');


     }

My route is below

Route::post('/clients/{id}/history/', '[email protected]');

27th October, 2017

evripidesk left a reply on Get All Rows With Specific ID • 10 months ago

the issue as I think is here ->Orwhere('client_story', "%{$q}%") if I search only for name the its fine when I search for client_strory then give me and results from other clients id

evripidesk left a reply on Get All Rows With Specific ID • 10 months ago

my search query return me and clients with different id

evripidesk left a reply on Get All Rows With Specific ID • 10 months ago

this working, thank you, but I get wrong results, I get and results with different ids

26th October, 2017

evripidesk left a reply on Get All Rows With Specific ID • 10 months ago

i try the below but I still dont get any records

<?php 
$clients = Clients::where('client_id', $id)
                                      ->whereHas('user', function ($query) use ($q) {
                                        $query->Orwhere('name', "%{$q}%");})

                                        ->Orwhere('client_story', "%{$q}%")

                                        ->paginate(10);

evripidesk left a reply on Get All Rows With Specific ID • 10 months ago

@robrogers3 yes you are correct and I think the wherein cannot help me because my search results cannot find any record, is there any method so I can get the rows for specific ID and only for this ID

evripidesk left a reply on Get All Rows With Specific ID • 10 months ago

if I change the WhereIn with orwhere then is working but with wrong results (get results with different id)

evripidesk left a reply on Get All Rows With Specific ID • 10 months ago

anywhere after $clients = Clients::where('client_id', 'LIKE', $id) i get the same error before this my variable is null

evripidesk left a reply on Get All Rows With Specific ID • 10 months ago

cannot get dd ($clients) give me the same error "Invalid argument supplied for foreach()"

evripidesk left a reply on Get All Rows With Specific ID • 10 months ago

thank you for your reply and sorry for missing code controller

<?php 
public function searchHistory ()
     {
       $this->validate(request(), [
         'q' => 'required',
       ]);
            $q = Input::get ( 'q' );
            $id = Session::get('id');
            $clients = Clients::where('client_id', 'LIKE', $id)
                                      ->whereHas('user', function ($query) use ($q) {
                                        $query->where('name', 'like', "%{$q}%");})
                                        ->whereIN('client_story','LIKE',"%{$q}%")
                                        ->paginate(10); 
  if(count($clients) > 0)
            return view('clients.history',compact('clients'))->withClients($clients);
           else     return redirect('/clients/history')->with('status', 'No record founded!');


    }

history.blade

<?php 

  @foreach($clients as $client)
      <tr>
        <td>{{$client->client->name}}</td>
        <td>{{$client->idcard}}</td>
        <td>{{$client->phone_number}}</td>
        <td>{{$client['client_story']}}</td>
        <td>{{$client['created_at']}}</td>
        <td>{{$client->user->name}}</td>




        </td>
      </tr>
      @endforeach 

evripidesk started a new conversation Get All Rows With Specific ID • 10 months ago

I am trying to get all raws (search) with specific ID with whereIn 'public function searchHistory () { $this->validate(request(), [ 'q' => 'required', ]); $q = Input::get ( 'q' ); $id = Session::get('id'); $clients = Clients::where('client_id', 'LIKE', $id) ->whereHas('user', function ($query) use ($q) { $query->where('name', 'like', "%{$q}%");}) ->whereIN('client_story','LIKE',"%{$q}%") ->paginate(10); '

but I get the following error "Invalid argument supplied for foreach()"

Edit Your Profile
Update

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