dimanche 1 octobre 2017

Can't change MAIL_DRIVER to mailgun in Laravel 5.4

I updated MAIL_DRIVER in .env file of production server. I run these commands also:

php artisan config:clear
php artisan config:cache

However, they did not change MAIL_DRIVER. Server continues to send mail via old MAIL_DRIVER. I got from controller env("MAIL_DRIVER"), and it gets nothing (NULL).

How can I solve this problem.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2yh1sYi
via IFTTT

Laravel DB::raw() not executing query but manual execute works

I am running this query

$query = "update my_cloud set full_dir_url = replace(full_dir_url, '$findWhat', '$replaceWith') where full_dir_url like '$findWhat/%' or where full_dir_url = '$findWhat' ";
DB::raw($query);
echo $query;

Output of echo $query is

update my_cloud set full_dir_url = replace(full_dir_url, '/1st Year/Slide', '/1st Year/Slides') where full_dir_url like '/1st Year/Slide/%' or where full_dir_url = '/1st Year/Slide'

When I run this query in phpmyadmin sql editor, data is updated as expected.

But that DB::raw($query) doesn't update any data. No error log either.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2xP58zb
via IFTTT

Load Current Image to Update in Edit Form (Using Form Binding in Laravel 5.5)

I am trying to load the user current image(Image URL saved in db)in Edit Form... If new image in edit form is not selected i get this error...

Undefined variable: image_path

Here is my update function

 public function update(Request $request,User $user)
    {
        $get_user = Auth::user();
        if(Input::hasFile('image'))
        {
            $user_email = $get_user->email;
            $image = request()->file('image');
            $image_extension = $image->guessClientExtension();
            $image_path = $image->storePubliclyAs('public/uploads/profile_images/images', $user_email . ".{$image_extension}");

        }

        $user->firstname = $request->get('firstname');
        $user->lastname = $request->get('lastname');
        $user->company= $request->get('company');
        $user->address= $request->get('address');
        $user->phone = $request->get('phone');
        $user->country=  $request->get('country');
        $user->zipcode = $request->get('zipcode');
        $user->city = $request->get('city');
        $user->state = $request->get('state');
        $user->skills = $request->get('skills');
        $user->interests = $request->get('interests');
        $user->about = $request->get('about');
        $user->website = $request->get('website');
        $user->image_url = $image_path;
        $user->save();

        $request->session()->flash('message.level', 'success');
        $request->session()->flash('message.content', 'Profile Updated Successfully !');
        return redirect()->route('dashboard');

    }

Please Help and give me a solution to handle a scenerio if user not selected the image in Edit form..



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2ygfOIA
via IFTTT

Laravel image crop

I am trying to make an image cropper using Laravel. I have the following working php code to do that but could anyone please tell me how can I achieve the same using laravel.

        $dst_x = 0;
        $dst_y = 0;

        $top = 15;
        $left = 230;
        $width = 200;
        $height = 200;

        $dst_image = imagecreatetruecolor($width, $height);

        $src_image = imagecreatefromjpeg('public/upload/' . $filename);

        imagecopyresampled($dst_image, $src_image, $dst_x, $dst_y, $left, $top, $width, $height, $width, $height);



        $random_name = rand() . ".jpg";

        imagejpeg($dst_image, 'public/upload' . $random_name);

Thanks in advance for the help



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2g1iXkE
via IFTTT

How can i redirect after i use transaction and throw new \Exception('Error')

How can i redirect after i use transaction and throw new \Exception('Error'); from my code below when i've an error it stop at else{throw new \Exception('Error');} and my if($errors) not working

is their anyway to redirect after throw new \Exception() ?

$errors = false;
    DB::transaction(function () use ($count,$request,$a,$errors) {
        for ($i=0; $i < $count; $i++) {
            $warehouse_products_sell = New Warehouse_products_sell;
            $id_w = $request->input('idw');
            $id_c = $request->get('id_c')[$i];
            $id_p = $request->get('id_p')[$i];
            $qty = $request->input('quantity_box')[$i];
            $price = $request->input('price')[$i];
            $available = $this->check_stock($id_w, $id_p, $qty);
          if($available > 0){

            $warehouse_products_sell->save();
          }else{

            echo "error";
            $errors = true;
            throw new \Exception('Error');
          }
        }
    });
    if ($errors) {
       return redirect('URL');
    }else{
        return 'x';
    }



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2fAqUN2
via IFTTT

Confirm and Cancel Button Laravel Sweet Alert

Good Morning:

I am trying to use plugin Sweet Alert in Laravel. My problem is, I don´t know the way to put a Alert with Cancel Button and Confirm Button in Controller. Reading de documentation, I only found this sentence:

Alert::warning('Are you sure?', 'message')->persistent('Close');

Also, I trying with:

echo 'swal({ title: "Are you sure?", text: "name is available, continue save?", type: "warning", showCancelButton: true, confirmButtonColor:"#DD6B55", confirmButtonText: "Yes, delete it!", closeOnConfirm: false }, function(){});';

But it not working.

How can I use Sweet Alert in my Controller showing a Cancel Button and Confirm Button?

Thanks



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2xGn6EH
via IFTTT

samedi 30 septembre 2017

Laravel 5.5 dusk could not work

I make a new laravel project.

composer create-project laravel/laravel testing_laravel
composer require laravel/dusk --dev 
php artisan serve
php artisan dusk

and then...

PHPUnit 6.3.1 by Sebastian Bergmann and contributors.

F                                                                   1 /         1 (100%)

Time: 1.12 seconds, Memory: 10.00MB

There was 1 failure:

1) Tests\Browser\ExampleTest::testBasicExample
Did not see expected text [Laravel] within element [body].
Failed asserting that false is true.

/Users/nobuhiroharada/work/laracast/testing_laravel/vendor/laravel/dusk/src/Concerns/MakesAssertions.php:274
/Users/nobuhiroharada/work/laracast/testing_laravel/vendor/laravel/dusk/src/Concerns/MakesAssertions.php:245
/Users/nobuhiroharada/work/laracast/testing_laravel/tests/Browser/ExampleTest.php:20
/Users/nobuhiroharada/work/laracast/testing_laravel/vendor/laravel/dusk/src/TestCase.php:92
/Users/nobuhiroharada/work/laracast/testing_laravel/tests/Browser/ExampleTest.php:21

FAILURES!
Tests: 1, Assertions: 1, Failures: 1.

Chrome browser is not lauching.

I am using.. macOS Sierra 10.12.1 localhost

"laravel/framework": "5.5.*", "laravel/dusk": "^2.0"

Google Chrome version: 61.0.3163.100 ChromeDriver 2.31.488774

Thank you very much for your help.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2fAEMqI
via IFTTT