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