mercredi 24 juin 2020

why is not find user email to database?

public function create(Request $request){

$this->validate($request, [
 'email' => 'required|email',

]);

   $user = user::where('email',$request->email)->first();      
     if ($user)
   return response()->json([
       'message' => 'We can not find a user with that e-mail address.'
   ], 404);
   
   
   $passwordReset = PasswordReset::updateOrCreate(
  
   [
        //'email' =>$user->email,
        'email'=>$request->email,
        'token' => str_random(60)
    ]
   
);

if ($user && $passwordReset)
$user->notify(
    new PasswordResetRequest($passwordReset->token)
);       
 return response()->json([
'message' => 'We have e-mailed your password reset link!'

]);

}



via Chebli Mohamed

Permission problems with Laravel's storage directory on CentOS 7. Changing permissions and ownship with chmod and chown does not solve it

I figured this out myself while I was revising my question, but I'm going to post my original question anyway with the solution in case it helps anyone else.

The solution has nothing to do with symbolic links or Deployer, but I'm going to leave my question as is in case someone came to the same problem in a similar way.


I'm trying to set up a Laravel 5.8 deployment using Deployer on a CentOS 7 server.

The deployment is successful. The storage folder is set as a shared directory in my deploy.php file, so what it does it sets up the storage folder as a persistent shared folder between releases. It does this by creating a symbolic link to a shared storage folder for the releases.

There is a folder for the current release at /var/www/test-laravel/current, which is actually a symbolic link to the folder with the most recent release (in this case /var/www/test-laravel/releases/18). Inside that folder the storage folder is actually a symbolic link to /var/www/test-laravel/shared/storage.

I was getting the following error,

The stream or file "/var/www/test-laravel/releases/18/storage/logs/laravel-2020-06-25.log" could not be opened: failed to open stream: Permission denied

After trying a few variations of permissions/owners/groups, out of frustration I manually ran chmod -R 777 and chown -R apache.apache on not just the original storage folder but on all of the symlink folders as well.

This hasn't changed anything at all. I'm still getting the same error.

I don't think this should make a difference, but just for good measure I've run php artisan cache:clear, php artisan view:clear and php artisan config:clear.



via Chebli Mohamed

Laravel remove pending migration execution

I have two Laravel apps that use the same database. I moved migrations from app 1 to app 2. Now I want to remove the pending migrations from app 2 due to that I moved the migrations files to it and tables exists in database.

Is any way to remove them from pending execution when php artisan migrate is executed?

Regards



via Chebli Mohamed

laravel eger loading not working properly when i use limit or take in whereIn

helllo my code is

$all_5_post = wp_terms::with(['wp_posts' => function ($query) {
                                      $query->orderBy('id', 'desc')->take(5);
                                }])->whereIn('id',[3,4,6,9])->get();

getting relationship data in 3 id but 4,6,9 relationship data getting empty but when i only use WHERE elequent and doing multiple query for same 3,4,6,9 id it showing 5 relationship table data in each what i have to do now i need a solution.



via Chebli Mohamed

how to store the select value of select box for search

Dear Stackoverflow team! i want to make the search condition with form like picture attachment. i want to store the select box value after form submit to search with multiple condition. so could the the team help make solution for it. below is my model filter condition, it's laravel code

public function scopeFilterInProfile($query, Request $request)
{
    $query = Property::where('user_id',auth()->user()->id)
                    ->published()
                    ->expired();
    if ($request->input('category')) {
        $query->where('parent_id', $request->input('category'));
    }
    if ($request->input('location')) {
        $query->where('province_id', '=', $request->input('location'));
    }
    if ($request->input('search')) {
        $query->where('title', 'LIKE', '%'.$request->input('search').'%');
    }
    if ($request->input('from_price') && $request->input('to_price')) {
        $query->whereBetween('price', [$request->input('from_price'),$request->input('to_price')]);
}
    if ($request->input('sort')) {
        switch ($request->input('sort')){
            case 'posted_date_desc':
                $query->orderBy('created_at', 'DESC');
                    break;
            case 'posted_date_asc':
                $query->orderBy('created_at', 'ASC');
                    break;
            case 'renew_date_desc':
                $query->orderBy('renew_date', 'DESC');
                    break;
            case 'renew_date_asc':
                $query->orderBy('renew_date', 'ASC');
                    break;
            case 'price_desc':
                    $query->orderBy('price', 'DESC');
                    break;
            case 'price_asc':
                $query->orderBy('price', 'ASC');
                    break;
            default:
                $query->orderBy('posted_date_desc', 'DESC');
        }
    }
    return $query;
}

myform search picture



via Chebli Mohamed

I got symfony/translation errors installing laravel 5 on remote server

Uploading my laravel 5 app on ubuntu under Digital Ocean server I got error in the browser:

Declaration of Symfony\Component\Translation\TranslatorInterface::setLocale($locale) must be compatible with Symfony\Contracts\Translation\LocaleAwareInterface::setLocale(string $locale)

Googling for decision I found that the error could need symfony/translation installation and I tried to install it locally on my kubuntu 18 and got error :

$ composer require symfony/translation                                     
Using version ^5.1 for symfony/translation
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install symfony/translation v5.1.2
    - Conclusion: don't install symfony/translation v5.1.1
    - Conclusion: don't install symfony/translation v5.1.0
    - Conclusion: don't install symfony/translation v5.1.0-RC2
    - Conclusion: don't install symfony/translation v5.1.0-RC1
    - Conclusion: don't install symfony/translation v5.1.0-BETA1
    - Conclusion: don't install symfony/translation 5.2.x-dev
    - symfony/translation 5.1.x-dev conflicts with symfony/http-kernel[v4.4.9].
    - symfony/translation 5.1.x-dev conflicts with symfony/http-kernel[v4.4.9].
    - Installation request for symfony/translation ^5.1 -> satisfiable by symfony/translation[5.1.x-dev, 5.2.x-dev, v5.1.0, v5.1.0-BETA1, v5.1.0-RC1, v5.1.0-RC2, v5.1.1, v5.1.2].
    - Installation request for symfony/http-kernel (locked at v4.4.9) -> satisfiable by symfony/http-kernel[v4.4.9].

My local composer.json :

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^7.1.3",
        "arrilot/laravel-widgets": "^3.13",
        "doctrine/dbal": "^2.9",
        "fideloper/proxy": "^4.0",
        "laravel/framework": "5.7.*",
        "laravel/tinker": "^1.0",
        "mews/purifier": "^2.1",
        "phpoffice/phpspreadsheet": "^1.6",
        "proengsoft/laravel-jsvalidation": ">2.2.0",
        "s-ichikawa/laravel-sendgrid-driver": "^2.0",
        "spatie/browsershot": "^3.37",
        "spipu/html2pdf": "^5.2",
        "yajra/laravel-datatables-oracle": "~8.0"
    },
    "require-dev": {
        "beyondcode/laravel-dump-server": "^1.0",
        "filp/whoops": "^2.0",
        "fzaninotto/faker": "^1.4",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^2.0",
        "phpunit/phpunit": "^7.0"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    }
}

How this can be salved ? Thanks!



via Chebli Mohamed

Laravel Api and Web Authentication At Same Time

i'm building cross-platform app so i have website and mobile app. also I've Authentication part for both website and app.

and i'm using Laravel As backend. For auth i found something called "Auth Guards" and there are two default Auth guard in Laravel, one for web and other for API.

But i'm a bit confused cause i found that you can't use both Auth Guards at the same time.

So, is there any way to build authentication system based in one Database Table For Website an Mobile.

NOTE i need any solution except Firebase Auth



via Chebli Mohamed