mardi 17 novembre 2020

How to pass data id to modal?

i need to pass the dropdown id value once been selected. The id must be pass to modal.

This is my code for view :

<div class="panel panel-default">
    <div class="panel-heading">
        <h4></h4>
    </div>
    <div class="panel-body">
        <div class="form-horizontal">
            <label class="col-lg-2 control-label">{!! msg('lbl_education_level') !!}</label>
            <div class="col-lg-4">
                {!! Form::dropdown('education_level_id', $edulevelselection, '', 'class="select2-form edulevel"') !!}
            </div>
            <span>
                    {!! Form::buttonAdd('','#',[
                    'data-toggle' => 'modal',
                    'id' => 'education',
                    'data-title' => msg('lbl_new_academic_qualification'),
                    'data-target' => '#modal_global_form',
                    'data-url' => route('academic_qualification.create', [ 'id' => $staff_id] ),
                    'data-action' => route('academic_qualification.store'),
                    'data-size' => 'modal-lg',
                    'data-param' => '{ }'
                    ]) !!}
                </span>
        </div>
    </div>
</div>
@push('scripts')
<script type="text/javascript">

$('#education_level_id').change(function(e){
    var edulevelid = $('#education_level_id').val();
    console.log(edulevelid);
    $('#education').attr('data-param','{"education_level_id":'+edulevelid+'}');
})

</script>
@endpush

But the value i want is not show up, i do the dump() at the controller. it just show my id only. Supposedly from the dropdown form should include in the dump. This is the dump i make on the controller:

enter image description here



via Chebli Mohamed

Why Laravel Sanctum SPA Authentication always keep the user logged in?

I used Laravel Sanctum SPA authentication. I can log out the user but I am wondering why is it that the user is still logged in even when I close the browser. I don't even implement the remember me function.



via Chebli Mohamed

lundi 16 novembre 2020

How to send SMS using firebase in laravel

I am developing a laravel application,in which while user register, i want to send the registration code through SMS, i don't want to use any paid services.I heard about firebase free SMS gateway. Is there any option to send SMS through firebase



via Chebli Mohamed

Relation query undefined method

In my setting model class i have this

public function user()
    {
        return $this->hasMany('App\User');
    }

and in my user model class i have this

 public function settings()
    {
        return $this->belongsTo('App\settings', 'id');
    }

I tried both these queries, trying to get the user information but failed.

$data = DB::table('settings')
                        ->where('id', '=', $id)
                        ->get()
                        ->toArray();

and

$table = \App\settings::where('id', '=', $id);
        $query = $table->user()
                       ->get()
                       ->toArray();

I'm getting this error

Call to undefined method Illuminate\Database\Eloquent\Builder::user()

How do you do relation query? Sorry new to laravel here.



via Chebli Mohamed

Store data into database using request json string in laravel

I am having a table name Student ( id , name , division ). To store data into this table I am sending json string as a request to the api in laravel.

Request json string is,

{
"name":"abc",
"division":"a",
"city":"xyz"
}

Controller Code

 public function registerStudent(Request $request){

    $requestData = $request->json()->all(); 
    $studentModel = Student::create($requestData);

 }

Student Model

class Student extends Model
{
    protected $fillable = [
        'id', 'name','division'
    ];

   
}

When i execute this code , i get the following error,

Illuminate\Database\QueryException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'city' in 'field list' (SQL: insert into `Student`... 

now my question here is, in what way I can store the data into database from json request with having extra keys into json object/array.



via Chebli Mohamed

Ayuda no funciona Laravel imdhemy/laravel-in-app-purchases verificar comprar de android en latravel

uso laravel 5.8 y estoy tratando de integrar mi backend con las compras de android he usado esta biblioteca de laravel llamada Laravel In-App purchase

y he recibido este error todo el tiempo, pues falta una clase que no se encuentra:

use Imdhemy\Purchases\Facades\Subscription;

alguien a usado esta clase y le a funcionado?



via Chebli Mohamed

Laravel route not found when route exists

When I try to access my laravel site I get this error in the console.

Laravel development server started: <http://127.0.0.1:8000>
[Mon Nov 16 10:39:15 2020] PHP Fatal error:  Uncaught InvalidArgumentException: Route [home] not defined. in /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php:389
Stack trace:
#0 /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(822): Illuminate\Routing\UrlGenerator->route('home', Array, true)
#1 /Users/threeaccents/code/src/gitlab.com/few/bodylove/storage/framework/views/e071ac62e490c49233841ae8b6b3906075bc0187.php(6): route('home')
#2 /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(43): include('/Users/threeacc...')
#3 /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(59): Illuminate\View\Engines\PhpEngine->evaluatePath('/Users/threeacc...', Array)
#4 /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/View/View.php(142): Illuminate\Vi in /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php on line 389
[Mon Nov 16 10:39:15 2020] PHP Fatal error:  Uncaught InvalidArgumentException: Route [home] not defined. in /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php:389
Stack trace:
#0 /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(822): Illuminate\Routing\UrlGenerator->route('home', Array, true)
#1 /Users/threeaccents/code/src/gitlab.com/few/bodylove/storage/framework/views/e071ac62e490c49233841ae8b6b3906075bc0187.php(6): route('home')
#2 /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(43): include('/Users/threeacc...')
#3 /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(59): Illuminate\View\Engines\PhpEngine->evaluatePath('/Users/threeacc...', Array)
#4 /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/View/View.php(142): Illuminate\Vi in /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php on line 389

But route home is clearly defined. I even set it at the top of my route file to make sure nothing else was overriding it.

routes/web.php
<?php

// New Home Page for App
Route::get('/', 'Web\HomeController@index')->name('home');

...

with php artisan route:list

+--------+----------------------------------------+--------------------------------------------------------------------------------------------+--------------------------------------------+------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Domain | Method                                 | URI                                                                                        | Name                                       | Action                                                                                         | Middleware                                                                                                                                                                        |
+--------+----------------------------------------+--------------------------------------------------------------------------------------------+--------------------------------------------+------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|        | GET|HEAD                               | .well-known/apple-developer-merchantid-domain-association                                  |                                            | App\Http\Controllers\Web\ApplePayDomainVerificationController                                  | web                                                                                                                                                                               |
|        | GET|HEAD                               | /                                                                                          | home                                       | App\Http\Controllers\Web\HomeController@index                                                  | web                                                                                                                                                                               |

Update

I've cleared route cache, deleted vendor folder, re-installed PHP but nothing seems to solve the issue.

I've tried it on my work laptop (same setup) and everything works. It seems to be an issue with my current station but I'm not sure what would be causing it. I'm using PHP 7.2 on a mac os 10.14.4

I also thought maybe it was an overall system issue but if I create a new laravel project everything works as expected so it does seem to be a project specific issue.



via Chebli Mohamed