How to add fields to Blog Page/index.php by Carbon Fields

I am trying to add fields to Blog Page/index.php by Carbon Fields but its not working

carbon.php

Container::make( 'post_meta', __( 'Blog Page Settings','carbon' ) )
        ->where( 'post_template', '=', 'index.php' )

        ->add_tab( __( 'Page Header Section','carbon' ), array(
            Field::make( 'text', 'blog_page_header_title', __( 'Title','carbon' ) )->set_width( 100 ),
            Field::make( 'text', 'blog_page_header_sub_title', __( 'Sub Title','carbon' ) )->set_width( 100 ),
        ) );

index.php

<h4><?php echo esc_html(carbon_get_the_post_meta('blog_page_header_title')); ?></h4>
<h1><?php echo esc_html(carbon_get_the_post_meta('blog_page_header_sub_title')); ?></h1>

Edit Excel Cells then download it with keeping the sheet styles

I have an Excel file that is stored in my server with some Dynamic Data. I want to Edit the Data in The Sheet then Download the Excel with Keeping the sheet format .
I am Already Editing the Data in Excel but I can’t keep the original style of the Sheet.
i am using maatwebsite/excel package with Laravel 8.

my controller code:

        public function generateArtisanalFile(Request $request){
                $lins=new ArtisanalImport();
                $data= Excel::import($lins,public_path('storage/delivered/CI-model.xlsx'));

                $export = new AsrisanalFileGenerator($lins->data);
                return Excel::download($export, 'model.xlsx');
}

The Import Class :

class ArtisanalImport implements ToCollection
  {

    public $data;

    public function collection(Collection $rows)
    {
       $rows[7][1]='karim El Hajjami';
       $rows[3][0]='Delivered';
       $this->data=$rows;
 
     }
   }

this is the Export Class:

class AsrisanalFileGenerator implements FromCollection
 {
   public $data;

   public function __construct($data){
    $this->data=$data;
  
   }

   public function collection()
   {
      return $this->data;
   }

 }

PHP Regex – Delete classes in HTML Tag

I have multiple HTML/CSS sites where I have classes added automatically due to a bug in an earlier version. Therefore my HTML files look currently like this:

<html class=" js cssanimations gecko win js js cssanimations gecko win js js cssanimations gecko win js js cssanimations gecko win js js cssanimations gecko win js js cssanimations gecko win js lang=de><head>

or like this:

<html class=" js cssanimations webkit chrome win js js cssanimations gecko win js js cssanimations webkit chrome win js js cssanimations gecko win js js cssanimations gecko win js js cssanimations gecko win js" lang="de"><head>

So those “phrases” are repeating:

 js cssanimations gecko win js 

or:

 js cssanimations webkit chrome win js 

I would like to write a regex in PHP where I replace those classes with an empty string. Here is what I´ve tried so far but it is not working at all:

private $replaceRegexes = [
    'html-class-attributes' => [
        'regex' => '/<html.*class=".*".*>/',
        'replacement' => '<html lang="de">',
    ]
];

But /<html.*class=".*".*>/ is not working.
Can someone help me out and let me know the correct regex for deleting the classes inside the <html tag?

Would appreciate any help.

Thanks,
Chris

Why create function in RegisterController is not working in laravel

I am new to Laravel. I am using registerController in Laravel to create users . Users data are stored in Users table.

What I have tried is :

    @extends('adminlte::auth.auth-page', ['auth_type' => 'register'])
    
    @php( $login_url = View::getSection('login_url') ?? config('adminlte.login_url', 'login') )
    @php( $register_url = View::getSection('register_url') ?? config('adminlte.register_url', 'register') )
    
    @if (config('adminlte.use_route_url', false))
        @php( $login_url = $login_url ? route($login_url) : '' )
        @php( $register_url = $register_url ? route($register_url) : '' )
    @else
        @php( $login_url = $login_url ? url($login_url) : '' )
        @php( $register_url = $register_url ? url($register_url) : '' )
    @endif
    
    @section('auth_header', __('adminlte::adminlte.register_message'))
    
    @section('auth_body')<!-- comment -->
    <?php $roles = DB::table('roles')->where('id','>',1)->get(); ?>
    <div class="login-form">
        <div class="container">
            <div class="row ">
                <div class="register-box">
                    <div class="register-box-header">
                        <p class="login-box-msg">{{!empty($type) && $type == 'Agronamist' ? 'Buyer' : ''}} REGISTRATION FORM</p>
                    </div>
                    <div class="register-box-body register_body">
                        <form method="POST" action="{{ route('register') }}" class="registerForm" enctype="multipart/form-data">
                            @csrf
                            @if(empty($type))
                            <div class="row">
                                <div class="col-md-12 text-center">
                                    <div class="form-group has-feedback">
                                        <select name="role" class="form-control" onchange='window.location.href=window.location.origin+"/register?role="+$(this).val();' required>
                                            <option value="">Select a Role</option>
                                            @foreach($roles as $role)                                           
                                              <option value="{{$role->id}}" {{(count($_GET)>0 && $_GET['role'] == $role->id) ? 'selected' : ''}}>{{$role->name}}  </option>
                                              @endforeach
                                        </select>
                                    </div>
                                </div>
                            </div>
                            @else
                            <input type="hidden" name="role" value="2">
                            <input type="hidden" name="type" value="{{$type}}">
                            @endif
                            @if(count($_GET)>0 && $_GET['role'] != '')
                                <?php $states = DB::table('states')->orderBy('name','asc')->get();?>
                                <div class="row">
                                    <div class="col-md-6">
                                        <div class="form-group has-feedback">
                                            <input type="text" class="form-control" placeholder="First Name *" name="first_name" value="{{ old('first_name') }}" required>
                                            <span class="glyphicon glyphicon-user form-control-feedback"></span>
                                        </div>
                                    </div>
                                    <div class="col-md-6">
                                        <div class="form-group has-feedback">
                                            <input type="text" class="form-control" placeholder="Last Name *" name="last_name" value="{{ old('last_name') }}" required>
                                            <span class="glyphicon glyphicon-user form-control-feedback"></span>
                                        </div>
                                    </div>
                                    <div class="col-md-6">
                                        <div class="form-group has-feedback">
                                            <input type="email" class="form-control" name="email" value="{{ old('email') }}" placeholder="Email *" required>
                                            <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
                                        </div>
                                    </div>
                                    <div class="col-md-6">
                                        <div class="form-group has-feedback">
                                            <input type="text" class="form-control phoneMask" placeholder="Phone *" name="phone" value="{{ old('phone') }}" required>
                                            <span class="glyphicon glyphicon-phone form-control-feedback"></span>
                                        </div>
                                    </div>
    <div class="col-md-6">
                                        <div class="form-group has-feedback">
                                            <input type="text" class="form-control" placeholder="Address *" name="address" value="{{ old('address') }}" required>
                                            <span class="glyphicon glyphicon-map-marker form-control-feedback"></span>
                                        </div>
                                    </div>
     <div class="col-md-6">
                                        <div class="form-group has-feedback">
                                            <input type="password" class="form-control @error('password') is-invalid @enderror" name="password" placeholder="Password *" required autocomplete="new-password">
                                            <span class="glyphicon glyphicon-lock form-control-feedback"></span>
                                            @error('password')
                                                <span class="invalid-feedback" role="alert">
                                                    <strong>{{ $message }}</strong>
                                                </span>
                                            @enderror
                                        </div>
                                    </div>
                                    <div class="col-md-6">
                                        <div class="form-group has-feedback">
                                            <input type="password" class="form-control" name="password_confirmation" placeholder="Retype password *" required autocomplete="new-password">
                                            <span class="glyphicon glyphicon-log-in form-control-feedback"></span>
                                        </div>
                                    </div>
 <div class="row">
                                <div class="col-md-3 col-xs-offset-4 submit_btn">
                                  <button type="submit" class="btn btn-primary btn-block btn-flat">Register</button>
                                </div>
                            </div>
</form>


Register Controller
<?php

namespace AppHttpControllersAuth;

use IlluminateHttpRequest;
use IlluminateAuthEventsRegistered;
use AppHttpControllersController;
use IlluminateDatabaseEloquentBuilder;
use AppUser,AppUserDetails,AppUserRoles,AppUserAddresses, Appmanager_group;
use IlluminateFoundationAuthRegistersUsers;
use IlluminateSupportFacadesHash;
use IlluminateSupportFacadesValidator;
use CarbonCarbon;
use Auth;
use DB;
class RegisterController extends Controller
{
    

    use RegistersUsers;

    
    protected $redirectTo = '/';

    
    public function __construct()
    {
        //$this->middleware('guest');
    }

    
    public function register(Request $request){       
        
       
        
        $this->validator($request->all())->validate();
       // dd($this->validator($request->all())->validate());
                event(new Registered($user = $this->create($request->all())));
              
                if(array_key_exists('type', $request->all())){
                   
                    return $this->registered($request, $user) ? : redirect('/buyersList/'.Auth::user()->id)->with('success','Registered successfully.');
                }else{
                  
                    return $this->registered($request, $user) ? : redirect($this->redirectPath())->with('success','Registered successfully. Please wait for the approval to access your account.');
                }
    }
      
                //$this->guard()->login($user);
    

    protected function validator(array $data)
    {
       
        return Validator::make($data, [
            'first_name' => ['required', 'string', 'max:255'],
            'last_name' => ['required', 'string', 'max:255'],
            'phone' => ['required', 'string', 'max:255'],
            'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], 
            'password' => ['required', 'string', 'min:8', 'confirmed'],
        ]);
            }

    /**
     * Create a new user instance after a valid registration.
     *
     * @param  array  $data
     * @return AppUser
     */
    protected function create(array $data)
    {
         $user = User::create([
            'first_name' => $data['first_name'],
            'last_name' => $data['last_name'],
            'phone' => $data['phone'],
            'email' => $data['email'],
            'password' => Hash::make($data['password']),
        ]);
        
        
       
}
}

My data is not inserting to users table,and the create function is not working when I dd($user) it. How to make my code working. What my page shows when I try to submit data is :

Output

php append pdf to pdf and check the page template first

i have a form where people can upload pdfs

with fpdf I append those pdf and generate a new one.
this works ok, unless someone uploads a vertical aligned pdf.
is there a way I can determine which alignment a pdf has?
this is my code to append:

/* APPEND PDFs */
    $files = [];
    array_push($files, $upload_folder . '/' . $pdf_name);
    if($new_path != 0 & $ext == 'pdf'){
        array_push($files, $new_path);
    }
    if($new_path1 != 0  & $ext1 == 'pdf'){
        array_push($files, $new_path1);
    }
    if($new_path2 != 0  & $ext2 == 'pdf'){
        array_push($files, $new_path2);
    }
    if($new_path3 != 0  & $ext3 == 'pdf'){
        array_push($files, $new_path3);
    }
    if($new_path4 != 0  & $ext4 == 'pdf'){
        array_push($files, $new_path4);
    }
    if($new_path5 != 0 & $ext5 == 'pdf'){
        array_push($files, $new_path5);
    }
    if($new_path6 != 0  & $ext6 == 'pdf'){
        array_push($files, $new_path6);
    }

pdf = new setasignFpdiFpdi();

// iterate over array of files and merge
foreach ($files as $file) {
    $pageCount = $pdf->setSourceFile($file);
    for ($i = 0; $i < $pageCount; $i++) {
        $tpl = $pdf->importPage($i + 1, '/MediaBox');
        $pdf->addPage();
        $pdf->useTemplate($tpl);
    }
}

// output the pdf as a file (http://www.fpdf.org/en/doc/output.htm)
$pdf->Output('F',$upload_folder . '/' . $pdf_name);

thanks a lot

shortcode for product tags description in WooCommerce

I am looking for a way to call the product tags description as a shortcode which could then be added in page builder like elementor. hope to get help here to solve my problem.

I found this snippet but it shows on shop page not on product tag pages

add_action( 'woocommerce_after_shop_loop_item', woocommerce_product_loop_tags', 5 );

function woocommerce_product_loop_tags() {

global $post, $product;

$tag_count = sizeof( get_the_terms( $post->ID, 'product_tag' ) );

echo $product->get_tags( ', ', '<span class="tagged_as">' . _n( 'Tag:', 'Tags:', $tag_count, 'woocommerce' ) . ' ', '.</span>' );
}

Foreign keys not saved when trying to store data Laravel 8

I am trying to store store an author and genre into a Book. The way I’m trying to achieve this is by having an Author table, Genre table and a Book table. I want to store the foreign key for the author and genre into the books table.

I have created a form to store the needed information for the book. Within the form, there are two select tags and within them I loop through the authors and genres array. I use a store function in my BookController to validate the data that is being sent. After the validation, I store a new Book.

However, the foreign keys are not being stored in the database except for the primary key, title, blurb and timestamps.

Book Model

class Book extends Model
{
    use HasFactory;

    protected $fillable = [
        'author_id',
        'genre_id',
        'title',
        'blurb',
    ];

    public function authors()
    {
        return $this->BelongsTo(Author::class);
    }

    public function genres()
    {
        return $this->BelongsTo(Genre::class);
    }
}

Author Model

class Author extends Model
{
    use HasFactory;

    protected $fillable = [
      'name',
    ];

    public function book()
    {
        return $this->hasMany(Book::class);
    }
}

Genre Model

class Genre extends Model
{
    use HasFactory;

    protected $fillable = [
        'title'
    ];

    public function book()
    {
        return $this->hasMany(Book::class);
    }
}

BookController create()

    public function create()
    {
        $authors = Author::all();
        $genres = Genre::all();

        return view('admin.book.create', ['authors' => $authors, 'genres' => $genres]);
    }

BookController store()

    public function store(Request $request)
    {
        $validatedData = $request->validate([
            'title' => 'required|max:255',
            'authors' => 'required|array',
            'genres' => 'required|array',
            'blurb' => 'required',
        ]);

        Book::create($validatedData);

        return redirect()->route('admin.book.create');
    }

Books table migration

    public function up()
    {
        Schema::create('books', function (Blueprint $table) {
            $table->id();
            $table->foreignId('author_id');
            $table->foreignId('genre_id');
            $table->string('title');
            $table->string('blurb');
            $table->timestamps();
        });
    }

create.blade.php (create Book page)

    <div class="flex justify-center">
        <div class="flex justify-center border lg:w-1/4">
            <div class="flex flex-col justify-center lg:w-2/4 gap-2">
                <form action="{{ route('admin.book.store') }}" method="post">
                    @csrf
                    <div class="mb-2">
                        <h1 class="text-xl">Add Book</h1>
                    </div>
                    <div>
                        <label class="" for="title">Title</label>
                        <input name="title" class="w-10 border border-gray-400 w-full py-1 px-2" type="text">
                    </div>
                    <div>
                        <label class="" for="author">Author</label>
                        <select name="authors[]">
                            @foreach($authors as $author)
                                <option value="{{ $author->id }}">{{ $author->name }}</option>
                            @endforeach
                        </select>
                    </div>
                    <div>
                        <label class="" for="genre">Genre</label>
                        <select name="genres[]">
                            @foreach($genres as $genre)
                                <option value="{{ $genre->id }}">{{ $genre->title }}</option>
                            @endforeach
                        </select>
                    </div>
                    <div>
                        <label class="" for="blurb">Blurb</label>
                        <textarea name="blurb" id="" cols="18" rows="10"></textarea>
                    </div>
                    <div>
                        <button class="py-2 px-4 border" type="submit">Save</button>
                    </div>
                </form>
            </div>

        </div>
    </div>

Auto import booking.com not working motopress

i have a problem with sync callendar in plugin motopress booking with bookin.com.
Automatic import works very well on the plugin, however it does not automatically import the booking.com calendar
Is it possible to perform an automatic import?

How to return only English value data from JSON

Ihave these data in json format i want to get only Engish value Data seperate. Like only need english data: (Center Bore (mm) : 66.6, Offset (mm) : 45, OEM Compatible : Yes).

I also try to decode data and seperate all data friquently but not get perfact result.

attributes: [
            {
                "thibertPartNumber": "081019",
                "attributeID": "ID_114",
                "attributeNames": [
                    {
                        "languageCode": "EN",
                        "localizedValue": "Center Bore (mm)"
                    },
                    {
                        "languageCode": "FR",
                        "localizedValue": "Alésage (mm)"
                    }
                ],
                "attributeValues": [
                    {
                        "languageCode": "EN",
                        "localizedValue": "66.6"
                    },
                    {
                        "languageCode": "FR",
                        "localizedValue": "66.6"
                    }
                ]
            },
            {
                "thibertPartNumber": "081019",
                "attributeID": "ID_115",
                "attributeNames": [
                    {
                        "languageCode": "EN",
                        "localizedValue": "Offset (mm)"
                    },
                    {
                        "languageCode": "FR",
                        "localizedValue": "Décalage (mm)"
                    }
                ],
                "attributeValues": [
                    {
                        "languageCode": "EN",
                        "localizedValue": "45"
                    },
                    {
                        "languageCode": "FR",
                        "localizedValue": "45"
                    }
                ]
            },
            {
                "thibertPartNumber": "081019",
                "attributeID": "ID_122",
                "attributeNames": [
                    {
                        "languageCode": "EN",
                        "localizedValue": "OEM Compatible"
                    },
                    {
                        "languageCode": "FR",
                        "localizedValue": "EOM Compatible"
                    }
                ],
                "attributeValues": [
                    {
                        "languageCode": "EN",
                        "localizedValue": "Yes"
                    },
                    {
                        "languageCode": "FR",
                        "localizedValue": "Oui"
                    }
                ]
            },
] 

And i want output to be:

Center Bore (mm) : 66.6
Offset (mm) : 45
OEM Compatible : Yes

Forwarding to profileurl

I use WordPress / Peepso / Buddypress. I want to build a redirect on the user profile.

example domain.tld / redirect

Now I need a PHP code that reads the profilurl and then redirects the user to the profile.

I have this piece of code

<? php echo $ user-> get_profileurl ();?>

anyone any idea? Thanks!