lundi 12 juin 2023

filters the data of a school to which the user belongs

I want to display the list of students from a school the user belongs to and not display data from other schools. for that I created two user tables: id , school_id school table: id, name, address,.... student table: id,school_id,name,address,.... I want to display the students of the school to whom this user belongs the display is done in browse.blade.php generated by voyageur how can i make this filter Thank you for help

the user belongs to a company and can only see data from that school I have a browse in /views/students that shows students from all schools



via Chebli Mohamed

dimanche 11 juin 2023

dependent drop in laravel with ajax doesn't work

**this is the blade **


    
                            <label class="form-label" for="basic-default-password12">اختر فصل دراسي</label>
                            <div class="input-group">
                                <span class="input-group-text" id="basic-addon11"><i class='bx bx-category-alt bx-tada'
                                        style='color:black'></i></span>
                                <select type="text" name="semester_id" class="form-control">
                                    <option value="">None</option>
                                    @foreach ($semesters as $key => $semester)
                                        <option value=""></option>
                                    @endforeach
                                </select>
                            </div>
                            <label class="form-label" for="basic-default-password12">اختر مرحلة دراسية</label>
                            <div class="input-group">
                                <span class="input-group-text" id="basic-addon11"><i class='bx bx-category-alt bx-tada'
                                        style='color:black'></i></span>
                                <select type="text" name="stage_id" class="form-control">
                                    <option value=""></option>
                                </select>
                            </div>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.0/jquery.min.js"
        integrity="sha512-3gJwYpMe3QewGELv8k/BX9vcqhryRdzRMxVfq6ngyWXwo03GFEzjsUm8Q7RZcHPHksttq7/GFoxjCVUjkjvPdw=="
        crossorigin="anonymous" referrerpolicy="no-referrer"></script>


    <script type="text/javascript">
        $(document).ready(function() {
            $('select[name="semester_id"]').on('change', function() {
                var semester_id = $(this).val();
                if (semester_id) {
                    $.ajax({
                        url: "/" + semester_id,
                        type: "GET",
                        dataType: "json",
                        success: function(data) {
                            $('select[name="stage_id"]').html('');
                            var d = $('select[name="stage_id"]').empty();
                            $.each(data, function(key, value) {
                                $('select[name="stage_id"]').append(
                                    '<option value="' + value.id + '">' + value
                                    .stage_name + '</option>');
                            });
                        },

                    });
                } else {
                    alert('danger');
                }
            });
        });
    </script>


   satgecontroller

`public function GetStage($semester_id){         $data = Stage::where('semester_id',$semester_id)->orderBy('stage_name','ASC')->get();             return json_encode($data);      }`

**this is th web.php **


`Route::controller(StageController::class)->group(function(){
    Route::get('/stage/ajax/{semester_id}' , 'GetStage');

});`

i want to get the stage by semester_id when i choose the semester but when i choose any thing in semester the stage doesn't show me any results why my code doesn't work?

I have made several many attempts, but nothing works and I do not know why when I put Ajax CDN in the admin dashboard and restore it via

@extend(admin.admin.dashboard) 

a path that does not work, it requires me to put it in the same code



via Chebli Mohamed

samedi 10 juin 2023

Uncaught Error: Class "IlluminateFoundationApplication" not found

PHP Fatal Error:  Uncaught Error: Class "IlluminateFoundationApplication" not found in /home/prasaanth/myport/bootstrap/app.php:14
Stack trace: #0 /home/prasaanth/myport/artisan(20): require_once()
#1 {main} 
thrown in /home/prasaanth/myport/bootstrap/app.php on line

When I try to create a Laravel project, it is creating without a vendor file. Some other files are missing, and the  console is showing this error. Also, when I run the Artisan server, the same error is coming.

I had tried by creating new project and modify the composer



via Chebli Mohamed

mercredi 7 juin 2023

Make Reset APIs without sanctum

(using POSTMAN and Only Laravel api.php routes and Middleware and Don’t use any external packages, also don’t forget to secure your API routes with a KEY)

Description: 1 - Create authentication API for user login and register.

2 - make end-point for profile which get user profile data (name, email, photo, age, etc..).

3 – let’s assume we have (categories, subcategories and user_subcategories table) and each category have some Subcategories for example (development category has subcategories (front-end, back-end, flutter and UI)) and we have a user in development category and he has only two subcategories in user_subcategories table,

(challenge: what’s the best way to view all these relations if the mobile app Requests a user profile data with categories?), show this API in a Laravel project

I searched for any explanation without the sanctum, but I did not find it



via Chebli Mohamed

Why Laravel passport login suddenly not working?

I am getting error for when try to login. I am not update any package at all but suddenly getting this error.

There was an error while creating the signature: error:0909006C:PEM routines:get_name:no start line

But i am sure that the key file is in the correct format:

storage/oauth-private.key -----BEGIN RSA PRIVATE KEY----- KEY VALUE -----END RSA PRIVATE KEY-----

storage/oauth-public.key -----BEGIN PUBLIC KEY----- KEY VALUE -----END PUBLIC KEY-----

Any idea ? I am using Laravel 5.7, Passport 7.5.1, PHP 7.2.24.

Fix the error

There was an error while creating the signature: error:0909006C:PEM routines:get_name:no start line

on vendor/lcobucci/jwt/src/Signer/OpenSSL.php:27



via Chebli Mohamed

mardi 6 juin 2023

Dispatch on laravel 5.6 won't run function handle(), only run construct()

Hi i try to create queue job, using queue=redis in laravel 5.2 But i've checked using log, my job only run construct() not running handle()

can you suggest what's wrong?

my dispatch scheme like this :

Controller -> dispatch -> dispatch_now() -> dispatch_now()

here is my code :

class LogHelper implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected $transId;

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

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle(){
       //do code
    }
}

expecting of those job was running normally like normal job and code excuted



via Chebli Mohamed

lundi 5 juin 2023

Is there any ready-made solution or code available in Laravel for Users, Access, Locations Management etc

IN Laravel : Is there any ready-made solution or code which includes common area for project (for avoiding repetitive task such as User management, Access management, Location based access, Department based access etc.)

(Ready made common needs area to make new projects)



via Chebli Mohamed