ottaviane

ottaviane

Member Since 4 Months Ago

Experience Points 580
Experience Level 1

4,420 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 1
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

09 Jun
1 week ago

ottaviane left a reply on Routing Not Working

thanks for replay. I resolved. I used in a html tab a for for row!!!! Now it works using js to dinamically change methods in a unique form. Thank you.

08 Jun
1 week ago

ottaviane left a reply on Routing Not Working

hi all. I have this route:

Route::group(['namespace' => 'Magazzino', 'prefix' => 'Magazzini'], function()
{
  Route::resource('/', 'MagazziniController');
});

infact php artisan route:list gives

|        | POST      | Magazzini                          | store               | App\Http\Controllers\Magazzino\[email protected]               | web                          |
|        | GET|HEAD  | Magazzini                          | index               | App\Http\Controllers\Magazzino\[email protected]               | web                          |
|        | GET|HEAD  | Magazzini/create                   | create              | App\Http\Controllers\Magazzino\[email protected]              | web                          |
|        | DELETE    | Magazzini/{}                       | destroy             | App\Http\Controllers\Magazzino\[email protected]             | web                          |
|        | PUT|PATCH | Magazzini/{}                       | update              | App\Http\Controllers\Magazzino\[email protected]              | web                          |
|        | GET|HEAD  | Magazzini/{}                       | show                | App\Http\Controllers\Magazzino\[email protected]                | web                          |
|        | GET|HEAD  | Magazzini/{}/edit                  | edit                | App\Http\Controllers\Magazzino\[email protected]                | web                          |

and routing to index() and to create() works very good. But when I call mysite/Magazzini/1 for example, routing don't works. I made this form:

  <form id='deleteform' class="" action="/Magazzini/{{ $mag->id }}" method="POST" enctype="multipart/form-data">
      @method("DELETE")
      @csrf
      
    </form>

and when I submit it I receive a 404 error end the funtion

public function destroy($id)
    {
        dd($id);
    }

of my controller isn't called. I'm not able even call update and show methods of my controller. What appened? thanks. bye.

ottaviane started a new conversation Routing Not Working

routing not working

23 May
3 weeks ago

ottaviane left a reply on Not Display Properly Bootstrap Div With Laravel App

I think it's a HTML error. Have you debugged Page Source? Normally, to find those mistakes, I use 'inspect element' function, or Page Source in my browser. php and Blade seems to be ok.

ottaviane left a reply on Change Database Dynamically

googling I found it:

//get old dbname
$oldDbName = env("DB_DATABASE");


$env = new DotenvEditor();
$env->changeEnv([
   'DB_HOST' => $request['hostname'],
   'DB_DATABASE' => $request['dbname'],
   'DB_USERNAME' => $request['username'],
   'DB_PASSWORD' => $request['dbpassword'],
]);

DB::disconnect(env("DB_CONNECTION"));

Config::set('database.connections.' . env("DB_CONNECTION"), array(
        'driver'    => 'mysql', //or $request['driver'],
        'host'      => $request['hostname'],
        'database'  => $request['dbname'],
        'username'  => $request['username'],
        'password'  => $request['dbpassword'],
        'charset'   => 'utf8',
        'collation' => 'utf8_general_ci',
        'prefix'    => '',
));

//Trying reconnect database
try {
        DB::connection()->getPdo();
    } catch (\Exception $e) {
        //revert old db if any error
        DB::disconnect(env("DB_CONNECTION"));
        Config::set('database.connections.' . env("DB_CONNECTION") .'.database', $oldDbName );
    }

I don't know if it works, but it seems to be what you need... I hope.

ottaviane left a reply on Change Database Dynamically

@CMDOBUENO - I think cronix is right. I add: a multidatabase approach, in some contexts, can also be much more elegant and orderly.

07 May
1 month ago

ottaviane left a reply on Quering A Ldapserver And Synchronize Laravel Database

@MARTINBEAN - thank you for your precious help. the real reason is that my laravel must authenticate 90% of users entirely managed by ldap, to which server I do not have administrative access, and 10% of users managed entirely by me locally. The two things must be merged invisibly. Furthermore, the authentication on ldap is very slow for technical reasons that I cannot solve (insurmountable administrative issues). In doing so, I speeded up the authentication because, in fact, after the first time the user has logged in, it is registered locally and for the future it is logged in locally much faster. If the password should change, the system will automatically ask ldap and, if the different credentials are valid for ldap, the local record is updated ... and so via.do valid In turn local users who do not have to be created on ldap, being valid already at the first stage, do not create any problem. I hope I was clear. thank you so much.

04 May
1 month ago

ottaviane left a reply on Using Admin Middleware In Some Only Resource Routing

@SERGIU17 - perfect! thank you very very mutch.

ottaviane started a new conversation Using IsAdmin Middleware In Resource Routimg

Hi, I have this middleware:

class Admin
{  
     public function handle($request, Closure $next)
     {
       if(auth()->user()->isAdmin !== null)
       {
         if (auth()->user()->isAdmin == 1) {
             return $next($request);
         }
       }
       return redirect('/')->with('error', 'You have not admin access.');
     }
}

and I have this routes in web.php

Route::get('/raccolte/{id}/switch','[email protected]')->middleware('admin');
Route::get('/raccolte/{id}/{id2}/scambia','[email protected]')->middleware('admin');
Route::resource('raccolte','RaccolteController');

and with artisan route:list I have

|        | GET|HEAD  | raccolte                                | raccolte.index      | App\Http\Controllers\[email protected]                          | web,auth       |
|        | POST      | raccolte                                | raccolte.store      | App\Http\Controllers\[email protected]                          | web,auth       |
|        | GET|HEAD  | raccolte/create                         | raccolte.create     | App\Http\Controllers\[email protected]                         | web,auth       |
|        | GET|HEAD  | raccolte/{id}/switch                    |                     | App\Http\Controllers\[email protected]                         | web,admin,auth |
|        | GET|HEAD  | raccolte/{id}/{id2}/scambia             |                     | App\Http\Controllers\[email protected]                        | web,admin,auth |
|        | GET|HEAD  | raccolte/{raccolte}                     | raccolte.show       | App\Http\Controllers\[email protected]                           | web,auth       |
|        | PUT|PATCH | raccolte/{raccolte}                     | raccolte.update     | App\Http\Controllers\[email protected]                         | web,auth       |
|        | DELETE    | raccolte/{raccolte}                     | raccolte.destroy    | App\Http\Controllers\[email protected]                        | web,auth       |
|        | GET|HEAD  | raccolte/{raccolte}/edit                | raccolte.edit       | App\Http\Controllers\[email protected]                           | web,auth       |

I'd like to protect with middleware only a part of resource route:

|        | POST      | raccolte                                | raccolte.store      | App\Http\Controllers\[email protected]                          | web,auth       |
|        | GET|HEAD  | raccolte/create                         | raccolte.create     | App\Http\Controllers\[email protected]                         | web,auth       |

how can I do? thanks, bye.

ottaviane left a reply on Quering A Ldapserver And Synchronize Laravel Database

@SNAPEY - Hi Snapey. I resolved. I hope the solution described at the top of this discussion can help somebody. Thanks for your valuable help.

ottaviane left a reply on Quering A Ldapserver And Synchronize Laravel Database

@MARTINBEAN - at the top I explained and solved. thank you

ottaviane left a reply on Intercepting Laravel Login Error

finally I resolved my problem:

protected function attemptLogin(Request $request)
    {
      if($this->guard()->attempt($this->credentials($request), $request->filled('remember'))) //if user is valid in Laravel
      {
        return true;
      }
      else
      {
        if(my_fake_ldap_verify($request)) //if user is valid in ldap server
        {
          $mycredentials['email']=$request['email'];
          $mycredentials['password']=Hash::make($request['password']);
          $mycredentials['name']=$request['email'];
          $user = User::updateOrCreate($mycredentials); //add new user with credentials to users table in my database if not exists or update it if password changed
          $this->guard()->attempt($this->credentials($request), $request->filled('remember')); //relogin

          return true;
        }
        else return false;
      }
    }

thanks all

03 May
1 month ago

ottaviane left a reply on Intercepting Laravel Login Error

@SNAPEY - I made it:

  protected function attemptLogin(Request $request)
    {

      if($this->guard()->attempt($this->credentials($request), $request->filled('remember'))) //if user is valid in Laravel
      {
          return true;
      }
      else
      {
        if(my_fake_ldap_verify($request)) //if user is valid in ldap server
        {
          $mycredentials['email']=$request['email'];
          $mycredentials['pass']=$request['password'];
          $request['name']=$request['email'];
          //dd($request);
          $user = User::updateOrCreate(request(['name','email','password'])); //add new user with credentials to users table in my database if not exists or update it if password changed
          //  dd($user);
          //dd(compact('mycredentials'));
          return Redirect::route('login')->with('mycredentials',$mycredentials);
          //2 -  resend same login request recalling the form login.blade.php
        }
        else return false;
      }
    }

and it add new records with users abilited bay ldap. I need so to encrypt password in new records and to modify login.blade.php with a script who make autologin. What do you mean?

ottaviane left a reply on Intercepting Laravel Login Error

@SNAPEY - Yes, the objective is to auto register users that are known in the directory. I was thinking of taking the password, which is certainly valid for ldap, from the request ... mmhhh ... I think it may be a good solution. And, it is important, users should not notice this, so they don't go in confusion.

ottaviane left a reply on Intercepting Laravel Login Error

@SNAPEY - I thought I'd do this, correct me if I'm wrong please:

// in my LoginController.php...
protected function attemptLogin(Request $request)
    {

      if($this->guard()->attempt($this->credentials($request), $request->filled('remember')))
      {
          return true;
      }
      else
      {
        if(myldapverify($request))
        {
          1 -  with DB fake add new user with credentials to users table in my database if not exists or update it if password changed
          2 -  resend same login request recalling the form login.blade.php
        }
        else return false;
      }
    }

What do you think about it?

ottaviane left a reply on Intercepting Laravel Login Error

@SNAPEY - I'm sorry but sometimes I look stupid! You're right! I have included the library and it works. Just what I needed. Let me see: you did an overriding of a method, right?

ottaviane left a reply on Intercepting Laravel Login Error

@SNAPEY - Thanks and good morning.

it would be better to log in to laravel first, but if I solve it, the opposite is also fine.

In LoginController.php I added this:protected function attemptLogin(Request $request) { return $this->guard()->attempt( $this->credentials($request), $request->filled('remember') ); } but I receive an error:

 Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_RECOVERABLE_ERROR)
Argument 1 passed to App\Http\Controllers\Auth\LoginController::attemptLogin() must be an instance of App\Http\Controllers\Auth\Request, instance of Illuminate\Http\Request given, called in /home/ottaviane/Sviluppo/vvfsr/vendor/laravel/framework/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php on line 44

bye.

02 May
1 month ago

ottaviane left a reply on Intercepting Laravel Login Error

@DAVIDPETROV - I tried to override the function like that

...
class LoginController extends Controller
{
...
    public function __construct()
    {
        $this->middleware('guest')->except('logout');
    }
    protected function sendFailedLoginResponse(Request $request)
    {
            return view('myooop.php');
    }
}

But I receive this error:

Argument 1 passed to App\Http\Controllers\Auth\LoginController::sendFailedLoginResponse() must be an instance of App\Http\Controllers\Auth\AuthRequest, instance of Illuminate\Http\Request given, called in /home/ottaviane/Sviluppo/vvfsr/vendor/laravel/framework/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php on line 53

ottaviane left a reply on Intercepting Laravel Login Error

@MARTINBEAN - I need to query an ldap server if the user is not recognized by Laravel. If the ldap server returns the ok (and here there is no problem) then the user must be considered logged in.

ottaviane left a reply on Intercepting Laravel Login Error

I made in login.blade.php file

@error('email')
                                <script type="text/javascript">
                                  window.location = "{ url('/myerrorpage.php') }";
                                </script>         
@enderror

But is there any better way to do it?

ottaviane left a reply on Querying Ldap Server For Auth Requests

I think to make it with Middleware... I'm studing...

01 May
1 month ago

ottaviane started a new conversation Querying Ldap Server For Auth Requests

Hi guys, I need to autenticate only 2 users already registered with laravel auth method ... and it's ok: no problems. But if a user who is logging is another user, i need to query a ldap server, and I already have a php code working very well. how do I call my php function if laravel authentication fails? and if the ldap server returns ok how do I tell Laravel that the user can be accepted as logged in?maybe I have to override some method? which? thank you. regards

24 Apr
1 month ago

ottaviane started a new conversation Difference Betwen Static & Dinamically Instantiate Models

Hello, I can't understand why with this

$tab=new SpartInRacc;
      $tab->setTable($id_tab);
      $elenco = $tab->get();
      dd($elenco);

I obtain this

Collection {#273 ▼
  #items: array:2 [▼
    0 => SpartInRacc {#274 ▶}
    1 => SpartInRacc {#275 ▶}
  ]
}

and I have to make a foreach to get all records, and instead with static call, for example SpartInRacc::all(), I obtain directly records. Is there any way to obtain directly records with dinamic mode? thanks. bye.

ottaviane started a new conversation Saving Record " ErrorException (E_NOTICE) Array To String Conversion"

Hi all. I have to save record in a table but I receive this error message: " ErrorException (E_NOTICE) Array to string conversion"

This is code: public function store(Request $request) { //aggiungi un record $id_tab=request(['id_tab']); $id_canto=$request['canti']; $tab=new SpartInRacc;//new instance of my model $tab->setTable($id_tab); $tab->id_canto=$id_canto; $tab->save();

    return redirect('/spartinracc');
}

and dd($tab); outs SpartInRacc {#244 ▼ #table: array:1 [▼ "id_tab" => "13-Natale" ] #fillable: array:1 [▼ 0 => "id_canto" ] #connection: null #primaryKey: "id" #keyType: "int" +incrementing: true #with: [] #withCount: [] #perPage: 15 +exists: false +wasRecentlyCreated: false #attributes: array:1 [▼ "id_canto" => "22" ] #original: [] #changes: [] #casts: [] #dates: [] #dateFormat: null #appends: [] #dispatchesEvents: [] #observables: [] #relations: [] #touches: [] +timestamps: true #hidden: [] #visible: [] #guarded: array:1 [▼ 0 => "*" ] }

where is the mistake? Bye