lundi 6 novembre 2017

TokenMismatchException in VerifyCsrfToken.php line

i am using laravel 5.1 its working on localhost but not working on server getting error

TokenMismatchException in VerifyCsrfToken.php line 53:

here is my code link

http://ift.tt/2h7AGai

help me



via Chebli Mohamed

samedi 4 novembre 2017

Cannot upload image in Laravel 5.2

I make input data with an upload image, my code

$name   = $request->input('name');
$images = $request->file('image');
$name_img = $images->getClientOriginalName();
$ext = $images->getClientOriginalExtension();
// Move Uploaded File
$destinationPath = 'img/';
$images->move($destinationPath,$name_img);
$path = $destinationPath.'/'.$name_img;

then put them in array, then insert in database

$data = array(
'name' => $name,
'image' => $path, );
DB::table('daftar')->insert($data);
return json_encode(array('status' =>true));

That code works in Laravel 5.1, but it doesnt work in Laravel 5.2.

Anything wrong with that code for Laravel 5.2?

Thank You. :)



via Chebli Mohamed

vendredi 3 novembre 2017

Maatwebsite/Laravel-Excel issue with more data

im using Maatwebsite/Laravel-Excel for exporting data in a xls format. How ever its not responding for 20000+ records. Download request ended up in response.

There is a known issue in here. They have suggest to chunk the records, but in my case i used .blade files in laravel for generating the xls.

How can i use chunk with .blade?



via Chebli Mohamed

if else statement running like what i need something went wrong in laravel

i have 2 button accept and reject
when i die dump request is coming fine with accept id 2 and reject id 3 but i try to add if statement its bring me only accept skip reject

here is my code

 $interview = Interview::find($request->id);
    $user = Currentuser::where('id', $interview->CompanyID)->first();
    if ($request->Status = '2') {


                 $data = []; // Empty array

                Mail::send('email.useracceptjob', $data, function($message) use ($user){

                    $message->to($user->Email)->subject('Your Job Accepted By user');

                });
             }
             elseif ($request->Status = '3') {


                 $data = []; // Empty array

                Mail::send('email.userrejectjob', $data, function($message) use ($user){

                    $message->to($user->Email)->subject('Your Job Rejected By user');

                });
             }
             else{
                return response()->json(['code' => 500]);
             }

do i doing something wrong? Help me Please



via Chebli Mohamed

jeudi 2 novembre 2017

Laravel: Allow soft deleted models in a hasManyThrough relationship

I have a has many through relationship like this:

class Venue {
    public function orders()
    {
        return $this->hasManyThrough(Order::class, Offer::class);
    }
}

However the Offer model can be soft deleted: http://ift.tt/2iVGxUj

This means the function, will not return any orders that have a soft deleted offer.

How can I allow the function to return orders that have soft deleted offers.

Note that I am using Laravel 5.1 (although solutions in newer versions is appreciated).



via Chebli Mohamed

mercredi 1 novembre 2017

preg_match(): No ending delimiter '/' found Laravel

I'm doing a validation by regex from a request, this validation is to check that the parameter that is sent is an IP.

My rules are as follows:

  <?php

namespace App\Http\Requests\usuarios;

use Illuminate\Foundation\Http\FormRequest;

class storeVPN extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [            
            'segmentwan' => 'http://regex:/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/',
            'segmentlan' => 'http://regex:/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/',

        ];
    }

the debugger shows me that the error is in this line

the debugger shows me that the error is in this line

return preg_match($parameters[0], $value) > 0;

y el error completo es el siguiente

 * @return bool
     */
    public function validateRegex($attribute, $value, $parameters)
    {
        if (! is_string($value) && ! is_numeric($value)) {
            return false;
        }

        $this->requireParameterCount(1, $parameters, 'regex');

        return preg_match($parameters[0], $value) > 0;
    }

    /**
     * Validate that a required attribute exists.
     *
     * @param  string  $attribute
     * @param  mixed   $value
     * @return bool
     */
    public function validateRequired($attribute, $value)
    {
        if (is_null($value)) {
            return false;
        } elseif (is_string($value) && trim($value) === '') {
            return false;
        } elseif ((is_array($value) || $value instanceof Countable) && count($value) < 1) {
            return false;
        } elseif ($value instanceof File) {
            return (string) $value->getPath() !== '';
        }



via Chebli Mohamed

Connection could not be established with host on custom server

i am using laravel 5.1 & i am trying to send email after login but it show me error

Connection Could not be established with host mail.jobnow.com.sg

also try another host like gmail and other still same problem


How can i fix this



via Chebli Mohamed