dimanche 3 janvier 2021

How to fetch distinct record From second table in left join

I have three table A,B,C And Structure Is Shown Below

                    Table A
              ----------------------
              |id | text_message   |
              ----------------------
              |1  | first Message  |
              ----------------------
              |2  | second Message |
              ----------------------

                    Table B
           -----------------------------------
           |id  | request_id | approved_status|
           ------------------------------------
           |101 |  1         |    2           |
           ------------------------------------
           |102 |   1        |     1          |
           ------------------------------------
           |103 |   2        |      2         |
           -------------------------------------
           |104 |   2         |     2          |
           -------------------------------------

                       Table C
           --------------------------------------
           |id   |  request_id | approved_status |
           ---------------------------------------
           | 501 |    1        |   1              |
           ----------------------------------------
           |502  |    2        |   2              |
           -----------------------------------------

1)Table B request_id column is foreign key reference Table A id column

2)Table C request_id column is foreign key reference Table A id column

3)Table A has one to many relationship with Table B

4)Table A has one to one relationship with Table C

My question is Below

How to write eloquent query so that We can get all record from Table A and Table C and distinct record i.e distinct request_id from Table B



via Chebli Mohamed

samedi 2 janvier 2021

How to fetch record from Table A which has not any approved status true on Table B

I have three table A , B and C and it structure is shown below

            Table A                        
   ----------------------------         
   | id | Text_message_to_show|
   ----------------------------
   | 1  | first demo message  |
   ----------------------------
   | 2  | second demo message |
   ----------------------------


               Table B
   ------------------------------------
   | id | request_id  | approved_status |        
   ------------------------------------
   | 101  |   1      |       2        |
   ------------------------------------
   | 102  |   1      |       1        |
   ------------------------------------ 
   | 103  |   2      |       2        |
   ------------------------------------ 
   | 104  |   2      |       2        |
   ------------------------------------   

                Table c
   ------------------------------------
   | id | request_id  | approved_status |        
   ------------------------------------
   | 501  |   1      |       2        |
   ------------------------------------
   | 502  |   2      |       1        |
   ------------------------------------  
  
   

Table B and Table C has foreign key request_id column which is reference id column of table A.Table Table A-> Table B has one to many relaionship and Table A->Table C has one to one relationship Now I have question is how to wrie sql query such that to fetch Table A record where no approved_status for request_id should be 2 in Table B And also Table C approved_status should not be 2



via Chebli Mohamed

file upload validation in Laravel

I use a javascript code to upload multiple files on the server. the problem is that when I upload multiple files with 10 MByte size and the server storage only has space for 5 Mbyte then some of the files will upload and some not. I want to send the response name of uploaded files and not uploaded files. I use the code below and it only throws an exception StorageLimit. This is function in Model Class Post:

  public function newcmspost(Request $request){
        $names = [];
        $paths ="succes";
        $erpaths = "error";
        $index = 0;
        foreach ($request->file('files') as $file){
            $names[$index] = $file->getFilename();
            try{
                $paths = $paths."/ ". $file->store('public/images');

            }catch (Exception $e){
                $erpaths = $paths."/".$file->getFilename();
            }
        }
        return response("long responce".$paths);
    }

1 - I want a response like:

error : filename1\ .... success : filenamesucess1 \ ...

2 - and also I want to prevent default throw error on StorageLimit. thank you all.



via Chebli Mohamed

How to access function value in another function in PHP Classes

How can i return a variable value from one function and pass it to another function in a class and access it ?, im new to php class.

here is the code i have tried

<?php
class BioTool{
public function one(){
$lol =[2,3,5]; print_r($lol);
}
 public function two(){
     $newarr=$this->one(); //this only return the array but i can't access it, check below.
    print_r($newarr[0]); //not working
}
}

$biotool=new BioTool();
$biotool->two();


via Chebli Mohamed

Laravel 5.4 update

I have an existing application developed using laravel and wanted to update it from laravel 5.4 to laravel 7 or 8 , How can I do that ? Is it the only way to do it step by step 5.4 to 5.5, 5.5 to 5.6, 5.6 to 5.7 and so on

Or is there any easiest way of doing ?



via Chebli Mohamed

vendredi 1 janvier 2021

I want developed a scorm player in laravel

I am working on developing a Scorm player. Scorm support 2004 and 1.2 and file support mp4, pdf, ppt, and html. I am looking for a Laravel equivalent of Moodle Scorm.



via Chebli Mohamed

How to get url value Passing From Laravel Route to php file?

I have an laravel application and also included an php file for a Payment Package,im Passing two url parameters from my laravel route to this Php File .How can i access the passed url parameters in this Php file.

Route::get('payumoneypayment/{courseid}/{userid}', function() {
    include_once(app_path() . '/payu/index.php');  
  });

The route passed from laravel is like this eg http://127.0.0.1:8000/payumoneypayment/1152/44 In my index.php file ,i tried using $userid = $_REQUEST['userid']; but im not getting the request value in php file



via Chebli Mohamed