samedi 31 mars 2018

How to handle this error : Class App\Http\Controllers\post/ProductController does not exist

Code in the blade file is given as below:

@extends('clientlayout.layouts.master1')
@section('title')
Register
@endsection
@section('content')
<div class="container" style="background-color: #c1bdba;max-width: 100% 
!important;">
<div class="row">
  <div class="offset-lg-2 col-lg-8 col-sm-8 col-8 border rounded main- 
  section"  style="background-color:rgba(19, 35, 47, 0.9);">
  <img src="client/images/decksys.png" alt="." style="margin: 20px 0px 20px 
350px;"> 
    <hr>
    <form class="container" action="/create" id="needs-validation" 
method="post" novalidate>
    <input type = "hidden" name = "_token" value = "<?php echo csrf_token(); 
 ?>">
      <div class="row">
        <div class="col-lg-6 col-sm-6 col-12">
           <div class="form-group">
            <label class="text-inverse custom" 
 for="validationCustom01">First Name
 <span class="req">*</span>
 </label>
<input type="text" name="firstname" class="form-control" 
id="validationCustom01"  placeholder="First name"
value="" required maxlength="25" onKeyPress="return ValidateAlpha(event);" 
style="background-color: rgba(19, 35, 47, 0.4); color:#fff;">
            <div class="invalid-feedback">
              Enter Your Firstname
            </div>
          </div>
        </div>

      </div> 
 </form>
   </div>
   </div>  
   </div>
   @endsection

The Controller code is shown below:

<?php

namespace App\Http\Controllers;

use App\Http\Controllers\ProductController;


use Illuminate\Http\Request;

use DarthSoup\Whmcs\Facades\Whmcs;
use Darthsoup\Whmcs\WhmcsServiceProvider;

class ProductController extends Controller
{
 public function insertform(){
    return view('clientlayout.main.signup');
    } 

  public function insert(Request $request){

    $user = User::create([
        'firstname' => $data['firstname'],
        'lastname' => $data['lastname'],
        'email' => $data['email'],
        'city' => $data['city'],
        'dob' => $data['dob'],
        'password' => bcrypt($data['password']),
    ]);
    Whmcs::create($data->all());
    return redirect($this->create());

    echo "Record inserted successfully.<br/>";
    echo '<a href = "/insert">Click Here</a> to go back.';

    }

    }

The route code is given below and suggest me if any changes has to be made in the route.

Route::get('insert', 'ProductController@insertform');
Route::post('create','post/ProductController@insert');

Suggest me a solution to handle this error - "Product Controller doesn't Exit" and to get the output as follows:

Record inserted successfully



via Chebli Mohamed

mercredi 28 mars 2018

How to show message in Popup without reloading the page in Laravel? I am sending data using CURL

This is dashboard.blade.php My View.

<form class="form-horizontal" role="form" method="post" action="" enctype="multipart/form-data">
   <input type="hidden" name="_token" value="">  
   <div class="row">
    <div class="col-md-6">
            <fieldset style="height: auto;">
                    <legend>Complaint Details</legend>
                    <div class="form-group row">
                            <label class="col-md-6 control-label" for="pnr">PNR/Unreserved Tickets No <span class="errors">*</span>: </label>
                            <div class="col-md-6">          
                                    <input type="text" class="form-control" maxlength="10" name="pnr" id="pnr" placeholder="PNR/Unreserved Tickets No." required>
                            </div>
                    </div>
                 </div>
              </div>
           </form>

This is my DashboardController.php

  public function formSubmit(Request $request){ 
  $data1 = [
        'name'=> $passName,
  ];
   $curl = curl_init();

    curl_setopt_array($curl, array(
        CURLOPT_URL => "xyz.com",
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => "",
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 30,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => "POST",
        CURLOPT_POSTFIELDS =>$data1,
        CURLOPT_HTTPHEADER => array(
            "Content-Type: multipart/form-data",
          ),
    ));

    $response = curl_exec($curl);
    $err = curl_error($curl);

    curl_close($curl);
    if ($err) {
        return redirect()->back()->with('message','Error on submitting form.'); 
    } else {  
            return redirect()->back()->with('message','Thank You for Submitting Complaint');
        }

It is working fine. I am sending the data through CURL in Laravel. I just want to not refresh the page after submitting the Form. I just want to show the Successful message or error message in a popup. When I am submitting the form, It reloads the page. I just don't want to reload the page.

Thanks In Advance.



via Chebli Mohamed

How to search autocomplete with laravel?

I'm trying to do search autocompleete in a taable with laaravel. I've triied to do thiis usiing the code below but nothiing happens....... Could you please help me with this....... Thank you in advance....

route.php

Route::get('/metier', 'MetierController@index');
Route::get('/metier/search', 'MetierController@search');
metiercontroller

public function index()
{
$Listmetier=metier::all();
return view('metier.index',['metier'=>$Listmetier]);
}
public function search(Request $request)
{     
if($request->ajax())
{
$output="";
$metiers=DB::table('metiers')- 
>where('libelle_metier','LIKE','%'.$request->search."%")-
>get();
if($metiers)
{
foreach ($metiers as $key => $metiers) {
$output.='<tr>'.
'<td>'.$metiers->id.'</td>'.
'<td>'.$metiers->libelle_metier.'</td>'.
'</tr>';
 }
 return Response($output);
}
}

index.blade.php

@extends('Layouts.app')
@extends('Layouts.master')
@section('content')
<link rel="stylesheet" type="text/css"     
 ref="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

Liste des Metiers Ajouter Metier

        <head>
        <tr>
            <th>libelle metier</th>
            <th>Action</th>

        </tr>
        </head>
        <body>

        </body>
    </table>

</div>
<script type="text/javascript">
    $('#search').on('keyup',function){
        $value=$(this).val();
        $.ajax({
            type: 'get',
            url : '',
            data : {'search':$value},
            success:function(data){
                console.log(data);
            } 
        });
    }
</script>
</div>
</div>
 @endsection



via Chebli Mohamed

jeudi 22 mars 2018

Replacing values in an array basing on values from another

Having the 2 following arrays:

[
    {"id":1,"value":40},
    {"id":2,"value":30},
]

And:

[
    {"userId":1,"worth":20},
    {"userId":2,"worth":10},
]

What I want to have in the end, is the following result:

[
    {"id":1,"value":20},
    {"id":2,"value":10},
]

So here, I want to replace in the first array, the values with those in the second array, according to the ìd`. I made something like that:

foreach ($array2 as $k => $v) {
    array_filter($array1), function($item) use($value) {
        $item['id'] == $v['userId'] ? $item['value'] = $v['worth'] :$item['value'] = $item['value'];
    });
}

It is working for those given arrays, but if you have arrays with more than 1 million data, it will never be done ! The question is, if there are some PHP functions which can do this hard work?



via Chebli Mohamed

mercredi 21 mars 2018

I am using alaouy/Youtube package on my laravel 5.4 its fetching videos from youtube

I am using alaouy/Youtube package on my laravel 5.4 its fetching videos from youtube but i am getting errors i am a little new to laravel hope you can help me out thank you

// /view

@extends('welcome') 
    @section('content')


       <ul>
           @foreach($videos as $data)
                <div class="well">
                    
               </div>
         @endforeach
     </ul>
  @endsection

 enter code here

// controller

   $videos = Youtube::search($search);

  return view('search',compact('videos'));

i am able to get access to all the data in the object except

//Error Undefined property: stdClass::$videoId (View: C:\Users\derrick\testyoutubeapi\resources\views\search.blade.php)



via Chebli Mohamed

mardi 20 mars 2018

Laravel Queue Mail files

I have been trying to move from directly sending emails, to adding them to Laravel Queue, and I've noticed that if the email contains any files, it does not really like to deal with it.

For example, this example works fine if I was to send the email directly, but it will not if I want to add it to the Queue because it will not serialise the $file variable.

$this->mail->queue('emails.contact-us',compact('data'), function($message) use($files)
    {
        $message->from('email@mail.co.uk', 'Test Subject');
            foreach($files as $file){
                $message->attach($file->getRealPath(),array(
                        'as' => $file->getClientOriginalName(),
                        'mime' => $file->getMimeType()
                ));
            }
    });

If I tried to getFileContents, store all data to a varaible and pass the variable to the Queue, it will create a Job, however instead of the Json payload data that it should produce, it adds 0 to the payload column.

So my question is, has anybody dealt with this situation before? I have thought about adding file temporary, but it does not seem like a good solution.



via Chebli Mohamed

vendredi 16 mars 2018

Laravel Devafactory minify: Ajax Calls do not work after minification

I have a few JS files that are expected to place calls to web server once loaded in client/ browser. To minify, I am using Devafactory/minify package with Laravel 5.1 .

It does good minification of CSS and JS. My question is : However, once JS is minified, it does not place any AJAX call to server. Without minification all calls work fine as expected.

Seeking help!



via Chebli Mohamed