dimanche 21 janvier 2024

Uploading images using FancyFileUpload and regular form submit without using Ajax

I like the interface of FancyFileUpload that's why I'm try to implement it on my already existing form submit. The existing form submit works just fine and can save data into database and upload files to the server. (I'm using laravel by the way).

So here's what I'm trying to accomplish. I want users to select files using FancyFileUpload, but I want to submit the form data in a normal way without using ajax or js. The problem is, no files are being uploaded in the server. When FancyFileUpload initialized, it seems the form could not detect any files added by the user, that's why file input shows null. But if I remove FancyFileUpload, the form works just fine.

Here's my form.

<form id="postForm" class="row" action="" method="POST" enctype="multipart/form-data">
@csrf
    <div class="mb-4">
        <div class="mt-3">
            <textarea class="form-control" rows="7" name="body" placeholder="Write something..."></textarea>
        </div>
        
        <div class="mt-3">
            <label class="mb-2">Upload Photos</label>
            <input class="fileUp fileup-sm" type="file" name="photo_list[]" accept="image/png, image/gif, image/jpg, image/jpeg" multiple>
        </div>
    </div>
    <div class="col-sm-12">
        <button type="submit" class="btn btn-primary" id="submitBtn">Submit</button>
    </div>
</form>

Javascript:

 $(document).ready(function() {
        // Initialize FancyFileUpload
        $('.fileUp').FancyFileUpload();

        // Before form submission, reinitialize FancyFileUpload
        $('#postForm').submit(function() {
            $('.fileUp').FancyFileUpload();
        });
    });

No issues on server side because is working just fine if FancyFileUpload is disabled. Thanks a lot in advance.



via Chebli Mohamed

lundi 15 janvier 2024

Laravel 5.8 mail blade with default css styling or inline styling doesn't work

I created mail html blade file designed with css file in Laravel 5.8.

I tried many ways to work the degisned view with css, but nothing actually works.

Sending email is fine, I just changed the whole designed blade file.
Using default.css or inlined styling both doesn't work.
So confusing about this situation.

  • view (resources/views/mail/stat.blade.php)
<div class="element">
        <img class="bg-logo" src="" />
        <img class="logo" src="" />

        <div class="text-title">베이직바이블<br />서비스 주간 리포트</div>
        <div class="font-bold-700 text-service_term">2023.12.01 - 2023.12.07</div>

        <div class="whitebox-base OS">
            <img src="" alt="" class="app-icon">
            <div class="font-bold-700 text-app_name">베이직바이블</div>
            <div class="font-bold-700 div">쇼핑몰 OS정보</div>
            <div class="OS-2">
                <div class="div-2">
                    <img class="img" src="" />
                    <div class="font-bold-700 text-os_ver">6.6 버전</div>
                </div>
                <div class="div-2">
                    <img class="img" src="" />
                    <div class="font-bold-700 text-os_ver">5.0 버전</div>
                </div>
            </div>
            <div class="IOS">
                <div class="font-bold-700 text-wrapper-3">IOS 개발자계정</div>
                <div class="date">
                    <div class="font-bold-700 text-wrapper-4">365일 남음</div>
                    <div class="text-wrapper-5">만료 2024.12.20</div>
                </div>
            </div>
        </div>
        <div class="whitebox-base box-base-1 box-1">
            <div class="font-bold-700 title">APP</div>
            <div class="text-remain_days">
                <div class="font-heavy-400 normal">203</div>
                <div class="font-bold-700 font-24">일</div>
            </div>
        </div>

    </div>
  • route for preview (web.php)
Route::get('mailable', function() {
    // return view('mail.weeklystat');
    $data = App\Models\AppsData::findOrFail(3698);
   
    return new App\Mail\WeeklyStatMail($data);
});
  • for send mail (app/Mail/StatMail.php)
<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

use App\Models\AppsData;

class WeeklyStatMail extends Mailable
{
    use Queueable, SerializesModels;

    public $appsData;    
   
public function __construct(AppsData $appsData)
{
        $this->appsData = $appsData;
}

public function build()
    {
        return $this
            ->subject($this->appsData->app_name." 통계")
            ->markdown('mail.stat');
   }
}

** tried this part like this, but didn't work.**

public function build()
    {
        return $this
            ->subject($this->appsData->app_name." 통계")
            ->view('mail.stat');
   }
}

  • css (resources/views/mail/html/themes/default.css)
html,
body {
    margin: 0px;
    height: 100%;
}

/* a blue color as a generic focus style */
button:focus-visible {
    outline: 2px solid #4a90e2 !important;
    outline: -webkit-focus-ring-color auto 5px !important;
}

a {
    text-decoration: none;
}

@font-face {
    font-family: "SUIT-Bold";
    src: url('/assets/css/fonts/SUIT/SUIT-Bold.ttf') format("truetype");
}

@font-face {
    font-family: "SUIT-Medium";
    src: url('/assets/css/fonts/SUIT/SUIT-Medium.ttf') format("truetype");
}

@font-face {
    font-family: "SUIT-Heavy";
    src: url('/assets/css/fonts/SUIT/SUIT-Heavy.ttf') format("truetype");
}

@font-face {
    font-family: "SUIT-ExtraBold";
    src: url('/assets/css/fonts/SUIT/SUIT-ExtraBold.ttf') format("truetype");
}

.rectangle {
    position: relative;
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.bg-color-red {
    background-color: #f56650;
}

.bg-color-yellow {
    background-color: #ffa812;
}

.bg-color-green {
    background-color: #00a65a;
}

.bg-color-green-2 {
    background-color: #34a853;
}

.bg-color-black {
    background-color: #000;
}


.font-black {
    color: #000;
}

.font-green {
    color: #00a65a;
}

.font-red {
    color: #f56650;
}

.font-white {
    color: #fff;
}

.font-666 {
    color: #666;
}

.font-bold-700 {
    font-family: "SUIT-Bold", Helvetica;
    font-weight: 700;
    letter-spacing: 0;
    line-height: normal;
}

.font-heavy-400 {
    font-family: "SUIT-Heavy", Helvetica;
    font-weight: 400;
    letter-spacing: 0;
    line-height: normal;
}

.whitebox-base {
    position: absolute;
    background-color: #fff;
    border-radius: 12px;
    overflow: hidden;
}

.title {
    position: relative;
    align-self: stretch;
    margin-top: -1px;
    font-size: 15px;
    color: #666;
}


.yellow_circle {
    display: flex;
    flex-direction: column;
    width: 30px;
    height: 30px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px;
    position: absolute;
    top: 0;
    left: 147px;
    background-color: #ffba00;
    border-radius: 20px;
}

.title_number {
    position: relative;
    width: fit-content;
    margin-top: -6.5px;
    margin-bottom: -4.5px;
    font-family: "SUIT-Heavy", Helvetica;
    font-weight: 400;
    color: #fff;
    letter-spacing: 0;
    line-height: normal;
    font-size: 20px;
}

.text-title {
    position: absolute;
    top: 42px;
    left: 0;
    font-family: "SUIT-ExtraBold", Helvetica;
    font-weight: 800;
    color: #151515;
    font-size: 36px;
    text-align: center;
    letter-spacing: 0;
    line-height: normal;
}

.text-subtitle {
    position: absolute;
    top: 87px;
    left: 22px;
    font-family: "SUIT-Regular", Helvetica;
    font-weight: 400;
    color: #999;
    font-size: 18px;
    text-align: center;
    letter-spacing: 0;
    line-height: normal;
}

.text-unit {
    position: relative;
    width: fit-content;
    color: #151515;
    font-size: 24px;
    text-align: right;
}


.img {
    position: relative;
    width: 16px;
    height: 16px;
}

.num-up {
    color: #e74646;
    font-size: 16px;
    position: relative;
    width: fit-content;
    margin-top: -1px;
    font-family: "SUIT-Bold", Helvetica;
    font-weight: 700;
    text-align: right;
    letter-spacing: 0;
    line-height: normal;
}

.num-down {
    color: #4673e7;
    font-size: 16px;
    position: relative;
    width: fit-content;
    margin-top: -1px;
    font-family: "SUIT-Bold", Helvetica;
    font-weight: 700;
    text-align: right;
    letter-spacing: 0;
    line-height: normal;
}

.data-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    align-self: stretch;
    position: relative;
    gap: 8px;
    width: 100%;
    flex: 0 0 auto;
}









.element {
    position: relative;
    width: 895px;
    height: 605px;
    background-color: #e8ebed;
}

.element .bg-logo {
    position: absolute;
    width: 473px;
    height: 135px;
    top: 0;
    left: 422px;
}

.element .logo {
    position: absolute;
    width: 58px;
    height: 66px;
    top: 48px;
    left: 58px;
}

.element .text-title {
    position: absolute;
    top: 122px;
    left: 58px;
    color: #151515;
    font-size: 48px;
    font-family: "SUIT-ExtraBold", Helvetica;
    font-weight: 800;
    letter-spacing: 0;
    line-height: normal;
}

.element .text-service_term {
    position: absolute;
    top: 244px;
    left: 58px;
    color: #7a7a7a;
    font-size: 20px;
}

.element .OS {
    width: 225px;
    height: 260px;
    top: 305px;
    left: 40px;
}

.element .app-icon {
    position: absolute;
    width: 72px;
    height: 72px;
    top: 47px;
    left: 77px;
    border-radius: 20px;
    border: 1px solid;
    border-color: #0000000d;
    /* background-image: url(https://c.animaapp.com/XyeV1pwN/img/app-icon@2x.png);
    background-size: cover;
    background-position: 50% 50%; */
}

.element .text-app_name {
    position: absolute;
    top: 126px;
    left: 60px;
    font-size: 20px;
    color: #151515;
}

.element .div {
    position: absolute;
    top: 15px;
    left: 16px;
    font-size: 15px;
    color: #666666;
}

.element .OS-2 {
    display: flex;
    width: 193px;
    align-items: flex-start;
    gap: 8px;
    position: absolute;
    top: 159px;
    left: 16px;
}

.element .div-2 {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 6px 8px;
    position: relative;
    flex: 1;
    flex-grow: 1;
    background-color: #999999;
    border-radius: 8px;
}

.element .img {
    position: relative;
    width: 16px;
    height: 16px;
}

.element .text-os_ver {
    position: relative;
    width: fit-content;
    margin-top: -0.5px;
    color: #ffffff;
    font-size: 12px;
}

.element .IOS {
    display: flex;
    width: 193px;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    position: absolute;
    top: 195px;
    left: 16px;
    background-color: #f1f1f1;
    border-radius: 8px;
    overflow: hidden;
}

.element .text-wrapper-3 {
    position: relative;
    width: fit-content;
    color: #666666;
    font-size: 12px;
}

.element .date {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    position: relative;
    flex: 0 0 auto;
}

.element .text-wrapper-4 {
    position: relative;
    width: fit-content;
    margin-top: -1px;
    color: #151515;
    font-size: 14px;
    text-align: right;
}

.element .text-wrapper-5 {
    position: relative;
    width: fit-content;
    color: #999999;
    font-size: 10px;
    text-align: right;
    font-family: "SUIT-Medium", Helvetica;
    font-weight: 500;
    letter-spacing: 0;
    line-height: normal;
    white-space: nowrap;
}

.element .box-base-1 {
    display: flex;
    flex-direction: column;
    width: 181px;
    height: 122px;
    align-items: flex-start;
    justify-content: space-between;
    padding: 16px;
}

.element .box-1 {
    top: 305px;
    left: 281px;
}

.element .box-2 {
    top: 305px;
    left: 478px;
}

.element .box-3 {
    top: 305px;
    left: 675px;
}

.element .box-4 {
    top: 443px;
    left: 281px;
}

.element .box-5 {
    width: 181px;
    height: 122px;
    top: 443px;
    left: 478px;
}

.element .box-6 {
    width: 181px;
    height: 122px;
    top: 443px;
    left: 675px;
}

.element .text-remain_days {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 2px;
    align-self: stretch;
    width: 100%;
    position: relative;
    flex: 0 0 auto;
}

.element .normal {
    color: #151515;
    position: relative;
    width: fit-content;
    margin-top: -1px;
    font-size: 40px;
    text-align: right;
}

.element .not {
    color: #e74646;
}

.element .font-24 {
    font-size: 24px;
}

.element .text-lock {
    position: absolute;
    top: 15px;
    left: 16px;
    color: #666;
    font-size: 15px;
}

.element .locked {
    display: flex;
    width: 66px;
    height: 66px;
    top: 40px;
    left: 57px;
    align-items: center;
    justify-content: center;
    gap: 2px;
    position: relative;
    border-radius: 33px;
    background-color: #ffe39b;
    overflow: hidden;
}

.element .lock {
    position: relative;
    width: 32px;
    height: 33.36px;
}

.element .box-6 .text-not_using {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 24px;
    position: absolute;
    top: 53px;
    left: 45px;
    background-color: #e8ebed;
    border-radius: 28px;
}

.element .not_using {
    position: relative;
    flex: 0 0 auto;
    color: #999;
}

I even tried to copy and paste the default.css to resources/views/vendor/mail/html/themes/default.css, but it doesn't work either.

Also tried to change the css styles to inline styles in stat.blade.php, then it works but not actually worked as the original style.

How can I make it work for this mail styling with css? Would it only worked with table tags?



via Chebli Mohamed

samedi 13 janvier 2024

Laravel livewire How to show data in table according to date

hello im new for laravel livewire im trying to foreach data to table by date wise.

EXAMPLE I taken attendance on 1/1/24 table header show DATE-1/1/24 AND ROW Show that date record if we not taken attendance on 2/1/24 than table Hader show DATE-2/1/24 AND ROW Show - means attendance not taken

example

   |  name    |    STD_ID   |    DATE-1/1/24   |   DATE-2/1/24 |  DATE-3/1/24 | DATE-4/1/24 |
   |  john    |    STD_01   |         P        |       -       |       P      |      A      |
   |  sean    |    STD_02   |         P        |       -       |       P      |      P      |

enter image description here

**CONTROLLER**
``
  $this->Data= Attendance::get();
  //This Code Use For Multiple Coleman Marg In single row by student_id 
 $grouped =  $this->Data->groupBy('student_id');
 $this->Attendance_Data = $grouped->all();
``

**BLADE VIEW**

`<table>
   <thead> 
       <tr> 
         <th>NAME</th>
         <th>STD_ID</th>
         <th>DATE-1/1/24</th>
         <th>DATE-2/1/24</th>
         <th>DATE-3/1/24</th>
         <th>DATE-......</th>
         <th>DATE-31/1/24</th>
  </thead>
<tbody>
  @foreach ($this->Attendance_Data as $key=>$Attendance_Datas)                                          
<tr> 
   <td></td>
   <td></td>
 @foreach ($Attendance_Datas as $key=>$Attendance)
   <td> </td>
 @endforeach  
</tr>
   @endforeach
   @endif 
    </tbody> 
</table> `

DATABASCE

id  |     name      |student_id   |  date_of_attendance |   attendance |
1   |    john       |    STD_01   |     2024-01-01      |       P      |
2   |    john       |    STD_01   |     2024-01-03      |       P      |
2   |    john       |    STD_01   |     2024-01-04      |       A      |
3   |    sean       |    STD_02   |     2024-01-01      |       P      |
4   |    sean       |    STD_02   |     2024-01-03      |       P      |
2   |    sean       |    STD_02   |     2024-01-04      |       P      |

i tryid in if and else but not get proper result



via Chebli Mohamed

vendredi 8 décembre 2023

FatalErrorException in Handler.php line 26

Uncaught TypeError: Argument 1 passed to App\Exceptions\Handler::report() must be an instance of Exception, instance of Error given, called in \vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\HandleExceptions.php on line 73 and defined in \app\Exceptions\Handler.php:26 Stack trace: #0 \vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\HandleExceptions.php(73): App\Exceptions\Handler->report(Object(Error)) #1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Error)) #2 {main} thrown

I have migrated one application from laravel 4.2 to laravel 5.0, placed all the code according to requirement and done composer update command but white executing this I am getting this error. Deleted the composer.lock file and vendor directly and done the composer update still getting this error.



via Chebli Mohamed

mercredi 6 décembre 2023

FatalErrorException in Handler.php line 26

While migrating to Laravel 5.0 from 4.2 I am getting this error

FatalErrorException in Handler.php line 26: Uncaught TypeError: Argument 1 passed to App\Exceptions\Handler::report() must be an instance of Exception, instance of Error given, called in \vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\HandleExceptions.php on line 74 and defined in C:\app\Exceptions\Handler.php:26 Stack trace: #0 \vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\HandleExceptions.php(74): App\Exceptions\Handler->report(Object(Error)) #1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Error)) #2 {main} thrown

I have migrated one application from laravel 4.2 to laravel 5.0, placed all the code according to requirement and done composer update command but white executing this I am getting this error.



via Chebli Mohamed

How can I use websockets in Flutter?

I am trying to implement WebSockets for a Laravel-Flutter project. For the Laravel side, I followed these steps. If you see anything wrong or missing, please feel free to say:

https://gist.github.com/emir-ekin-ors/79e670eb6ea970af38c476a8087c19ea

When I test it with Tinker, I can see the event in the dashboard. So I assume the Laravel part is working properly.

The problem is when I try to listen to the channel in Flutter. I can't see anything on the terminal. I tried to follow the documentation of the web_socket_channel package. I am open to all the suggestions since I know nothing about websockets. You can find the Flutter code below:


import 'dart:async';

import 'package:flutter/material.dart';
import 'package:web_socket_channel/web_socket_channel.dart';

void main() {
    runApp(MyApp());
}

class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
        return MaterialApp(
            home: MyWebSocketScreen(),
        );
    }
}

class MyWebSocketScreen extends StatefulWidget {
    @override
    _MyWebSocketScreenState createState() => _MyWebSocketScreenState();
}

class _MyWebSocketScreenState extends State<MyWebSocketScreen> {
    late final _channel;
    late StreamSubscription _streamSubscription;

    @override
    void initState() {
        super.initState();
        _channel = WebSocketChannel.connect(Uri.parse('wss://localhost:6001'));
        _streamSubscription = _channel.stream.listen((data) {
            print('Received: $data');
        }, onError: (error) {
            print('Error: $error');
        });
    }

    @override
    Widget build(BuildContext context) {
        return Placeholder();
    }

    @override
    void dispose() {
        _streamSubscription.cancel();
        _channel.sink.close();
        super.dispose();
    }
}

This is the NewMessage class in Laravel if it necessary:


<?php

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class NewMessage implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $message;

    public function __construct($message)
    {
        $this->message = $message;
    }

    public function broadcastOn(): array
    {
        return [
            new Channel('home'),
        ];
    }
}


via Chebli Mohamed

samedi 2 décembre 2023

I have encrypted data in the database how to decrypt it before displaying in the frontend in crocodic-studio / crudbooster?

I have the following form -

$this->form[] = ['label'=>'Client Name','name'=>'client_id','type'=>'select','validation'=>'required|integer|min:0','width'=>'col-sm-10','datatable'=>'client,client_name','datatable_where'=>'status=1'];
$this->form[] = ['label'=>'Client Code','name'=>'user_id','type'=>'select','validation'=>'required|integer|min:0','width'=>'col-sm-10','datatable'=>'cms_users,name','datatable_where'=>'id_cms_privileges = 3 and blocked=0','parent_select'=>'client_id'];

cms_users,name is encrypted using the laravel encryption - Crypt::encryptString($postdata['name'], env('ENC_KEY'));

Now the problem is when I am clicking on the Client name dropdown I get the encrypted value in the Client Code dropdown.

I want to decrypt the value before displaying to the Client Code dropdown. How to solve this issue??

enter image description here



via Chebli Mohamed

vendredi 1 décembre 2023

Laravel validation regex depends upon dependent answer

We have 2 questions 'temp_id_type' with Select Options 'A','B', 'C' 'temp_id' text field

Validation rule required on temp_id

  • requied_if:temp_id_type,A,B,C Also I need regex rule on temp_id
  • if temp_id_type=A - regex should match: ^[0-9]{13}$
  • if temp_id_type=B - regex should match: ^[0-9]{13,20}$
  • if temp_id_type=C - regex should match: ^[A-Z]{2}[0-9]{2}[A-Z0-9]{1,35}$


via Chebli Mohamed

mercredi 29 novembre 2023

Getting data from database in jquery

I want to get yeniseries values ​​from the database, i can use the API but I don't know what I should add to the javascript code, I would be happy if you help me.

var yeniSeries = [50, 80, 30];

window.addEventListener("load", function () {
  try {
    var grafikYapilandirma = {
      chart: {
        type: "donut",
        width: 370,
        height: 430,
      },
      colors: ["#622bd7", "#e2a03f", "#e7515a", "#e2a03f"],
      dataLabels: {
        enabled: false,
      },
      legend: {
        position: "bottom",
        horizontalAlign: "center",
        fontSize: "14px",
        markers: {
          width: 10,
          height: 10,
          offsetX: -5,
          offsetY: 0,
        },
        itemMargin: {
          horizontal: 10,
          vertical: 30,
        },
      },
      plotOptions: {
        pie: {
          donut: {
            size: "75%",
            background: "transparent",
            labels: {
              show: true,
              name: {
                show: true,
                fontSize: "29px",
                fontFamily: "Nunito, sans-serif",
                color: undefined,
                offsetY: -10,
              },
              value: {
                show: true,
                fontSize: "26px",
                fontFamily: "Nunito, sans-serif",
                color: "#1ad271",
                offsetY: 16,
                formatter: function (t) {
                  return t;
                },
              },
              total: {
                show: true,
                showAlways: true,
                label: "Total",
                color: "#888ea8",
                formatter: function (t) {
                  return t.globals.seriesTotals.reduce(function (n, e) {
                    return n + e;
                  }, 0);
                },
              },
            },
          },
        },
      },
      stroke: {
        show: true,
        width: 15,
        colors: "#0e1726",
      },
      series: yeniSeries,
      labels: ["Online", "Offline", "Rest"],
      responsive: [
        { breakpoint: 1440, options: { chart: { width: 325 } } },
        { breakpoint: 1199, options: { chart: { width: 380 } } },
        { breakpoint: 575, options: { chart: { width: 320 } } },
      ],
    };

    var grafik = new ApexCharts(
      document.querySelector("#chart-2"),
      grafikYapilandirma,
    );

    grafik.render();

    document
      .querySelector(".theme-toggle")
      .addEventListener("click", function () {
        var yeniSeries = [200, 300, 500];

        grafik.updateOptions({ series: yeniSeries });
      });
  } catch (hata) {
    console.log(hata);
  }
});

I would appreciate it if you could help, thank you



via Chebli Mohamed

mardi 28 novembre 2023

"Resolving Country Code Bug: How to Fix the country code?"

 <div class="form-group">
                     <label class="form-label required"></label>
                                <input  class="form-control mobilenumber @error('mobile') is-invalid @enderror phone"
                                    type="tel" id="number" name="mobile" onkeypress='validate(event)'>

                                <input type="hidden" id="code" name="countrycode" value="1">

                                @error('mobile')
                                    <div class="invalid-feedback d-block">
                                        
                                    </div>
                                @enderror
                            </div>

Here i want my country code will be bangladesh and it will be fixed.



via Chebli Mohamed

Selenium Appium App Crashed And Returns A Failed Cases

So I have a Selenium Appium Python script for my testing purpose. I created the UI website using Laravel.

My script consists of around 3 test cases: def test_login_success def test_less_phone_number def test_more_phone_number

this is my LoginScriptController:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Storage;

class LoginScriptController extends Controller
{
    public function runLoginScript()
    {
        $command = 'pytest ../automation/app.py -k "test_login_success or test_less_phone_number or test_more_phone_number" 2>&1';
        exec($command, $output, $returnCode);

        if ($returnCode === 0) {
            return response('Script executed successfully', 200);
        } else {
            return response('Script encountered an error', 500);
        }
    }
}

When I click the button "Run test" on my website UI, the app always breaks down (crashed) and the first test case stopped (returns a Failed status). I already tried running it manually from my terminal using pytest app.py -k "test_login_success or test_less_phone_number or test_more_phone_number" but it works ok (returns PASSED status for all cases).

I can't find what's making my app breaks down



via Chebli Mohamed

jeudi 23 novembre 2023

How to print Api response data as collection

I was trying to print API response data as collection on blade for that i have used following line

$customers =   collect(json_decode($response, true));

But whenever i tried to print with following code:

 @foreach($customers as $row)
    <tr>
      <td> </td>
      <td></td>
      <td></td>
      <td></td>
    </tr>
  @endforeach 

it shows bellow error, What's the problem here?

Attempt to read property "first_name" on array

Here is the API response:

Illuminate\Support\Collection {#341 ▼ // app\Http\Controllers\IntegrationController.php:61
  #items: array:1 [▼
    "customers" => array:3 [▼
      0 => array:27 [▼
        "id" => 6895839936762
        "email" => "russel.winfield@example.com"
        "accepts_marketing" => false
        "created_at" => "2023-10-20T11:06:26-04:00"
        "updated_at" => "2023-10-20T11:06:26-04:00"
        "first_name" => "Russell"
        "last_name" => "Winfield"
        "orders_count" => 0
        "state" => "disabled"
        "total_spent" => "0.00"
        "last_order_id" => null
        "note" => "This customer is created with most available fields"
        "verified_email" => true
        "multipass_identifier" => null
        "tax_exempt" => false
        "tags" => "VIP"
        "last_order_name" => null
        "currency" => "USD"
        "phone" => "+16135550135"
        "addresses" => array:1 [▶]
        "accepts_marketing_updated_at" => "2023-10-20T11:06:26-04:00"
        "marketing_opt_in_level" => null
        "tax_exemptions" => []
        "email_marketing_consent" => array:3 [▶]
        "sms_marketing_consent" => array:4 [▶]
        "admin_graphql_api_id" => "gid://shopify/Customer/6895839936762"
        "default_address" => array:17 [▶]
      ]
      1 => array:26 [▶]
      2 => array:26 [▶]
    ]
  ]
  #escapeWhenCastingToString: false
}


via Chebli Mohamed

Laravel notification via method changes not coming in toMail method

I have one class where I calculate variables in via method and the same variable I want to use in toMail method but it's always null in the toMail Method. any idea why?

class FinancialQuestionnaireSubmissionNotification extends Notification implements ShouldQueue
{
    use Queueable,SerializesModels, GlobalMailHelperTrait;

    public Lead $lead;
    public $code;

    public function __construct(Lead $lead)
    {
        $this->lead = $lead->fresh();         
                          
    }
    public function via($notifiable)
    {

        $this->code = 'xyz';            
       
        return ['mail'];
    }
    /**
     * Get the mail representation of the notification.
     */
    public function toMail($notifiable)
    {                    
        dd($this->code);
    }   

    /**
     * Get the array representation of the notification.
     */
    public function toArray($notifiable)
    {
        return [
            //
        ];
    }
}

here my $this->code is always null why even after setting that variable in via method!



via Chebli Mohamed

mardi 21 novembre 2023

Laravel Nova Panel Form Fields Update issue

I am working on nova panel in localhost.. When i perform update my form fields that time i will see this warning...

"Another user has updated this resource since this page was loaded. Please refresh the page and try again."

also i am getting (409 - Conflict) in ajax.

any solution for that?

I will perform cache clear operation

php artisan config:clear

php artisan route:clear

php artisan view:clear


via Chebli Mohamed

samedi 18 novembre 2023

Quantized feature maps with Kmeans, then visualize them on the original image

I extracted feature maps using ResNet, then quantized (segmented) using Kmeans. Now I want to visualize the quantized feature maps (labels) on the input image using Kmeans. Does anyone have an idea how I can do this?

 model = models.resnet18(weights='ResNet18_Weights.DEFAULT')
    model_children = list(model.children())
    feature_extractor = torch.nn.Sequential(\*list(model.children())\[:-2\])

    feature_extractor.eval()

    image_path = 'image.jpg'
    transform = transforms.Compose(\[
    transforms.Resize((224, 224)),
    transforms.ToTensor(),
    transforms.Normalize(mean=0., std=1.)
    \])
    image = transform(Image.open(image_path)).unsqueeze(0)

    with torch.no_grad():
    feature_maps = feature_extractor(image)

    feature = feature_maps.squeeze(0)
    feature = feature.view(512, -1)
    feature = feature.detach().numpy()
    feature= np.transpose(feature)

    \#Kmeans Algorithm
    num_clusters = 10
    kmeans = KMeans(n_clusters=num_clusters,n_init='auto', random_state=0).fit(feature)

    labels = kmeans.labels\_
    labels= labels.reshape(7,7)
    plt.imshow(labels)
    plt.show()


via Chebli Mohamed

vendredi 17 novembre 2023

Laravel 5.8: Laravel Passport API Authentication Issue Outside php artisan serve

I am encountering an authentication problem with my Laravel API when attempting to run it without using php artisan serve. I have implemented Passport for authentication.

The authentication process works seamlessly when using php artisan serve and accessing http://127.0.0.1:8000/api/login in tools like Insomnia. However, I am facing issues when trying to run the Laravel backend independently and connecting it to an Angular frontend.

Despite exploring various solutions suggested online, including updating the .htaccess files in both the root and public folders, the API consistently returns an "unauthenticated" error.

I would appreciate any guidance or assistance in resolving this issue. If anyone has encountered a similar problem or can provide insights into how to make Laravel Passport authentication work outside of php artisan serve, your help would be greatly appreciated.

Thank you in advance for your time and assistance.

  • Updated the .htaccess files in both the root and public folders as recommended in online resources.
  • Checked the Laravel Passport configuration for any misconfigurations.
  • Verified that the Laravel backend is accessible outside of php artisan serve.
  • Ensured that the Angular frontend is making requests to the correct API endpoints.
  • Checked for any relevant error messages in the Laravel logs.

Expectation:

I expected the Laravel Passport authentication to work seamlessly when the backend is accessed independently (without using php artisan serve) from my Angular frontend. However, despite these efforts, the API consistently returns an "unauthenticated" error.



via Chebli Mohamed

dimanche 12 novembre 2023

Laravel project code not refelcting changes to view files

I created a laravel(5.1.3) project with breeze as the starter kit. I am planning to use the react as frontend to this project. I run the 'php artisan serve' command. The boiler plate template is working but any changes to files /resources/js/Pages/Welcome.jsx or /resources/views/welcome.blade.php is not reflecting. I have tried

  1. clearing the storage/framework/views folder ,
  2. run command php artisan view:clear ,
  3. run command php artisan config:clear ,
  4. run command composer dump-autoload ,

Still no change to the initial view. What am I doing wrong?

And I configured to make react as frontend library so I don't need the welcome.blade.php file right?



via Chebli Mohamed

samedi 11 novembre 2023

How to send multiple data from view to controller laravel

i want to send data from view to controller ..i.e. 1st card click send id =5 , 2nd card click send id = 6 etc...I can't find answer anywhere on google ...any help will be appreciated...thanks

i tried sendind the variable even aaray by form ..but i am not able to get the desired output.As i said i want to send data on card conditions ..for card 1 send id = 5 , card 2 send id = 6 ..so on

Here is my Code ...

@foreach ($role as $d)
      <form class="form-signin" id="agentPassword" method="POST" action="">
         
        <div class="card_dash card-1" onClick='submitDetailsForm()'>
          <h3>    
          
          <img src="/assets_web/app-icon/icon/web-icon/bix42_" id="role" alt="img">
            <input type="hidden" name="roleInfo[]" value="">
            <!-- <input type="hidden" name="role" value=""> -->
          </h3>
        </div>
      </form>
      @endforeach

the id value in already in $d[1] ...its even better if i can send the whole array $d.



via Chebli Mohamed

Hii i am create a new laravel project in laravel 5.1.3 version and my php version is 8.2.12.please help me to solve this errors

Problem 1 - laravel/framework[v10.10.0, ..., v10.31.0] require league/flysystem ^3.8.0 -> satisfiable by league/flysystem[3.8.0, ..., 3.19.0]. - league/flysystem[3.3.0, ..., 3.14.0] require league/mime-type-detection ^1.0.0 -> satisfiable by league/mime-type-detection[1.0.0, ..., 1.14.0]. - league/flysystem[3.15.0, ..., 3.19.0] require league/flysystem-local ^3.0.0 -> satisfiable by league/flysystem-local[3.15.0, 3.16.0, 3.18.0, 3.19.0]. - league/mime-type-detection[1.0.0, ..., 1.3.0] require php ^7.2 -> your php version (8.2.12) does not satisfy that requirement. - league/mime-type-detection[1.4.0, ..., 1.14.0] require ext-fileinfo * -> it is missing from your system. Install or enable PHP's fileinfo extension. - league/flysystem-local[3.15.0, ..., 3.19.0] require ext-fileinfo * -> it is missing from your system. Install or enable PHP's fileinfo extension. - Root composer.json requires laravel/framework ^10.10 -> satisfiable by laravel/framework[v10.10.0, ..., v10.31.0].

To enable extensions, verify that they are enabled in your .ini files: - C:\Program Files\php-8.2.12\php.ini

Hii i am create a new laravel project in laravel 5.1.3 version and my php version is 8.2.12.please help me to solve this errors. i have enabled the file-info extension then also same error.



via Chebli Mohamed