dimanche 20 décembre 2020

Cannot install laravel/socialite package

I'm trying to install Socialite Package getting this error :

Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/DependencyResolver/RuleSetGenerator.php on line 126

I have change changed memory_limit in my php.ini file but facing same issue, any help will be highly appreciated.



via Chebli Mohamed

How to add Laravel scheduled tasks as cronjob on AWS Elastic Beanstalk?

I tried many different solutions that I found but none of them worked! Here are the links that I already tried without any luck:

  1. First
  2. Second
  3. Third
  4. Forth
  5. ..

I need to regularly truncate a table in DB which is used for caching purposes (PHP artisan truncate:cached_stores).

According to the documentation, I created mycron.config in .ebextensions folder in the root directory of my Elastic Beanstalk laravel app with many different contents based on the solutions I found such as the followings:

    files:
    "/etc/cron.d/schedule_run":
        mode: "000644"
        owner: root
        group: root
        content: |
            * * * * * root php /path-to-your-project/artisan schedule:run >> /dev/null 2>&1
commands:
    remove_old_cron:
        command: "rm -f /etc/cron.d/*.bak"

Also this:

    files:
    "/etc/cron.d/mycron":
        mode: "000644"
        owner: root
        group: root
        content: |
            * * * * * root /usr/local/bin/myscript.sh

    "/usr/local/bin/myscript.sh":
        mode: "000755"
        owner: root
        group: root
        content: |
           * * * * * root . /opt/elasticbeanstalk/support/envvars && /usr/bin/php /var/www/html/artisan schedule:run 1>> /dev/null 2>&1

commands:
    remove_old_cron:
        command: "rm -f /etc/cron.d/*.bak"

I appreciate it if you could help me what am I missing?



via Chebli Mohamed

how insert data and show data by location Laravel using the Laravel and jQuery

how insert data and show data by location Laravel using the Laravel and jQuery

how insert data and show data by location Laravel using the Laravel and jQuery



via Chebli Mohamed

samedi 19 décembre 2020

Undefined Variable Request in Laravel 5

I am having issues it says Request is undefined same goes for DB.

public function edit(Request $request,$id) {
        $name = $request->input('stud_name');
        DB::update('update student set name = ? where id = ?',[$name,$id]);
        echo "Record updated successfully.<br/>";
        echo '<a href = "/edit-records">Click Here</a> to go back.';
     }


via Chebli Mohamed

Loop through Categories and its Products in PHP Laravel

I have to create an array with the categories array and its related products i'm fetching category with all related products using this query

  $categoryData= Category::with('product')->get();

Data is beign fetched properly, using this loop to get data in the format given below:

 foreach($categoryData as $row){
            $categoriesData[] = [
                'id' => $row->id,
                'title' =>  $row->title,
            ];
          foreach($row->product as $rowproduct){
            $categoriesData['product_details'][] = [
             'product_name' => $rowproduct->name,
             'product_price' => $rowproduct->price
      ];
}
}

Format (It should be something like this) :

{
    "categoriesData": {
        "0": {
            "id": 1,
            "category_name" : "Name 1",
        "product_details": [
            {
                "id": 1,
                "product_name": Product Name,
            },
        ],
        "1": {
            "id": 2,
            ""category_name" ": "Name 2",
            "product_details": [
            {
                "id": 1,
                "product_name": product name,
            },
        },
      
   

but through present loop all product is getting saved in one array. It is not saving inside category.

Any help is highly appreciated



via Chebli Mohamed

vendredi 18 décembre 2020

Laravel pagination showing duplicate records

I am using laravel pagination in the query i am using order by with a column and the multiple rows has the same value for this column so when i change the page via pagination some records repeats. Is there any solution to fix this problem.



via Chebli Mohamed

not working in laravel

I am displaying images in laravel blade with this method

<img class="docu-image" src="" alt="Second slide">

on localhost it is working fine but on live server it isn't working

When add public in url by inspect element then it shows image .

What could be the reason



via Chebli Mohamed