mardi 31 janvier 2023

Trying to get property 'emp_access_level' of non object [closed]

At this line of code:

@if(Auth::user()->employee->emp_access_level == 1)
<a class="linker list-group-item list-group-item-action  border-right-0 "
   href="">
   <i class="fas fa-home"></i>
   <span>Firm Home</span>
</a>

enter image description here

I am writing code for 2 factor authentication but ran into this issue of trying to get property 'emp_access_level' of non-object.

I have defined the emp-access-level here:

Schema::create('employees', function (Blueprint $table) {
     $table->increments('id');
     $table->integer('emp_org_id')->unsigned()->nullable();
     $table->integer('emp_user_id')->unsigned()->unique()->nullable();
     $table->string('emp_notes')->nullable();
     $table->boolean('emp_status')->nullable();   //false: not allowed true:allowed
     $table->string('emp_leave_date')->nullable();
     $table->string('emp_access_level')->nullable();
     $table->foreign('emp_user_id')->references('id')->on('users');
     $table->foreign('emp_org_id')->references('id')->on('organizations');
     $table->timestamps();
});


via Chebli Mohamed

how to solve problem ? Failed to download laravel/laravel from dist

Creating a "laravel/laravel" project at "./store" Info from https://repo.packagist.org: #StandWithUkraine Installing laravel/laravel (v9.5.1)

Failed to download laravel/laravel from dist: The zip extension and unzip/7z commands are both missing, skipping.

The php.ini used by your command-line PHP is: C:\xampp\php\php.ini Now trying to download from source

In GitDownloader.php line 82:

git was not found in your PATH, skipping source download

composer create-project laravel/laravel store



via Chebli Mohamed

lundi 30 janvier 2023

Laravel - How to get all product ids and quantity in a current cart?

How to get all product ids and quantity in a current cart? I learned that i can get the total sum with , but can someone help me how to get the product id's and quantity.

I need to fill this with correct data:

contents: [
      {
        id: ''',
        quantity: X
      },
      {
        id: ''',
        quantity: X
      }],

Thank you. Keep in mind that i'm not a programmer, but i have to find a way to do it :) Laravel 5.2.

I tried everything that i saw in google.



via Chebli Mohamed

How to change dynamically APP_KEY in config/app.php in laravel

basically i want to give different different APP_KEY to different different user so, when i try to do this they give fatal error

    /*
    |--------------------------------------------------------------------------
    | Encryption Key
    |--------------------------------------------------------------------------
    |
    | This key is used by the Illuminate encrypter service and should be set
    | to a random, 32 character string, otherwise these encrypted strings
    | will not be safe. Please do this before deploying an application!
    |
    */

    'key' => Auth::User()->APP_KEY

    'cipher' => 'AES-256-CBC',


via Chebli Mohamed

vendredi 27 janvier 2023

When i am trying to close my collape the automatci open again and again

enter image description here

When I am trying to close my collapse the automatic opens again and again enter image description here

 <div class="portlet box purple ">
                    <div class="portlet-title">
                        <div class="caption">
                            <i class="fa fa-gift"></i> Advance Search </div>
                        <div class="tools">
                            <a href="" class="<?= isset($_GET['advanceSearch']) ? "expand" : "collapse"  ?>"><i class="icon-collapse"></i></a>
                        </div>
                    </div>
                    <div class="portlet-body form" >
                        {!! Form::open(['method'=>'GET','url'=>route('users.index'),'class'=>'form-horizontal','role'=>'search'])  !!}
                        <div class="form-body">

                            <div class="row"> 
                                <div class="col-md-4">
                                    <div class="form-group">                           
                                        <div class="col-md-12">                         
                                        <label>First Name<span class="required"></span></label>
                                        {!! Form::text('first_name', null, array('placeholder' => 'First Name','class' => 'form-control')) !!}

                                        
                                        </div>
                                    </div>                          
                                </div>

                              

                                <div class="col-md-4">
                                    <div class="form-group">                           
                                        <div class="col-md-12">                         
                                        <label>Email<span class="required"></span></label>
                                         {!! Form::text('email', \Request::get('email'), array('placeholder' => 'Email','class' => 'form-control')) !!}
                                        
                                        </div>
                                    </div>                          
                                </div>

                            <div class="clearfix"></div>
                            <div class="form-actions" style="text-align: center">
                                <input class="btn green" type="submit" name="advanceSearch" value="Search">
                            </div>
</div>
                        </div>
                        {!! Form::close() !!}
                    </div><!-- search-form -->
                </div>


via Chebli Mohamed

jeudi 26 janvier 2023

How I can pipeline the incomming results in Laravel so I can process them whilst I read them?

I need to run a query in a console command:


use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;

use App\Jobs\SendVaccationEmail;

class ProcessDbResult extends Command
{
  protected $signature = "process:entries";
  protected $description = "Bulk Process of results";

   public function handle() 
   {
     $sql = "
        SELECT DISTINCT 
             user_id 
        from 
         (Select user_id from travels where destination = "Bahamas") as bahamas_vac
         LEFT JOIN (Select user_id from travels where destination <> "Bahamas") as non_bahamas_vac ON bahamas_vac.user_id = non_bahamas_vac.user_id
        WHERE
          non_bahamas_vac.user_id = NULL
 ";

     $results = DB:select($sql);
     foreach($results as $result){
       SendVaccationEmail::dispatch($result);
     }
   }
}

But expect the results to be rather large ~ 100.000 records, therefore in order to save memory consumption, I want somehow the database results to be streamed instead being fetched on one go.

What I actually want to do is:

enter image description here

Meaning I do not want to wait for results to be returned but once I have the first result I want to begin to process it.

Is somehow feasible Using laravel? I'm stuck with laravel 5.8.



via Chebli Mohamed

mardi 24 janvier 2023

How can i decrypt my old data with new laravel new generated key [closed]

encrypt library's link with laravel:- https://www.nicesnippets.com/blog/laravel-8-automatic-database-encryption-decryption-with-eloquent

I have decrypt and insert data in db throw this library, but problem with this, i can decrypt and fetch my data with my only old (APP_KEY base64:xxxxxxxxxxxxxxxxxxxx), i am unable to decrypt the data with updated key. i need help to solve this problem.



via Chebli Mohamed