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

dimanche 29 janvier 2023

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 try to collapse my element it automatically opens again and again

enter image description here

When I try to close my element it automatically opens again and again

<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

lundi 23 janvier 2023

Compare one zipcode in range of zips [closed]

If my single zip code is 00624 and range in databse is 005-009, how do I compare this?

public function postalcode(Request $request)
{
    dd($request->postalcode);
}


via Chebli Mohamed

mercredi 18 janvier 2023

Laravel controller Merge 2 array to Comparision selling

I have 2 array to get the sold products from location at different date ranges then I need to make comparison between the two arrays

$results_day_report = DB::table('transaction_sell_lines as tsl')
        ->select(DB::raw('b.name as business_location_name , t.location_id as location_id , tsl.product_id as product_id , p.name as product_name , tsl.variation_id as variation_id , sum(tsl.quantity) AS quantity , sum(tsl.quantity * tsl.unit_price_inc_tax) AS total'))
        ->leftjoin('transactions as t','t.id', '=', 'tsl.transaction_id')
        ->leftjoin('business_locations as b','b.id', '=', 't.location_id')
        ->leftjoin('products as p','p.id', '=', 'tsl.product_id')
        ->whereRaw("t.transaction_date LIKE '$reportdate%'")
        ->where('b.custom_field1', $location_type)
        ->where('t.type', '=' , 'sell')
        ->where('t.status', '=' , 'final')
        ->where('p.id', '!=' , 1)
        ->groupBy('tsl.variation_id')
        ->orderBy('tsl.variation_id', 'asc')
        ->orderBy('b.id', 'asc')
        ->get(); 
        
        $results_day_report_year_before = DB::table('transaction_sell_lines as tsl')
        ->select(DB::raw('b.name as business_location_name , t.location_id as location_id , tsl.product_id as product_id , p.name as product_name , tsl.variation_id as variation_id , sum(tsl.quantity) AS quantity , sum(tsl.quantity * tsl.unit_price_inc_tax) AS total'))
        ->leftjoin('transactions as t','t.id', '=', 'tsl.transaction_id')
        ->leftjoin('business_locations as b','b.id', '=', 't.location_id')
        ->leftjoin('products as p','p.id', '=', 'tsl.product_id')
        ->whereRaw("t.transaction_date LIKE '$reportdate_year_before%'")
        ->where('b.custom_field1', $location_type)
        ->where('t.type', '=' , 'sell')
        ->where('t.status', '=' , 'final')
        ->where('p.id', '!=' , 1)
        ->groupBy('tsl.variation_id')
        ->orderBy('tsl.variation_id', 'asc')
        ->orderBy('b.id', 'asc')
        ->get();  

and Now I have results to be $results_day_report =

Illuminate\Support\Collection {#4170 ▼
  #items: array:23 [▼
    0 => {#4172 ▼
      +"business_location_name": "Gaming Area"
      +"location_id": 19
      +"product_id": 526
      +"product_name": "سيارات تصادم (مايكل)"
      +"variation_id": 674
      +"quantity": "15.0000"
      +"total": "300.00000000"
    }
    1 => {#4178 ▼
      +"business_location_name": "Gaming Area"
      +"location_id": 19
      +"product_id": 528
      +"product_name": "قطار اطفال (مايكل)"
      +"variation_id": 676
      +"quantity": "5.0000"
      +"total": "50.00000000"
    }
    2 => {#4179 ▼
      +"business_location_name": "Gaming Area"
      +"location_id": 19
      +"product_id": 529
      +"product_name": "ارنوب (مايكل)"
      +"variation_id": 677
      +"quantity": "3.0000"
      +"total": "30.00000000"
    }
    3 => {#4173 ▼
      +"business_location_name": "Lavandula Gym"
      +"location_id": 17
      +"product_id": 594
      +"product_name": "جم رجال يومى ع.د"
      +"variation_id": 742
      +"quantity": "3.0000"
      +"total": "90.00000000"
    }
    4 => {#4171 ▼
      +"business_location_name": "Lavandula Gym"
      +"location_id": 17
      +"product_id": 595
      +"product_name": "جم رجال يومى ق.م"
      +"variation_id": 743
      +"quantity": "1.0000"
      +"total": "60.00000000"
    }
    5 => {#4177 ▼
      +"business_location_name": "Lavandula Gym"
      +"location_id": 17
      +"product_id": 597
      +"product_name": "جم رجال شهرى ع.د"
      +"variation_id": 745
      +"quantity": "1.0000"
      +"total": "200.00000000"
    }
    6 => {#4175 ▼
      +"business_location_name": "Lavandula Gym"
      +"location_id": 17
      +"product_id": 615
      +"product_name": "رسم استخراج كارنيه اول مره"
      +"variation_id": 763
      +"quantity": "1.0000"
      +"total": "30.00000000"
    }
    7 => {#4180 ▼
      +"business_location_name": "Tiba Rose Gym"
      +"location_id": 16
      +"product_id": 637
      +"product_name": "جلسة مساج مشتركين"
      +"variation_id": 785
      +"quantity": "2.0000"
      +"total": "400.00000000"
    }
    8 => {#4181 ▼
      +"business_location_name": "Tiba Rose Gym"
      +"location_id": 16
      +"product_id": 679
      +"product_name": "جيم سيدات يومى ع د"
      +"variation_id": 827
      +"quantity": "2.0000"
      +"total": "70.00000000"
    }
    9 => {#4182 ▼
      +"business_location_name": "Tiba Rose Gym"
      +"location_id": 16
      +"product_id": 681
      +"product_name": "جيم  سيدات يومى مدنى"
      +"variation_id": 829
      +"quantity": "1.0000"
      +"total": "85.00000000"
    }
    10 => {#4183 ▼
      +"business_location_name": "Tiba Rose Gym"
      +"location_id": 16
      +"product_id": 683
      +"product_name": "جيم سيدات  شهرى ق م"
      +"variation_id": 831
      +"quantity": "1.0000"
      +"total": "450.00000000"
    }
    11 => {#4184 ▼
      +"business_location_name": "Tiba Rose Gym"
      +"location_id": 16
      +"product_id": 705
      +"product_name": "حمام سباحة مغطى(م)"
      +"variation_id": 853
      +"quantity": "1.0000"
      +"total": "75.00000000"
    }
    12 => {#4185 ▼
      +"business_location_name": "Subscriptions"
      +"location_id": 20
      +"product_id": 773
      +"product_name": "العاب ثابته"
      +"variation_id": 921
      +"quantity": "3.0000"
      +"total": "30.00000000"
    }
    13 => {#4186 ▼
      +"business_location_name": "Gaming Area"
      +"location_id": 19
      +"product_id": 6140
      +"product_name": "الترامبولين م"
      +"variation_id": 6291
      +"quantity": "7.0000"
      +"total": "70.00000000"
    }
    14 => {#4187 ▼
      +"business_location_name": "Gaming Area"
      +"location_id": 19
      +"product_id": 6568
      +"product_name": "كاروسيل (مايكل)"
      +"variation_id": 6719
      +"quantity": "5.0000"
      +"total": "50.00000000"
    }
    15 => {#4188 ▼
      +"business_location_name": "Red Zone"
      +"location_id": 44
      +"product_id": 7781
      +"product_name": "مصارعه سومو"
      +"variation_id": 7932
      +"quantity": "10.0000"
      +"total": "217.39100000"
    }
    16 => {#4189 ▼
      +"business_location_name": "Red Zone"
      +"location_id": 44
      +"product_id": 7782
      +"product_name": "تيلي جيمز"
      +"variation_id": 7933
      +"quantity": "10.0000"
      +"total": "217.39100000"
    }
    17 => {#4190 ▼
      +"business_location_name": "Red Zone"
      +"location_id": 44
      +"product_id": 7783
      +"product_name": "فولي بيج بول"
      +"variation_id": 7934
      +"quantity": "10.0000"
      +"total": "347.82600000"
    }
    18 => {#4191 ▼
      +"business_location_name": "Red Zone"
      +"location_id": 44
      +"product_id": 7784
      +"product_name": "سوكر شوز"
      +"variation_id": 7935
      +"quantity": "10.0000"
      +"total": "347.82600000"
    }
    19 => {#4192 ▼
      +"business_location_name": "Red Zone"
      +"location_id": 44
      +"product_id": 7785
      +"product_name": "الساعة"
      +"variation_id": 7936
      +"quantity": "10.0000"
      +"total": "434.78300000"
    }
    20 => {#4193 ▼
      +"business_location_name": "Tiba Rose Gym"
      +"location_id": 16
      +"product_id": 9091
      +"product_name": "اكستريم جيم سيدات شهري مدني"
      +"variation_id": 9251
      +"quantity": "1.0000"
      +"total": "800.00000000"
    }
    21 => {#4194 ▼
      +"business_location_name": "Red Zone"
      +"location_id": 44
      +"product_id": 9341
      +"product_name": "ارشيرلي فايت"
      +"variation_id": 9501
      +"quantity": "10.0000"
      +"total": "434.78300000"
    }
    22 => {#4195 ▼
      +"business_location_name": "Red Zone"
      +"location_id": 44
      +"product_id": 9342
      +"product_name": "كومبو (2)"
      +"variation_id": 9502
      +"quantity": "10.0000"
      +"total": "2000.00000000"
    }
  ]
}

and result of $results_day_report_year_before to be

Illuminate\Support\Collection {#4174 ▼
  #items: array:15 [▼
    0 => {#4196 ▼
      +"business_location_name": "Video Game"
      +"location_id": 18
      +"product_id": 513
      +"product_name": "موتوسيكل"
      +"variation_id": 661
      +"quantity": "1.0000"
      +"total": "15.00000000"
    }
    1 => {#4202 ▼
      +"business_location_name": "Video Game"
      +"location_id": 18
      +"product_id": 517
      +"product_name": "هزازات"
      +"variation_id": 665
      +"quantity": "1.0000"
      +"total": "10.00000000"
    }
    2 => {#4203 ▼
      +"business_location_name": "Video Game"
      +"location_id": 18
      +"product_id": 520
      +"product_name": "هدايا كبيرة"
      +"variation_id": 668
      +"quantity": "1.0000"
      +"total": "20.00000000"
    }
    3 => {#4197 ▼
      +"business_location_name": "Gaming Area"
      +"location_id": 19
      +"product_id": 526
      +"product_name": "سيارات تصادم (مايكل)"
      +"variation_id": 674
      +"quantity": "24.0000"
      +"total": "480.00000000"
    }
    4 => {#4176 ▼
      +"business_location_name": "Gaming Area"
      +"location_id": 19
      +"product_id": 527
      +"product_name": "سامبا (مايكل)"
      +"variation_id": 675
      +"quantity": "2.0000"
      +"total": "40.00000000"
    }
    5 => {#4201 ▼
      +"business_location_name": "Gaming Area"
      +"location_id": 19
      +"product_id": 528
      +"product_name": "قطار اطفال (مايكل)"
      +"variation_id": 676
      +"quantity": "4.0000"
      +"total": "40.00000000"
    }
    6 => {#4199 ▼
      +"business_location_name": "Lavandula Gym"
      +"location_id": 17
      +"product_id": 594
      +"product_name": "جم رجال يومى ع.د"
      +"variation_id": 742
      +"quantity": "1.0000"
      +"total": "30.00000000"
    }
    7 => {#4204 ▼
      +"business_location_name": "Lavandula Gym"
      +"location_id": 17
      +"product_id": 598
      +"product_name": "جم رجال شهرى ق.م"
      +"variation_id": 746
      +"quantity": "1.0000"
      +"total": "350.00000000"
    }
    8 => {#4205 ▼
      +"business_location_name": "Tiba Rose Gym"
      +"location_id": 16
      +"product_id": 615
      +"product_name": "رسم استخراج كارنيه اول مره"
      +"variation_id": 763
      +"quantity": "5.0000"
      +"total": "50.00000000"
    }
    9 => {#4206 ▼
      +"business_location_name": "Tiba Rose Gym"
      +"location_id": 16
      +"product_id": 688
      +"product_name": "جم رجال يومى ع.د"
      +"variation_id": 836
      +"quantity": "2.0000"
      +"total": "70.00000000"
    }
    10 => {#4207 ▼
      +"business_location_name": "Tiba Rose Gym"
      +"location_id": 16
      +"product_id": 690
      +"product_name": "جم رجال يومى مدنى"
      +"variation_id": 838
      +"quantity": "1.0000"
      +"total": "85.00000000"
    }
    11 => {#4208 ▼
      +"business_location_name": "Tiba Rose Gym"
      +"location_id": 16
      +"product_id": 691
      +"product_name": "جم رجال شهرى ع.د"
      +"variation_id": 839
      +"quantity": "3.0000"
      +"total": "750.00000000"
    }
    12 => {#4209 ▼
      +"business_location_name": "Tiba Rose Gym"
      +"location_id": 16
      +"product_id": 692
      +"product_name": "جم رجال شهرى ق.م"
      +"variation_id": 840
      +"quantity": "1.0000"
      +"total": "450.00000000"
    }
    13 => {#4210 ▼
      +"business_location_name": "Subscriptions"
      +"location_id": 20
      +"product_id": 763
      +"product_name": "حجزملعب س/ط س ن"
      +"variation_id": 911
      +"quantity": "4.0000"
      +"total": "560.00000000"
    }
    14 => {#4211 ▼
      +"business_location_name": "Subscriptions"
      +"location_id": 20
      +"product_id": 773
      +"product_name": "العاب ثابته"
      +"variation_id": 921
      +"quantity": "2.0000"
      +"total": "20.00000000"
    }
  ]
}

then I make this foreach loop to generate one array with the comparison

foreach($results_day_report as $result_day_report)
    {
        array_push($queries, (object)[
                'business_location_name' => $result_day_report->business_location_name,
                'location_id' => $result_day_report->location_id,
                'product_id' => $result_day_report->product_id,
                'product_name' => $result_day_report->product_name,
                'variation_id' => $result_day_report->variation_id,
                
                'quantity_report_date_same_year' => $result_day_report->quantity,
                'total_report_date_same_year' => $result_day_report->total,
                
                'quantity_report_date_year_before' => 0,
                'total_report_date_year_before' => 0,
                
                'quantity_date_range_same_year' => 0, 
                'total_date_range_same_year' => 0,
                
                'quantity_date_range_year_before' => 0,
                'total_date_range_year_before' => 0,
                
                'step_a' => '1',
            ]);
    }
    foreach($results_day_report_year_before as $result_day_report_year_before)
    {
        $collection = collect($queries);
        if(!$collection->contains('variation_id', $result_day_report_year_before->variation_id))
        {
            array_push($queries, (object)[
                'business_location_name' => $result_day_report_year_before->business_location_name,
                'location_id' => $result_day_report_year_before->location_id,
                'product_id' => $result_day_report_year_before->product_id,
                'product_name' => $result_day_report_year_before->product_name,
                'variation_id' => $result_day_report_year_before->variation_id,
                
                'quantity_report_date_same_year' => 0,
                'total_report_date_same_year' => 0,
                
                'quantity_report_date_year_before' => $result_day_report_year_before->quantity,
                'total_report_date_year_before' => $result_day_report_year_before->total,
                
                'quantity_date_range_same_year' => 0,
                'total_date_range_same_year' => 0,
                
                'quantity_date_range_year_before' => 0,
                'total_date_range_year_before' => 0,
                
                'step_b' => '1',
            ]);
        }
        else
        {
            $data = $collection->map(function ($item, $key) use ($result_day_report_year_before) {
                if($item->location_id == $result_day_report_year_before->location_id && $item->variation_id == $result_day_report_year_before->variation_id)
                {
                    $item->quantity_report_date_year_before = $result_day_report_year_before->quantity ;
                    $item->total_report_date_year_before = $result_day_report_year_before->total ;
                    $item->step_b = 2 ;
                }
                elseif($item->location_id != $result_day_report_year_before->location_id && $item->variation_id == $result_day_report_year_before->variation_id)
                {
                    array_push($queries, (object)[
                        'business_location_name' => $result_day_report_year_before->business_location_name,
                        'location_id' => $result_day_report_year_before->location_id,
                        'product_id' => $result_day_report_year_before->product_id,
                        'product_name' => $result_day_report_year_before->product_name,
                        'variation_id' => $result_day_report_year_before->variation_id,
                        
                        'quantity_report_date_same_year' => 0,
                        'total_report_date_same_year' => 0,
                        
                        'quantity_report_date_year_before' => $result_day_report_year_before->quantity,
                        'total_report_date_year_before' => $result_day_report_year_before->total,
                        
                        'quantity_date_range_same_year' => 0,
                        'total_date_range_same_year' => 0,
                        
                        'quantity_date_range_year_before' => 0,
                        'total_date_range_year_before' => 0,
                        
                        'step_b' => '3',
                    ]);
                }
                return $item;
            });
            
        }
    }

Now the result of final array ($queries) will be

enter image description here

This result isn't correct, the correct answer must be array with 34 object not 33 object Error at step of array push which contain 'step_b' => '3' , it return null not correct object

What's the problem ?



via Chebli Mohamed

How to make command in Laravel that can go thousands rows and update all data with Job that can update grouped by 50 data

I want to make command that can go through all data from database and update some data in API for every row.. I am afraid of stopping command or cron and all data will not be updated. And when command run again it will go from first id. For example if I have ids: [1,2,3,4,5,6,7,8,...100,101,..1000,1001,...] I want to first update 50 rows(1-50), then (51-100)..and so on.. How can I make Job that will save from which to which ID should be updated? I hope so that someone can help me.. I tried something like this

 $woocount=WoocommerceProduct::where('sync_status', 'IN_SYNC')->count();
        
        if($woocount>100){
            $max=intval($woocount/100);
        }else{
            $max=$woocount;

        }
       // dd($max);
        $i=1;
        while($i<=$woocount){
            dump($max);
            $wooproducts=WoocommerceProduct::where([['sync_status', 'IN_SYNC'],['id','>=',$i], ['id', '<=', $max]])->get();
            dump($wooproducts->pluck('id')->toArray());
            CheckStockJob::dispatch($wooproducts);
            $i=$max+1;
            $max=$max+100;
        }


via Chebli Mohamed

mardi 17 janvier 2023

NotFoundHttpException in Handler.php line 103: No query results for model [sistemaconvocatoria\Convocatoria]

I have a problem when I try to edit a record I get the following error: NotFoundHttpException in Handler.php line 103: No query results for model [sistemaconvocatoria\Convocatoria]. --- Here is my controller:

<?php

namespace sistemaconvocatoria\Http\Controllers;

use Illuminate\Http\Request;

use sistemaconvocatoria\Http\Requests;
use sistemaconvocatoria\Convocatoria;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\input;
use sistemaconvocatoria\Http\Requests\ConvocatoriaFormRequest;
use Carbon\Carbon;
use DB;


class ConvocatoriaController extends Controller
{
    public function __construct()
    {
        //$this->middleware('auth');

    }
    public function index(Request $request)
    {
        if ($request)
        {
            $query=trim($request->get('searchText'));
            $convocatorias=DB::table('convocatoria')
            ->where('descripcion','LIKE','%'.$query.'%')
            ->orwhere('codigo','LIKE','%'.$query.'%')
            ->orderBy('idconvocatoria','desc')
            ->paginate(10);
            return view('convocatoria.locacion.index',["convocatorias"=>$convocatorias,"searchText"=>$query]);
        }
        
    }

    public function create()
    {
       
        return view("convocatoria.locacion.create");
    }
    public function store (ConvocatoriaFormRequest $request)
    {
        $convocatoria=new Convocatoria;
        //$convocatoria->id=$request->get('id');
        $convocatoria->codigo=$request->get('codigo');
        $convocatoria->descripcion=$request->get('descripcion');
        $convocatoria->categoria_convocatoria=$request->get('categoria_convocatoria');
        $convocatoria->estado= 'VIGENTE';

        $date1 = Carbon::parse($request->get('fecha_publicacion'));
        $convocatoria->fecha_publicacion=$date1->toDateTimeString();

        $date2 = Carbon::parse($request->get('fecha_vencimiento'));
        $convocatoria->fecha_vencimiento=$date2->toDateTimeString();

        if (Input::hasFile('documento')){
         $file=Input::file('documento');
         $para_extencion=$file->getClientOriginalName();
         $extension = pathinfo($para_extencion, PATHINFO_EXTENSION);
         $nombre_archivo="pdf_".$request->get('categoria_convocatoria')."_".$request->get('codigo').".".$extension;
         $file->move(public_path().'/archivos/pdf/',$nombre_archivo);
         $convocatoria->documento=$nombre_archivo;
        }
        $convocatoria->save();
        return Redirect::to('convocatoria/locacion');

    }
    
    public function show($id)
    {
        return view("convocatoria.locacion.show",["convocatoria"=>Convocatoria::findOrFail($id)]);
    }
    public function edit($id)
    {
        return view("convocatoria.locacion.edit",["convocatoria"=>Convocatoria::findOrFail($id)]);
    }
    
    
    public function update(ConvocatoriaFormRequest $request,$id)
    {
        
        $convocatoria=Convocatoria::findOrFail($id);

        //$convocatoria->id=$request->get('id');
        $convocatoria->codigo=$request->get('codigo');
        $convocatoria->descripcion=$request->get('descripcion');
        $convocatoria->categoria_convocatoria=$request->get('categoria_convocatoria');
        

        $date1 = Carbon::parse($request->get('fecha_publicacion'));
        $convocatoria->fecha_publicacion=$date1->toDateTimeString();

        $date2 = Carbon::parse($request->get('fecha_vencimiento'));
        $convocatoria->fecha_vencimiento=$date2->toDateTimeString();

        if (Input::hasFile('documento')){
         $file=Input::file('documento');
         $para_extencion=$file->getClientOriginalName();
         $extension = pathinfo($para_extencion, PATHINFO_EXTENSION);
         $nombre_archivo="pdf_".$request->get('categoria_convocatoria')."_".$request->get('codigo').".".$extension;
         $file->move(public_path().'/archivos/pdf/',$nombre_archivo);
         $convocatoria->documento=$nombre_archivo;
        }

        $convocatoria->update();
        return Redirect::to('convocatoria/locacion');
    }

    public function destroy($id)
    {
        $convocatoria = DB::table('convocatoria')->where('idconvocatoria','=',$id)->delete();
        return Redirect::to('convocatoria/locacion');

    }
}

my edit.blade.php

@extends ('layouts.admin')
@section ('contenido')
    <div class="row">
        <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
            <h3>Editar Certificado: </h3>
            @if (count($errors)>0)
            <div class="alert alert-danger">
                <ul>
                @foreach ($errors->all() as $error)
                    <li></li>
                @endforeach
                </ul>
            </div>
            @endif
        </div>
    </div>
            {!!Form::model($convocatoria, ['method'=>'PATCH','route'=> ['convocatoria.locacion.update',$convocatoria->idconvocatoria],'files'=>'true'])!!}<!--creamos el formulario y le damos los prametros es importante patch es editar-->
            <!--agregamos un token-->
            <div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
            <div class="form-group">
                <label for="descripcion">Descripción</label>
                <input type="text" name="descripcion" required value="" class="form-control" placeholder="Descripción...">        
            </div>      
        </div>
        <!--para el codigo-->
        <div class="col-lg-2 col-md-2 col-sm-2 col-xs-12">
            <div class="form-group">
                <label for="codigo">Código</label>
                <input type="text" name="codigo" required value="" class="form-control" placeholder="Código...">           
            </div>      
        </div>
        <!--para la categoria-->
        <div class="col-lg-2 col-md-2 col-sm-2 col-xs-12">
            <div class="form-group">
                <label>Categoria</label>
                <select name="categoria_convocatoria" class="form-control">
                    <option value="Bienes" >Bienes</option>
                    <option value="Servicios" >Servicios</option>
                    
                </select>
            </div>
        </div>
        <div class="row"></div>
        <br>

        <div class="col-lg-2 col-md-2 col-sm-2 col-xs-12">
            <div class="form-group"><!--creamos la fila para ingresar el nombre-->
                <label for="fecha_publicacion">Fecha de publicacion</label><!--etiqueta-->
                <input name="fecha_publicacion" type="datetime-local" required value="" class="form-control" placeholder="Fecha de Publicación...">
                        
            </div>      
        </div>
        
        <div class="col-lg-2 col-md-2 col-sm-2 col-xs-12">
            <div class="form-group">
                <label for="fecha_vencimiento">Fecha de Vencimiento</label>
                <input name="fecha_vencimiento" type="datetime-local" required value="" class="form-control" placeholder="Fecha de Vencimiento...">
                        
            </div>      
        </div>
        
        <!--para el pdf-->
        <div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
            <div class="form-group">
                <label for="documento">Subir TDR</label>
                <input type="file" name="documento" class="form-control">       
            </div>      
        </div>
            <div class="form-group">
                <button class="btn btn-primary" type="submit">Guardar</button>
                
                <button class="btn btn-danger" onclick="history.go(-1); return false;">Cancelar</button>
            </div>

            {!!Form::close()!!}     
            
        
@endsection

at the beginning I thought it was because I was generating a conflict with the id and idconvocation of my convocation table, but apparently it is not that.

<td>
<a href=""><button class="fa fa-pencil-square-o btn btn-primary"> Editar</button></a>
<a href="" data-target="#modal-delete-" data-toggle="modal"><button class="fa fa-trash-o btn btn-danger"> Eliminar</button></a>
</td>

My Route

Route::resource('convocatoria/locacion','ConvocatoriaController');


via Chebli Mohamed

lundi 16 janvier 2023

How Can I display the product sales per Month using Line Graph

$monthlySales = OrderProduct::selectRaw('sum(amount) as total_sales, month(created_at) as month, year(created_at) as year') ->groupBy('month', 'year') ->get();

        $labels = $monthlySales->pluck('month')->toArray();
        $data = $monthlySales->pluck('total_sales')->toArray();

this is the line graph

var xValues = ['January','Febuary','March','April','May','June','July','August','September','October','November','December']; var yValues = [];

                      new Chart("myChart", {
                        type: "line",
                        data: {
                          labels: xValues,
                          datasets: [{
                            fill: false,
                            lineTension: 0,
                            backgroundColor: "rgba(0,0,255,1.0)",
                            borderColor: "rgba(0,0,255,0.1)",
                            data: yValues
                          }]
                        },
                        options: {
                          legend: {display: false},
                          scales: {
                            yAxes: [{ticks: {min: 0, max:}}],
                          }
                        }
                      });

I tried to use for loop to make a array for the data but still no visible data or maybe I dont have enough data in database?



via Chebli Mohamed

vendredi 13 janvier 2023

Url amigavel com 2 parametros desconfigura html

I am trying to implement friendly URLs on my website, however whenever I use "/" to separate the second argument it works and sends normally but the site doesn't load images and becomes misconfigured. Below is the .htaccess file. I want the images to load normally with one argument I can do it perfectly.

.htacess

RewriteEngine on
# If we receive a forwarded http request from a proxy...
#RewriteCond %{HTTP:X-Forwarded-Proto} =http [OR]

# ...or just a plain old http request directly from the client
#RewriteCond %{HTTP:X-Forwarded-Proto} =""
#RewriteCond %{HTTPS} !=on

# Redirect to https version
#RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

#RewriteCond %{HTTPS} off
#RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Acesso http redirecionado para https
#RewriteCond %{HTTPS} off
#RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

#RewriteCond %{HTTPS} !=on
#RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$



RewriteRule ^(.*)$ %{REQUEST_URI}/ [R=301,L]


RewriteRule ^([a-z0-9-]+)/([0-9]+)/?$ index.php?id=$1&nome=$2 [NC]


via Chebli Mohamed

save and update the order of concatenation in the controller

I am looking to concatenate columns into a single , and be able to change the order that I can save it here is the schema of my table:

id col1 col2 col3 separation order ref
A 320 Audi - 'col1','col2','col3' A-320-Audi
A 120 Audi * 'col3','col2','col1' Audi120A
c 220 Aaudi / 'col2','col3','col1' 220/audi/c

in my modification form the user can change the values ​​of the columns also the separation and the order but I also want to save the order that the user has chosen to use it in other pages

in my controller:

serials = Serial::findOrFail($id);
    $serials->update([
        'col1' => $request['col1'],
        'col2' => $request['col2'],
        'col3' => $request['col3'],
        'separation' => $request['separation'],
        'order' => $request['order'],
    ]);
DB::statement(DB::raw("UPDATE serials SET ref = CONCAT_WS(separation,order????) WHERE id = $id"));

problem 1:

how to register the chosen order correctly

in my input request of order someting like = 'col1','col2','col3'

problem 2 :

how to retrieve the value of the order and correctly execute the concatenation from the column order someting like :

DB::statement(DB::raw("UPDATE serials SET ref = CONCAT_WS(separation, ???'column:order'????) WHERE id = $id"));


via Chebli Mohamed

jeudi 12 janvier 2023

how Get Multiple value in array with same id laravel & Angular

Here I am trying to get question. At first understand all system we have quiz making system in that we make quizzes but in there a problem if we put a question in any quiz then we creating other quiz the how can we know this particular question is putted in other quizzes or not if yes then which-which. So, here i am trying to get all quizzes title of particular question id. here is controller code

$questions = DB::table('questionbank')
                ->leftJoin('questionbank_quizzes', function($join)
             {
                 $join->on('questionbank_quizzes.questionbank_id','=','questionbank.id');
             })
             ->leftJoin('quizzes', function($join)
             {
                 $join->on('quizzes.id','=','questionbank_quizzes.quize_id');
                      
                      
             })
            //  ->groupBy('questionbank.id')
                ->where('questionbank.subject_id', '=', $request->subject_id)
                ->select('questionbank.id', 'questionbank.subject_id', 'topic_id', 'question_type', 'question', 'questionbank.marks', 'difficulty_level', 'status','quizzes.title')
                ->get(['questionbank.id', 'questionbank.subject_id', 'topic_id', 'question_type', 'question', 'questionbank.marks', 'difficulty_level', 'status', 'quizzes.title']);
     
      return json_encode(array('topics'=>$topics, 'questions'=>$questions, 'subject'=>$subject));

And This is angular code

$scope.subjectChanged = function(selected_number) {
         
        if(selected_number=='')
            selected_number = $scope.subject_id;
        subject_id = selected_number;
        if(subject_id === undefined)
            return;
        route = '';  
        data= {  _method: 'post', 
                '_token':httpPreConfig.getToken(),
                 'subject_id': subject_id
               };

          httpPreConfig.webServiceCallPost(route, data).then(function(result){

            result = result.data;
            $scope.subjectQuestions = [];
            $scope.subject          = result.subject;
            $scope.subjectQuestions = result.questions;
 
            $scope.contentAvailable = true;

           $scope.removeDuplicates();
        
            });
        }

        $scope.removeDuplicates = function(){
           
            if($scope.savedQuestions.length<=0 || $scope.subjectQuestions.length<=0)
                return;

             angular.forEach($scope.savedQuestions,function(value,key){
                    if(value.subject_id != $scope.subjectQuestions[0].subject_id)
                        return;

                    res = httpPreConfig.findIndexInData($scope.subjectQuestions, 'id', value.question_id);
                    if(res >= 0)
                    {
                         $scope.subjectQuestions.splice(res, 1);
                    }
                    
            });
        }

This is blade view

    <div ng-if="subjectQuestions!=''" class="vertical-scroll" >

                                <h4 class="text-success">Questions @ </h4>
                                <table  class="table table-hover">
                                    <th ></th>

                                    <th></th>

                                    <th></th>

                                    <th></th>

                                    <th></th> 

                                    <th></th>    
                                    <tr ng-repeat="question in subjectQuestions | filter: { difficulty_level:difficulty, question_type:question_type, show_in_front_end:show_in_front_end , topic_id:topic, sub_topic_id:sub_topic } | filter: question_model track by $index ">

                                        <td>@</td>
                                        <td title="@" ng-bind-html="trustAsHtml(question.question)">
                                        </td>
                                        <td>  @ </td>
                                        <td>@</td>
                                        <td>@</td>
                                        <td><a ng-click="addQuestion(question, subject);" class="btn btn-primary" ></a>
                                          </td>
                                    </tr>
                                </table>
                                </div>  
                                </div>
                            </div>

Its result is like this

questions:[
0: {id: "4599", subject_id: "104", topic_id: "120", question_type: "radio",status: "1", subject_id: "104", title: "MOCK TEST NCERT BOOKS CHEMISTRY 26", topic_id: "120"}
1: {id: "4599", subject_id: "104", topic_id: "120", question_type: "radio",status: "1", subject_id: "104", title: "MOCK TEST NCERT BOOKS CHEMISTRY 23", topic_id: "120"}
2: {id: "4600", subject_id: "104", topic_id: "120", question_type: "radio",status: "1", subject_id: "104", title: "MOCK TEST NCERT BOOKS CHEMISTRY 26", topic_id: "120"}
3: {id: "4600", subject_id: "104", topic_id: "120", question_type: "radio",status: "1", subject_id: "104", title: "MOCK TEST NCERT BOOKS CHEMISTRY 23", topic_id: "120"}
4: {id: "4602", subject_id: "104", topic_id: "120", question_type: "radio",status: "1", subject_id: "104", title: "MOCK TEST NCERT BOOKS CHEMISTRY 26", topic_id: "120"}
5: {id: "4602", subject_id: "104", topic_id: "120", question_type: "radio",status: "1", subject_id: "104", title: "MOCK TEST NCERT BOOKS CHEMISTRY 23", topic_id: "120"}
6: {id: "4603", subject_id: "104", topic_id: "120", question_type: "radio",status: "1", subject_id: "104", title: "MOCK TEST NCERT BOOKS CHEMISTRY 26", topic_id: "120"}
7: {id: "4603", subject_id: "104", topic_id: "120", question_type: "radio",status: "1", subject_id: "104", title: "MOCK TEST NCERT BOOKS CHEMISTRY 23", topic_id: "120"}
]

In result you can see with same id title is different but i am stuck here how can i do that. Please help us in this problem. I want result like this..

questions:[
0: {id: "4599", subject_id: "104", topic_id: "120", question_type: "radio",status: "1" subject_id: "104", title: "MOCK TEST NCERT BOOKS CHEMISTRY 26(<br> or ,)MOCK TEST NCERT BOOKS CHEMISTRY 23", topic_id: "120"}
1: {id: "4600", subject_id: "104", topic_id: "120", question_type: "radio",status: "1", subject_id: "104", title: ""MOCK TEST NCERT BOOKS CHEMISTRY 26(<br> or ,)MOCK TEST NCERT BOOKS CHEMISTRY 23", topic_id: "120"}
2: {id: "4602", subject_id: "104", topic_id: "120", question_type: "radio",status: "1", subject_id: "104", title: ""MOCK TEST NCERT BOOKS CHEMISTRY 26(<br> or ,)MOCK TEST NCERT BOOKS CHEMISTRY 23", topic_id: "120"}
3: {id: "4603", subject_id: "104", topic_id: "120", question_type: "radio",status: "1", subject_id: "104", title: ""MOCK TEST NCERT BOOKS CHEMISTRY 26(<br> or ,)MOCK TEST NCERT BOOKS CHEMISTRY 23", topic_id: "120"}
]


via Chebli Mohamed

mercredi 11 janvier 2023

How to implement prepared statement in array_push()

I'm trying to prevent my query from being injected with SQL injection by using a prepared statement. but how to implement prepared statement into array_push()? here I use array push for custom search purposes.

Here is the code snippet that I have now.

public function getDataTable(Request $req) {
    $start = $req->start;
    $length = $req->length;
    $draw = $req->draw;
    $order = $req->order;
    $type = '';
    $where = $this->storeParams($req);
    
    $data = $this->getData($where, $start, $length, $order, $type);
    
    .
    .
    .
    .

    $output = [
        'draw' => (int) $draw,
        'recordsTotal' => $total,
        'recordsFiltered' => $filtered,
        'data' => $data,
    ];
    return json_encode($output);
}

public function storeParams(Request $req) {
    $param = [];

    $start_date = date('Y-m-d');
    $end_date = date('Y-m-d');

    if (!empty($req->studentid)) {
        array_push($param, 'studentid LIKE \'' . $req->studentid . '\'');
    }

    if (!empty($req->studentnm)) {
        array_push($param, 'studentnm LIKE \'' . $req->studentnm . '%\'');
    }

    if (!empty($start_date) && !empty($end_date)) {
        array_push($param, "entrydate between '" . $start_date . "' and '" . $end_date . "'");
    }

    if (count($param) > 0) {
        $where = implode(' and ', $param);
    } else {
        $where = "1";
    }
    return $where;
}

public function getData($where, $start = null, $length = null, $order = null, $type = null) {
    .
    .
    .
    .
    $dataSet = DB::connection('mysql5')->table('tbl_datastudent')
        ->selectRaw("studentid, stuidentnm, address, entrydate, payment, paymentdate")
        ->whereRaw($where);
    .
    .
    .
    .
}

how do i apply the prepared statement into the storeParams() function? anybody can guide or help me?



via Chebli Mohamed

Get data eloquent to Dompdf with response->json in laravel

How to get data eloquent to Dompdf with response->json in laravel. if i use,

$pdf = PDF::loadview('ipdf',['ipdf'=>$ipdf]);
return $pdf->stream();

if i dont use it, img

My controller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use PDF;
use App\Http\Controllers\Controller;
use App\Helpers\MessageHelper;
use App\Helpers\StockHelper;
use Illuminate\Http\JsonResponse;
use App\Helpers\StringRandomHelper;
use App\Models\Order;
use App\Models\OrderDetail;
use App\Models\Sablon;
use App\Models\Stock;
use App\Models\Customer;
use App\Models\ProductSize;
use DB;
class IpdfController extends Controller
{
    public function __construct()
    {
        $this->model = new Order;
    }

    public function index(Request $request) {
        $ipdf = Order::with('orderDetail')->paginate(15);
        return view('ipdf', ['ipdf'=>$ipdf]);
    }
    public function cetak_pdf($id)
    {
        $ipdf = $this->model->with(['orderDetail.productSize.productColor.productCategories.product'])->find($id);
        $ipdf = $ipdf->where('id', '=', $id)->orderby('created_at','desc')->get();
        return response()->json($ipdf);
        // $pdf = PDF::loadview('ipdf',['ipdf'=>$ipdf]);
        // $pdf = PDF::loadview('ipdf',compact('ipdf'));
        // return $pdf->stream();
    }
}

get/read data eloquent by id to Dompdf with response->json in laravel



via Chebli Mohamed

samedi 7 janvier 2023

problems with login and authentication in laravel

i need help with my login and authentication of users.

Every time i press the login button when i try to log in i get an error:

"Undefined index: password"

in

C:\wamp\www\app\vendor\laravel\framework\src\Illuminate\Auth\EloquentUserProvider.php

and i dont know why.

My custom controller AuthController:

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Hash;
use Session;
use App\Models\Admin;
use Illuminate\Support\Facades\Auth;
class AuthController extends Controller
{
    public function index()
    {
        return view('auth.login');
    }  
      
    public function customLogin(Request $request)
    {
        $request->validate([
            'name' => 'required',
            'surname' => 'required',
            'passw' => 'required',
        ]);
   
        $credentials = $request->only('name', 'surname', 'passw');
        if (Auth::attempt($credentials)) {
            return redirect()->intended('');
        }
  
        return redirect("login")->withSuccess('Wrong input data.');
    }
    
    public function dashboard()
    {
        if(Auth::check()){
            return view('');
        }
  
        return redirect("login")->withSuccess('Wrong input data.');
    }
    
    public function signOut() {
        Session::flush();
        Auth::logout();
  
        return Redirect('');
    }
}

name, surname is in my native language and (passw) symbolises that the password is also in my native language.

My route:

Auth::routes();
Route::post('/login', 'AuthController@customLogin');

I consulted with a acquaintance that specialises in web-programming and she said i should do a custom AuthController, which I did, but the problem is either still not fixed or this is a different error. And from websources i used: https://www.positronx.io/laravel-custom-authentication-login-and-registration-tutorial/



via Chebli Mohamed

vendredi 6 janvier 2023

How to compare a db value to another db value in laravel php

I would like to compare 2 values of the database. Is it possible to do so with the "where" method? The "tnx_time" would be one db value and the "value(duration)" the other one. But right now I can not access the db values on the 3rd field of the "where" function.

Does anybody know how to fix that? Thanks a lot!

$trnxs =  Transaction::where('tnx_time', '<',  date("Y-m-d", strtotime( value(duration) )) )


via Chebli Mohamed

mercredi 4 janvier 2023

how to check a mutex exists for a scheduled job using laravel tinker?

I have a job scheduled to run every hour. 'withoutOverlapping' is set for this job and mutex expiry time is 24 hour.

But when I checked cron.log. I found that it is not running every hour. But it runs once in a day and at the end of job, there is a redis write error. I think this error is getting when clearing mutex (lock) of this job from redis after completion of job execution. Then after 24 hour, mutex expires automatically, then this job runs next hour.

To check mutex clears from redis or not, I need to see mutex of this job exists. So using tinker how can I achieve this ?



via Chebli Mohamed

mardi 3 janvier 2023

How to use X-component in laravel controller side

Add any details you missed and read through it again. Now is a good time to make sure that your title still describes the problem!



via Chebli Mohamed

lundi 2 janvier 2023

exception": "Illuminate\\Database\\QueryException "SQLSTATE[23000]: Integrity constraint violation:1052 Column 'id' in field list is ambiguous

This method i try

 $questions = DB::table('questionbank')
                ->join('questionbank_quizzes','questionbank_id.id','=','questionbank.id')
                ->join('quizzes','quizzes.id','=','questionbank_quizzes.quize_id')
                ->where('subject_id', '=', $request->subject_id)
                ->get(['id', 'subject_id', 'topic_id', 'question_type', 'question', 'marks', 'difficulty_level', 'status','quizzes.title']);

and the error is

"message": "SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id' in field list is ambiguous (SQL: select `id`, `subject_id`, `topic_id`, `question_type`, `question`, `marks`, `difficulty_level`, `status`, `quizzes`.`title` from `questionbank` inner join `questionbank_quizzes` on `questionbank_id`.`id` = `questionbank`.`id` inner join `quizzes` on `quizzes`.`id` = `questionbank_quizzes`.`quize_id` where `subject_id` = 78)",
    "exception": "Illuminate\\Database\\QueryException",
    

I want to return in this format can any suggest what we have to do? {id: 2665, subject_id: "78", topic_id: "95", question_type: "radio",…}

But in scipt has other method but we have to print same data as above

 $subject_id = $request->subject_id;
      $subject = Subject::where('id','=',$subject_id)->first();
      $topics = $subject
            ->topics()
            ->where('parent_id', '=', '0')
            ->get(['topic_name', 'id']);
      $questionbank_id = DB::table('questionbank')
                            ->where('subject_id', '=', $request->subject_id)
                             ->get(['id']);
    //   $questionbank_quizzes = $questionbank_id->DB::table('questionbank_quizzes')
    //                         ->where('questionbank_id', '=', $questionbank_id[]->id)
    //                          ->get(['quize_id','questionbank_id']);
    //   $quiz_n=quizzesExistTitle()->get(['title']);
      $questions = $subject->questions()->get(['id', 'subject_id', 'topic_id', 'question_type', 'question', 'marks', 'difficulty_level', 'status']);
    // $questions = DB::table('questionbank')
    //             ->join('questionbank_quizzes','questionbank_id.id','=','questionbank.id')
    //             ->join('quizzes','quizzes.id','=','questionbank_quizzes.quize_id')
    //             ->where('subject_id', '=', $request->subject_id)
    //             ->get(['id', 'subject_id', 'topic_id', 'question_type', 'question', 'marks', 'difficulty_level', 'status']);
      
      return json_encode(array('topics'=>$topics, 'questions'=>$questions, 'subject'=>$subject,'questionbank_quizzes'=>$questionbank_id));
    }

i have to show in array quizzes.title

I have try

$questions = DB::table('questionbank')
                ->join('questionbank_quizzes','questionbank_id.id','=','questionbank.id')
                ->join('quizzes','quizzes.id','=','questionbank_quizzes.quize_id')
                ->where('subject_id', '=', $request->subject_id)
                ->get(['id', 'subject_id', 'topic_id', 'question_type', 'question', 'marks', 'difficulty_level', 'status','quizzes.title']);

but got above error



via Chebli Mohamed

405 method not accepted laravel on live server

I'm creating Api's in laravel 5.7 with php version 7.4 using passport Its an Api of Signin. The Api works fine on local server but when we try it on live server it gives an error of 405 method not accepted. Don't know why its like that because its working fine on local server but not on live server



via Chebli Mohamed