dimanche 4 avril 2021

Laravel Class 'Mike42\Escpos\PrintConnectors\FilePrintConnector' not found

I am building an application that uses thermal printer and I found the Mike42/Escpos library.

I am using laravel for my application

I have installed the library in my application

but I am getting the following error.

Class 'Mike42\Escpos\PrintConnectors\FilePrintConnector' not found

Composer.json

{
   "require": {
       "spatie/laravel-backup": "^6.11",
       "mike42/escpos-php": "^3.0"
   }
}

Web.php

use Illuminate\Support\Facades\Route;
use Mike42\Escpos\PrintConnectors\FilePrintConnector;
use Mike42\Escpos\Printer;
Route::get('/', function () {
   $connector = new FilePrintConnector("XP-58IIH");
   $printer = new Printer($connector);
   $printer -> text("Hello World!\n");
   $printer -> cut();
   $printer -> close();
});

How do I solve this problem?



via Chebli Mohamed

samedi 3 avril 2021

Grammar::parameterize(): Argument #1 ($values) must be of type array, string given, called

This is my Controller named "AttendanceController". This is my Controller named "AttendanceController"

public function index()
{
    $attendances = Attendance::orderBy('date', 'desc')->paginate(50);
    $students = Student::all();
    return view('attendances.index', compact('attendances', 'students'));
}
public function create()
{
    $students = Student::all();
    return view('attendances.create', compact('students'));
}
public function store(Request $request)
{
    $students = Student::all();
    $request->validate(array(
        'attendance' => 'required',
        'date' => 'required',
    ));

    $attendance = Attendance::create(array(
        'attendance' => $request->input('attendance'),
        'date' => $request->input('date'),
    ));

    return redirect()->route('attendances.index')->withSuccess('Done');
}

This is my attendances.create where There is form to submit. This is my attendances.create where There is form to submit.

<form method="post" action="">
        @csrf
        <table>

                <tr>
                    <th><p style="margin: 20px">Name : </p></th>
                    <th><p style="margin: 20px">Attendance : </p></th>
                    <th><p style="margin: 20px">Date : </p></th>
                </tr>
            @foreach ($students as $student)
                <tr>
                    <th><p style="margin: 20px"></p></th>
                    <input name="id[]" type="hidden" value="">
                    <th><p style="margin: 20px">
                        <select name="attendance[]" id="attendance">
                            <option value="present">present</option>
                            <option value="absent">absent</option>
                            <option value="half_day">half day</option>
                        </select></p>
                    </th>
                    <th><p style="margin: 20px"><input type="date" class="form-control" name="date[]"></p></th>
                </tr>

            @endforeach
            <td><button class="btn btn-primary" name="submit" id="submit">Submit</button></td>
        </table>
    </form>


via Chebli Mohamed

Laravel Debugbar not working when running project without php artisan serve

laravel debugbar not working when running project without php artisan serve

Package Name - barryvdh/laravel-debugbar Version - 3.0

When I am running my project using php artisan serve Debugbar is showing fine at the bottom but when I am running my project using virtual host It is not showing.

Thanks in Advance!



via Chebli Mohamed

How to resend email verification link in Laravel 5.6

Using jrean/laravel-user-verification for User Verification.

The documentation shows the following for resending the verification token.

If you want to regenerate and resend the verification token, you can do this with the following two lines:

UserVerification::generate($user);
UserVerification::send($user, 'My Custom E-mail Subject');

The generate method will generate a new token for the given user and change the verified column to 0. The send method will send a new e-mail to the user.

I have created a method resendEmail using the above documentation.

public function resendEmail() {
    $user = Auth::user();

    UserVerification::generate($user);
    UserVerification::send($user, 'User Verification', config('mail.recieve_to.address'), config('mail.recieve_to.name'));

    return view('home')->with('success','Check your email for verification link!');
}

The receiving email address receives the email with verification link. However, clicking the verification link throws the following error

Jrean \ UserVerification \ Exceptions \ UserNotVerifiedException
This user is not verified.

Routes

Route::get('resend-email', 'HomeController@resendEmail')->name('resend-email');

Route::group(['middleware' => 'isVerified'], function () {
  Route::get('email-verification/error', 'Auth\RegisterController@getVerificationError')->name('email-verification.error');
  Route::get('email-verification/check/{token}', 'Auth\RegisterController@getVerification')->name('email-verification.check');
});

What am I doing wrong?



via Chebli Mohamed

Grammar::parameterize(): Argument #1 ($values) must be of type array, string given, called in

This is my create page. Here there is form in foreach loop having on submit button. (This is my create page. Here there is form in foreach loop having on submit button.)

<form method="post" action="">
        @csrf
        <table>

                <tr>
                    <th><p style="margin: 20px">Name : </p></th>
                    <th><p style="margin: 20px">Type : </p></th>
                    <th><p style="margin: 20px">Date : </p></th>
                </tr>
            @foreach ($students as $student)
                <tr>
                    <th><p style="margin: 20px"></p></th>
                    <input name="name[]" type="hidden" value="">
                    <th><p style="margin: 20px">
                        <select name="type[]" id="type">
                            <option value="present">present</option>
                            <option value="absent">absent</option>
                            <option value="half_day">half day</option>
                        </select></p>
                    </th>
                    <th><p style="margin: 20px"><input type="date" class="form-control" name="date[]"></p></th>
                </tr>

            @endforeach
            <td><button class="btn btn-primary" name="submit" id="submit">Submit</button></td>
        </table>
    </form>

This is my TypeController. This is my TypeController. I want to store data in foreach loop. (This is my TypeController. This is my TypeController. I want to store data in foreach loop)

public function index()
{
    // $types = Type::all();
    $types = Type::orderBy('date', 'desc')->paginate(50);
    $students = Student::all();
    return view('types.index', compact('types', 'students'));
}
public function create()
{
    $students = Student::all();
    return view('types.create', compact('students'));
}
public function store(Request $request)
{
    $request->validate([
        'name' => 'required',
        'type' => 'required',
        'date' => 'required',
    ]);

    $type = Type::create([
        'name' => $request->input('name'),
        'type' => $request->input('type'),
        'date' => $request->input('date'),
    ]);

    return redirect()->route('types.index')->withSuccess('Done');
}

This is my Type model which has relation with Student table (This is my Type model which has relation with Student table)

use HasFactory;

protected $table = 'students';

protected $fillable = [
    'name',
];

public function type()
{
    return $this->hasMany(Type::class);
}


via Chebli Mohamed

in object merze another object

i have an object like given below i wanted to formate like

         variation": [
            {
                "Color": "Red",
                "Size": "XS",
                "din": "10190537",
                "product_id": 55,
                "name": {
                    "0": "Color",
                    "1": "Size"
                },
                "value": {
                    "0": "Red",
                    "1": "XS"
                }
            }
        ],

Expected Object like given

          `variation": [
            {
                "Color": "Red",
                "Size": "XS",
                "din": "10190537",
                "product_id": 55,
                data: [
                       {
                         name:Color,
                         value:Red
                       }
                       {
                         name:Size,
                         value:XS
                       }
                    ]
                },

            }
        ]`

i am not able to found proper solution please help me

thanks..........



via Chebli Mohamed

vendredi 2 avril 2021

How To submit form by one submit button in foreach loop in laravel?

This is my create page. Here there is form in foreach loop having on submit button. (This is my create page. Here there is form in foreach loop having on submit button.)

<form method="post" action="">
        @csrf
        <table>
            @foreach ($students as $student)

                <tr>
                    <td>Name : </td>
                    <td><input type="text" class="form-control" name="name" value="" readonly></td>
                </tr>
                <tr>
                    <td>Type : </td>
                    <td>
                        <select name="type" id="type">
                            <option value="present">present</option>
                            <option value="absent">absent</option>
                            <option value="half_day">half day</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>Date : </td>
                    <td><input type="date" class="form-control" name="date"></td>
                </tr>

            @endforeach
            <button class="btn btn-primary" name="submit" id="submit">Submit</button>
        </table>
    </form>

This is my TypeController. This is my TypeController. I want to store data in foreach loop. (This is my TypeController. This is my TypeController. I want to store data in foreach loop)

public function create()
{
    $students = Student::all();
    return view('types.create', compact('students'));
}
public function store(Request $request)
{
    $request->validate([
        'name' => 'required',
        'type' => 'required',
        'date' => 'required',
    ]);

    $type = Type::create([
        'name' => $request->input('name'),
        'type' => $request->input('type'),
        'date' => $request->input('date'),
    ]);

    return redirect()->route('types.index')->withSuccess('Done');
}

This is my Type model which has relation with Student table (This is my Type model which has relation with Student table)

use HasFactory;

protected $table = 'types';

protected $fillable = [
    'name',
    'date',
];

public function student()
{
    return $this->belongsTo(Student::class);
}


via Chebli Mohamed