mardi 28 février 2017

Call to undefined function bzdecompress PHP

I have an Ubuntu 16.04 server with PHP7 + nginx running. I already have a project in PHP Laravel 5.1 running in my local enviroment (Windows with Xampp) and everything is running great. I have a PHP script that uses the function bzdecompress of Bzip2 but then, in the server just crash and show this message:

Call to undefined function App\Http\Controllers\bzdecompress() 

I don't see instructions of how install this library (if needed) or how to load it or check at least that is loaded. Thank you very much!



via Chebli Mohamed

how i display image when i uplaod it using this code in laravel 5.1

I store imagepath in database like this http://localhost/shopping/public/src/img/46.png

my code :
     $imageName = $product->id . '.' . 
            $request->file('image')->getClientOriginalExtension();
            $request->file('image')->move(public_path('src/img/'.$imageName));
            $product->imagePath=$imagepath;
            $product->save();



via Chebli Mohamed

unable to create directory in laravel 5.1 when upload image?

Error : Unable to create the "http:/localhost/shopping/public/src/img/" directory

my code :
$imageName = $product->id . '.' . 
        $request->file('image')->getClientOriginalExtension();
                $request->file('image')->move(
        url().'/public/src/img/', $imageName
        );



via Chebli Mohamed

ModelNotFoundException in Builder.php line 129: No query results for model [Fully\Models\Package]

I am having trouble calling a controller and routing.

My route:

Route::group(array('prefix' => LaravelLocalization::getCurrentLocale()), function () {

Route::group(array('prefix' => '/admin',
                   'namespace' => 'Admin',
                   'middleware' => ['before', 'sentinel.auth', 'sentinel.permission'] ), function () { // auth = stop directly accessing admin


//      PACKAGE

    Route::resource('package', 'PackageController', array('before' => 'hasAccess:package'));
    Route::get('package/{id}/delete', array('as' => 'admin.package.delete',
        'uses' => 'PackageController@confirmDestroy', ))->where('id', '\d+');

My controller:

class PackageController extends Controller
{
protected $package;
protected $packageCategory;
protected $activity;
protected $destination;
protected $perPage;

public function __construct(PackageInterface $package, PackageCategoryInterface $packageCategory, ActivityInterface $activity, DestinationInterface $destination)
{
    //codes

}

public function index()
{
    //index codes
}

public function suggested()
{

    return view('backend.package.suggested');
}

My menu.blade.php

<a href=""> View all packages</a>
<a href=""> Add new package</a>   
<a href=""> Suggested package</a>

What I am trying to achieve: In the controller i created a new function suggested, which should return a view when the link is clicked in the menu.blade.php. However when I click on the link the url in the browser shows localhost/en/admin/package/suggested but at no veil throws an exception error as described above. I want to know if i can create a new function in the controller and call it or not? How do I make this run ?



via Chebli Mohamed

lundi 27 février 2017

Sending mail error in laravel 5.1

i am trying to send email in laravel 5.1 but it give me folloiwng error.

Swift_TransportException in AbstractSmtpTransport.php line 383: Expected response code 250 but got code "530", with message "530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://ift.tt/2dX5gUh o1sm938569pgf.63 - gsmtp "

i have tried 2-Step verification and http://ift.tt/1oME4BN also trun on. But still getting the error

anyone can help me for that?



via Chebli Mohamed

Query if a relationship exists with conditions in Laravel

I have a model Foo that contains a hasMany relationship to Bar.

I have a query similar to the following:

$r = Foo::with(['bar' => function($query) {
    $query->where('someProp', '=', 10);
})->get()

However, I want to only return the Foo object if item has a Bar object that satisfies the query.

I'm aware that you can do something like this:

$r = Foo::has('bar')
    ->with(['bar' => function($query) {
        $query->where('someProp', '=', 10);
    })->get();

But that checks if any bar items exists. Not if a bar item exists with someProp = 10

How can I do this?



via Chebli Mohamed

Run a raw SQL statement to rename an index in a Laravel migration

I want to run the following raw SQL statement in a Laravel migration:

RENAME INDEX offer_venue_id_fk_idx TO offers_venue_id_index

How can I do this?



via Chebli Mohamed