Viewed   446 times

In laravel for registration I'm using encrypt algorithm for password instead of inbuilt bcrypt function in Laravel because to get password and send it to mail when password is forgot.

But decrypt it is showing a error like

DecryptException The MAC is invalid in Encrypter.php (line 184)

This , when I run this code it is working on local but server itself it is not working below i have mentioned the code , can anyone please help

public function forgotpassword(Request $request)
  $selectemail = User::select('email','password','name')

    $data = array( 'email' => $selectemail->email,'password' => $password , 'name' => $selectemail->name);

    Mail::send('email.resetpassword',$data,function($message) use ($email)
      $message->to([$email])->subject('Forgot Password Letgo');
      echo "Mail has sent successfully";
  } else {
    echo "This email is not yet registered";



The problem is you generated a new APP_KEY, then if you try to decrypt the old encrypted data it will show the DecryptException: The MAC is invalid.

If you want to decrypt the old data you need to restore your old APP_KEY.

After realizing that, now, adding a new problem there, if you stored new data with another APP_KEY or another encryption method you have a problem on the data because they are mixed on the table.

In case you don't know when do you started with the new encrypt method or differentiate the new encrypted entries, the fastest solution would be reset all the passwords with the new encrypt method.

You can learn more about how Laravel encryption works on the official Laravel docs.

Wednesday, September 7, 2022

Make sure to get() the subpages as IlluminateSupportCollection and mapWithKeys() to reformat the results. Use toArray() to provide the format Nova assumes:

private function selectOptions(): array
    $subpages = DB::table('subpages')->get();
    return $subpages->mapWithKeys(function ($subpage) {
        return [$subpage->slug => $subpage->slug];

This is how the returned result should look like:

    'my-article-1' => 'my-article-1',
    'my-article-2' => 'my-article-2',
    'my-article-3' => 'my-article-3',
Thursday, September 1, 2022

The problem is related to browser cache, not Laravel.

To handle browser cache you can use the following code in one of your start files or in a service provider:

App::after(function($request, $response)
    $response->headers->set('Cache-Control','nocache, no-store, max-age=0, must-revalidate');
    $response->headers->set('Expires','Fri, 01 Jan 1990 00:00:00 GMT');

Here we are just modifying each responses within Laravel using application events.

Some people said that this works for all web browser but not for IE. So for IE, you should add a bunch of meta tags to your layout:

<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="cache-control" content="no-store" />
<meta http-equiv="cache-control" content="must-revalidate" />
<meta http-equiv="expires"       content="0" />
<meta http-equiv="expires"       content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma"        content="no-cache" />
Sunday, August 7, 2022

Decode to array and array_combine with the new keys.
Then loop the 'agent' and replace the keys again with array_combine.

$arr = json_decode($json, true);
$mainkeys = ["url", "secret_token", "agent"];
$subkeys = ["id", "quantity"];

$arr = array_combine(array_slice($mainkeys,0,count($arr)), $arr);

    foreach($arr["agent"] as &$val){
        $val = array_combine($subkeys, $val);

array(3) {
  string(26) ""
  string(25) "stringstrinngstringstring"
  array(2) {
    array(2) {
      string(6) "sdsds1"
      string(6) "sdsds1"
    &array(2) {
      string(6) "sdsds1"
      string(6) "sdsds1"
Tuesday, August 23, 2022

You haven't defined the user relationship on Post properly. By default, if you don't explicitly add the related tables, Eloquent will infer the name of the foreign key field from the table name, and the primary key name.

In your case, the relationship table name is user and the primary key of that table you have defined as user_id. Because of this, it assumes the foreign key in your APPLICATIONS table to be user_user_id.

To address this, explicity name your foreign and other table ids in your relationship:

public function user()
    return $this->belongsTo('AppUser', 'user_id', 'user_id');

The second parameter in the above code will be your foreign key on the APPLICATIONS table (since you haven't explicitly said what is meant to be)

Saturday, September 3, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :