Posts

foreach inside another foreach

  public function viewAbstract ( ) {  // Retrieve all abstracts associated with the authenticated user $abstracts = Paper :: where ( 'user_id' , auth ()-> user ()->id)-> get ();  // Preprocess authors $authors = Author :: whereIn ( 'paper_id' , $abstracts -> pluck ( 'id' ))-> get ()-> groupBy ( 'paper_id' );  // Pass both abstracts and authors to the view   return view ( 'paper.view_abstracts' , compact ( 'abstracts' , 'authors' )); } Retrieve Abstracts : We retrieve all abstracts associated with the authenticated user from the papers table using Eloquent ORM. The where('user_id', auth()->user()->id) condition filters the abstracts by the user's ID. Preprocess Authors : We preprocess the authors associated with the retrieved abstracts. First, we extract the IDs of the abstracts using $abstracts->pluck('id') . Then, we use whereIn('paper_id', ...) to retrieve ...

migrate single file laravel

  Migrate php artisan migrate --path=/database/migrations/fileName.php Roolback php artisan migrate:rollback --path=/database/migrations/fileName.php Refresh php artisan migrate:refresh --path=/database/migrations/fileName.php Seeder php artisan db:seed --class=classNameTableSeeder

Install Multi version of php on ubuntu

  sudo apt-get install software-properties-common -y sudo add-apt-repository ppa:ondrej/php   [ Ondrej for insatlling multiple php versions] sudo apt-get update -y sudo apt-get install php7.2 php7.2-fpm php7.2-mysql libapache2-mod-php7.2  libapache2-mod -fcgid  -y sudo apt-get install php8.1 php8.1-fpm php8.1-mysql libapache2-mod-php8.1    -y libapache2-mod -fcgid  only once if its already installed no need a2enconf php8.2-fpm to make default add in etc/apache2/sites-avialble ---- .conf <FilesMatch \.php$> # For Apache version 2.4.10 and above, use SetHandler to run PHP as a fastCGI process server SetHandler "proxy:unix:/run/php/ php8.1 -fpm.sock|fcgi://localhost" </FilesMatch>   call to undefined function mb_strcut() laravel install php8.2-mbstring 

How to fix Error: laravel.log could not be opened?

  sudo chown -R $USER:www-data storage chmod -R 775 storage

mysql error in linux

  could not find driver (Connection: mysql, SQL: select table_name as `name`,   php -m | grep PDO   sudo apt-get install php-mysql # For Ubuntu/Debian sudo yum install php-mysql # For CentOS/Fedora    

Install latest node on unbuntu

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash   source ~/.bashrc   nvm list-remote   nvm install v16.14.0