imposition

imposition

Member Since 2 Years Ago

Goioerê

Experience Points
3,690
Total
Experience

1,310 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
23
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    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 Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

Level 1
3,690 XP
Nov
29
1 year ago
Activity icon

Replied to CRUD Help

@Snapey That's not a real problem. The user he's deleting does not affect the user that he logs in to the app.

This form deletes another type of user. A Radius one.

Nov
28
1 year ago
Activity icon

Replied to CRUD Help

Added a href instead of button and it works fine now.

Activity icon

Replied to CRUD Help

Okay did like this:

Route::post('newuser/delete/{id}', '[email protected]')->name('newuser.destroy');
        <td>{!! Form::open(['route' => ['newuser.destroy', $d['id']], 'method' => 'POST']) !!}
        {!! Form::submit('Excluir', ['class' => 'btn btn-default btn-sm']) !!}
        {!! Form::close() !!}</td>
 public function destroy($id)
            {
          
            $user = Users::find($id);
            $user1 = Groups::find($id);
            $user->delete();
            $user1->delete();

            return redirect('home')
            ->with('message', 'Usuário removido com sucesso!!');
            }    

It worked one time, now it does not work anymore Ç_Ç

EDIT: Added a instead of and it works fine.

Activity icon

Replied to CRUD Help

Don't know how to use boot... I'm pretty new to Laravel

Activity icon

Started a new Conversation CRUD Help

Hi there, I need to create a method to delete a user he is registered in two diff tables Created 2 models Users , Groups

The delete button:

        <td><a href="/newuser/delete/{{ $d['Username'] }}" class="fa fa-trash" aria-hidden="true"></i></a></td>

Route:

Route::delete('newuser/delete/{d}', '[email protected]');

Controller:

public function search(Request $request)
            {
            $users = Users::search($request);
            $users1 = Groups::search($request);
            foreach ($users as $user) {
            $data[] = array('Username' => $user->username,
            'id' => $user->id
            );
            };
            foreach ($users1 as $user1){
            $data1[] = array ('id2' => $user1->id);
            };
            return view('user.buscar', compact('data'));
            }

            public function buscar()
            {
            return view ('user.buscar');
            }

            public function destroy($id)
            {
            try {
            DB::transaction(function() use($id)
            {
            $user = Users::find($id);
            $user1 = Groups::find($id);
            $user->delete();
            $user1->delete();
            });
            return redirect('home')
            ->with('message', 'Usuário removido com sucesso!!');
            }
            catch (\Exception $e) {
            return redirect('home')
            ->with('message', 'Usuário não foi removido, verifique os dados!!');
            }

            } 

HELP pls ç-ç

Activity icon

Replied to Transaction

I was trying

DB::transaction(function($request) {
Nov
27
1 year ago
Activity icon

Started a new Conversation Transaction

  public function create(Request $request)
{
        try {
            DB::transaction(function() 
        {

        $user =  new Users;
        $user->username = $request->user;
        $user->attribute = "Password";
        $user->op = "==";
        $user->value = $request->password;
        $user1 = new Groups;
        $user1->username = $request->user;
        $user1->groupname = $request->group;
        $user1->save();
        $user->save();
        });

            return redirect('home')
            ->with('message', 'Usuário criado com sucesso!!');
        }
        catch (\Exception $e) {
            return redirect('home')
            ->with('message', 'Usuário não cadastrado! Verifique os dados!');
        }
}

With DB::transaction this code does not create user Without DB::transaction this code create user What am i doing wrong?

Nov
24
1 year ago
Activity icon

Replied to Improving Query

@bobbybouwmann Added a date range picker instead of a simple date picker Now i'm not having 'lag' problems haha

Activity icon

Replied to Query On My Model Taking Too Much Time To Finish.

Changed it to where between and added a daterangepicker instead of datepicker

Activity icon

Started a new Conversation Improving Query

$data = TopWireless::select(DB::raw('UserName, sum(AcctInputOctets) as Input , sum(AcctOutputOctets) as Output'))
                    ->whereDate('AcctStartTime' , 'regexp', date($data['date']))->groupBy('UserName')->orderBy('Output', 'desc')->limit(20)->get();

I'm wondering how to improve this query. This is taking too much time to complete.

Nov
22
1 year ago
Activity icon

Replied to Query On My Model Taking Too Much Time To Finish.

@mattsplat The AcctStartTime is a date. I'm searching through my DB with just the year and the month. After reading what you both said i did the code like this:

            $data = TopFiber::select(DB::raw('UserName, sum(AcctInputOctets) as Input , sum(AcctOutputOctets) as Output'))
                    ->whereDate('AcctStartTime' , $data['date'])->groupBy('UserName')->orderBy('Output', 'desc')->limit(20)->get();

And is taking a lot of time yet

Nov
21
1 year ago
Activity icon

Replied to Query On My Model Taking Too Much Time To Finish.

@mattsplat Added index to AcctStartTime and its getting a little less longer .... But not less enough

Nov
20
1 year ago
Activity icon

Replied to Query On My Model Taking Too Much Time To Finish.

@mattsplat

   {#766
       +"Table": "radacct",
       +"Non_unique": 1,
       +"Key_name": "AcctStartTime",
       +"Seq_in_index": 1,
       +"Column_name": "AcctStartTime",
       +"Collation": "A",
       +"Cardinality": 8576707,
       +"Sub_part": null,
       +"Packed": null,
       +"Null": "",
       +"Index_type": "BTREE",
       +"Comment": "",
       +"Index_comment": "",
Nov
19
1 year ago
Activity icon

Replied to Query On My Model Taking Too Much Time To Finish.

AcctStartTime is the date, I think This is taking too much time cus i have over 50.000 entries to This table

Nov
18
1 year ago
Activity icon

Started a new Conversation Query On My Model Taking Too Much Time To Finish.

Hi there! I have this query inside my model:

            $data = TopFiber::select(DB::raw('UserName, sum(AcctInputOctets) as Input , sum(AcctOutputOctets) as Output'))
                    ->where('AcctStartTime' , 'LIKE', $data['date'] . '%')->groupBy('UserName')->orderBy('Input', 'desc')->limit(20)->get();

But this is taking too much time like 5 minutes to complete or so. Can i do this any other way to speed up the query ? I need this exactly like it is.

Nov
17
1 year ago
Activity icon

Replied to Formatting To Eloquent

Got it!

$data = TopFiber::select(DB::raw('UserName, sum(AcctInputOctets) as Input , sum(AcctOutputOctets) as Output'))
                    ->where('AcctStopTime' , 'LIKE', $data['date'] . '%')->groupBy('UserName')->orderBy('Input', 'desc')->limit(20)->get();
Activity icon

Started a new Conversation Formatting To Eloquent

SELECT Username, SUM(AcctInputOctets) Input, SUM(AcctOutputOctets) Output
FROM radacct WHERE AcctStopTime LIKE '%xxxx%'  GROUP BY username ORDER BY Input DESC limit 20;

Please can someone help me format this to Eloquent? Like :

select(DB::raw('sum(AcctInputOctets) as Input , sum(AcctOutputOctets) as Output'))
                    ->where('AcctStopTime' , 'LIKE', $data['date'] . '%', )->get()

Got something like this:

$data = TotalFiber::select('UserName')->select(DB::raw('sum(AcctInputOctets) as Input , sum(AcctOutputOctets) as Output'))
                    ->where('AcctStopTime' , 'LIKE', $data['date'] . '%')->groupBy('UserName')->orderBy('Input', 'desc')->limit(20)->get();
Nov
16
1 year ago
Activity icon

Started a new Conversation Form To Select Dates

How do i create a form to select dates like From 02/01/2016 to 02/01/2017 And retrieve that data from my db? Can someone point me a tutorial ?

Nov
03
1 year ago
Activity icon

Replied to Audit

Something like this:

Route::post('/senhaf/search', ['middleware' => 'auth', 'audit', 'uses' => '[email protected]']);
    protected $routeMiddleware = [
        'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
        'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
        'can' => \Illuminate\Auth\Middleware\Authorize::class,
        'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
        'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
        'audit' => \App\Http\Middleware\Audit::class,
Activity icon

Replied to Audit

@mushood Bro, it still tracking every move my user make.

Oct
31
1 year ago
Activity icon

Replied to Audit

@mushood I think what's making the whole thing work is this middleware:

<?php

namespace App\Http\Middleware;

use Closure;
use Jenssegers\Agent\Agent;
use App\Audit as Auditor;

class Audit
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {

        $agent = new Agent();


        if ( \Auth::check() ) {

            Auditor::create([
                'user_id'    => \Auth::user()->id,
                'method'     => $request->getMethod(),
                'path' => $request->getPathInfo(),
                'query'      => $request->getQueryString(),
                'userAgent' => $agent->getUserAgent(),
                'ip'        => \Request::ip(),
                'device' => $agent->device(),
                'platform' => $agent->platform(),
                'browser' => $agent->browser(),
                'isDesktop' => $agent->isDesktop(),
                'isMobile' => $agent->isMobile(),
                'isPhone' => $agent->isPhone(),
                'isTablet' => $agent->isTablet()
            ]);
        }

        return $next($request);
    }
}

What should i do to make it only work in specific routes? Like... I want it to only work in this routes

Route::get('/senhaf', ['middleware' => 'auth', 'uses' => '[email protected]']);
Route::get('/senhaw', ['middleware' => 'auth', 'uses' => '[email protected]']);
Route::get('/senhaw/{rad}/edit', ['middleware' => 'auth', 'uses' => '[email protected]']);
Route::patch('/senhaf/{radius}', ['middleware' => 'auth', 'uses' => '[email protected]']);
Route::patch('/senhaw/{radius}', ['middleware' => 'auth', 'uses' => '[email protected]']);
Oct
30
1 year ago
Activity icon

Started a new Conversation Audit

Hi there! I made an Audit and it's working fine. But here is my problem. It's saving every single move my users make. I just want to save when they access an specific route For example I have the routes: /xxx /xxx1 /xxx2 /xxx3 I want my Audit only to make records about the /xxx3 url. Only when my user access /xxx3 then save into my DB

This is my model if it has any use:

use Illuminate\Database\Eloquent\Model;

class Audit extends Model
{

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'user_id', 'method', 'path', 'query', 'userAgent', 'ip', 'device' , 'platform', 'browser' , 'isDesktop', 'isMobile' , 'isPhone' , 'isTablet'
    ];


    public function user ()
    {
        return $this->belongsTo(User::class);
    }


    /**
     * Get online users
     *
     * @param int $min
     * @return \Illuminate\Database\Eloquent\Collection|static[]
     */
    public function online ($min = 3)
    {

        return $this->select('user_id')
                    ->where('audits.created_at', '>=', Carbon::now()->subMinutes($min)->toDateTimeString())
                    ->distinct('user_id')
                    ->with('user')
                    ->get()->map(function ($item) {
                        return $item->user;
                    });

    }
}
Oct
27
1 year ago
Activity icon

Replied to Which User Deleted What?

@kfirba i have native auth I just want to know how to make logs of each users activity... Which tools were used and stuff like that.

Oct
26
1 year ago
Activity icon

Started a new Conversation Which User Deleted What?

Is possible to create a log that show me what each user deleted or edited ?

Activity icon

Replied to Select Different Table .

@Snapey Found my problem... Was missing a } at the end of my model.

Activity icon

Replied to Select Different Table .

@Snapey i know that but we use fiber because of the label of equips we use... fiberhome. Also couldn't make it work.

Illuminate\Foundation\ComposerScripts::postAutoloadDump You made a reference to a non-existent script @php artisan package:discover

Activity icon

Replied to Select Different Table .

@Snapey Why ?

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use DB;
use App\PatchFiber;
use App\RadiusFiber;
use App\Form;

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use DB;


class PatchFiber extends Model

Name of the class is PatchFiber why would i use PatchFibre? Also, the App\RadiusFiber; works fine so in theory App\PatchFiber should work too

Activity icon

Replied to Select Different Table .

@Snapey Created this model:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use DB;


class PatchFiber extends Model
{
// ------------------ // -----------------//
// Conexão ao Database                   //
// ------------------//------------------//
    protected $connection = 'radiusfiber';

// ------------------ // -----------------//
// Tabela Utilizada no DB                //
// ------------------//------------------//
    protected $table  = 'radcheck';

// ------------------ // -----------------//
// Fillable com mass assignment           //
// ------------------//------------------//
    protected $guarded = [];

// ------------------ // -----------------//
// Timestamps desativados                //
// ------------------//------------------//
    public $timestamps = false;


And updated my method to:


    public function update(Request $request, PatchFiber $radius)
    {   
        $radius->update([
            'Value' => $request['Value']
            ]);
        return redirect('home');
    }

Also added use App\PatchFiber; to my controller

Activity icon

Replied to Select Different Table .

@Snapey When i do that i get this error: ReflectionException Class App\PatchFiber does not exist

_>

Activity icon

Replied to Select Different Table .

@Snapey I've created another model... But i can't figure out how to edit my update method to match my new model :c

Activity icon

Started a new Conversation Select Different Table .

I have this model:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use DB;

class RadiusFiber extends Model
{
// ------------------ // -----------------//
// Conexão ao Database                   //
// ------------------//------------------//
    protected $connection = 'radiusfiber';

// ------------------ // -----------------//
// Tabela Utilizada no DB                //
// ------------------//------------------//
    protected $table  = 'radreply';

// ------------------ // -----------------//
// Fillable com mass assignment           //
// ------------------//------------------//
    protected $guarded = [];

// ------------------ // -----------------//
// Timestamps desativados                //
// ------------------//------------------//
    public $timestamps = false;

// ------------------ // -----------------//
// Seleciona a conexão com DB             //
// ------------------//------------------//
    protected function searchIP($data = [])
    {
    
        
         $data = RadiusFiber::where('UserName' , 'LIKE', $data['search'] . '%')->get();
         return $data;
           }

  }

And this controller:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use DB;
use App\RadiusFiber;
use App\Form;

class RadiusController extends Controller
{


// ------------------ // -----------------//
// PAGINA INICIAL RADIUS                //
// ------------------//------------------//

    public function index()
    {
        $data = [];
        return view('radius.index', compact('data'));
    }


// ------------------ // -----------------//
// PAGINA DE EDIÇÃO RADIUS                //
// ------------------//------------------//

    public function edit(RadiusFiber $rad)
    {
        return view('radius.edit', compact('rad'));
    }

// ------------------ // -----------------//
// EDITAR DADOS RADIUS ----               //
// ------------------//------------------//
   

    public function update(Request $request, RadiusFiber $radius)
    {   
        $radius->update([
            'Value' => $request['Value']
            ]);
        return redirect('home');
    }

// ------------------ // -----------------//
// PROCURAR LOGINS                       //
// ------------------//------------------//

    public function search(Request $request)
     {   

         $logins = RadiusFiber::searchIP($request);

         foreach ($logins as $login) {
             if ($login->Attribute == 'Framed-IP-Address'){
                $data[] = array('UserName' => $login->UserName,
                            'ipAddress' => $login->Value,
                            'id' => $login->id
                        );
             }
         }
         
         return view('radius.index', compact('data'));
    }
   
// ------------------ // -----------------//
// DELETAR IP                             //
// ------------------//------------------//    
    public function DeleteConfirmation($userName)

    {

            return view ('radius.delete', compact('userName'));
       
        

    }

public function Destroy()

{
   
      
   try 
        {
   
            DB::transaction(function ()
                {

                $toDelete = request('delete');

                RadiusFiber::where('UserName', $toDelete )->delete();

                });

                return redirect('home');

        }  

    catch(\Exception $e)
        {
           
            return 'nao deu';

        }
   
}
}

I want this method:

// ------------------ // -----------------//
// EDITAR DADOS RADIUS ----               //
// ------------------//------------------//
   

    public function update(Request $request, RadiusFiber $radius)
    {   
        $radius->update([
            'Value' => $request['Value']
            ]);
        return redirect('home');
    }

To use a different table from that specified on my model

How to do that ?

Oct
24
1 year ago
Activity icon

Started a new Conversation How To Change The Default Auth Forgot Pass Email That Is Sent?

Can anyone point me for where i can change the email sent by native forgotpass?

https://prnt.sc/h1c7wv <- This one

Oct
20
1 year ago
Activity icon

Replied to Multiple DB Connections!

@jlrdw created new model/controller One for each DB Solved my problem for now. My system is close to be done I just needed this one. So i did like this to wrap it up. And when i have some more time i'll finish this the right way

Activity icon

Replied to Delete From Database.

@Corban I didn't mistake you I marked because it was really helpfull And it didn't work because of a mistake i've made before. You were really helpfull Thanks <3

Activity icon

Replied to Transaction

@tykus No but i solved that already.

About the Try/Catch forgot to update the code... Did like this

public function Destroy()
{
   try 
        {
   
            DB::transaction(function ()
                {

                $toDelete = request('delete');

                Radius::where('UserName', $toDelete )->delete();

                });

                return redirect('home');

        }  

    catch(\Exception $e)
        {
           
            return 'nao deu';

        }
Activity icon

Started a new Conversation Multiple DB Connections!

I have multiple DB connections. My Search method uses a select form to know which connection to use. Them display a search result... On that search result i have a delete href that leads me to a delete method... But my delete method does not choose a connection. How do i do that ?

My search form:

<form  method="POST" action="/radius/search">

                   <input type="hidden" name="_token" value="{{ csrf_token() }}">  
                    <div class="col-md-5">
                       <div class="form-group">
                           <input type="text" name="search" class="form-control" placeholder="Buscar Login"/>
                       </div>
                   </div>


                   <div class="col-md-5">
                   <div class="form-group">
                  
                   <select id="connection" name="connection" class="form-control">
                       <option value="fiber">Fibra</option>
                       <option value="wireless">Wireless</option>
                   </select>
               </div>

                           <button type="submit" class="btn btn-default btn-flat">Buscar</button>                          
                       </div>
                   </div>
               </form>

My Model that selects the connection:

    protected function searchIP($data = [])
    {
    
        if ($data->connection == 'fiber')
        {
            $this->connection = 'radiusfiber';
        }
        else
        {
            $this->connection = 'radiuswireless';
        }
        
         $data = Radius::where('UserName' , 'LIKE', $data['search'] . '%')->get();
         return $data;
    }

My Controller:

    public function search(Request $request)
     {   

         $logins = Radius::searchIP($request);

         foreach ($logins as $login) {
             if ($login->Attribute == 'Framed-IP-Address'){
                $data[] = array('UserName' => $login->UserName,
                            'ipAddress' => $login->Value);
             }
         }
         return view('radius.index', compact('data'));
    }
   public function Destroy()

{
    Radius::deleteIP();
      
   try 
        {
   
            DB::transaction(function ()
                {

                $toDelete = request('delete');

                Radius::where('UserName', $toDelete )->delete();

                });

                return redirect('home');

        }  

    catch(\Exception $e)
        {
           
            return 'nao deu';

        }
   
}

I basically want that my Destroy method grab the Search method connection. How do i do that ?

Activity icon

Replied to Transaction

@tykus And if there are any usernames alike

tykus tykus2 tykus3 tykus4

etc

My delete method will delete all rows with the username tykus :)

Activity icon

Replied to Transaction

@tykus because now i'm going to insert more querys I just want to know if i'm doing this right

Activity icon

Started a new Conversation Transaction

Can anyone tell me if i'm doing this right?

  public function Destroy()

    {
   
DB::beginTransaction();

    $toDelete = request('delete');

    Radius::where('UserName', $toDelete )->delete();

if ($toDelete){

    DB::commit();
    return redirect('home');

}   
else
{
            DB::rollBack();
            return 'nao deu';

}
Activity icon

Replied to Delete From Database.

@Corban even with the right variables i couldn't make it work exactly... It was almost all copy and paste i just made some changes on my controller that i hadn't posted here before... There was a messed up variable that made it not work actually. But thanks for your help I marked your answer as the best one :)

Oct
19
2 years ago
Activity icon

Replied to Delete From Database.

Made it like this web.php

// // ------------------ // -----------------//
// // DELETE REQUEST                          //
// // ------------------//------------------// 
Route::get('radius/destroy/{username}', '[email protected]');
Route::delete('/destroyradius', '[email protected]');

RadiusController.php

// ------------------ // -----------------//
// DELETAR IP                             //
// ------------------//------------------//    
    public function DeleteConfirmation($userName)

    {
        return view ('radius.delete', compact('userName'));

    }

    public function Destroy()

    {
   
    $toDelete = request('delete');

    Radius::where('UserName', $toDelete )->delete();

    return redirect('/');
   
    }

index view

        <td><a href="/radius/destroy/{{ $d['UserName'] }}" class="fa fa-trash" aria-hidden="true"></i></a></td>

delete view

    <form method="post" action="/destroyradius" class="">
        {{ csrf_field() }}
    {{ method_field('delete') }}
         <div class=""> 
        Are you sure you want to delete {{ $userName }} ?
     </div>
    <div class="">
        <input type="hidden" value="{{ $userName }}" name="delete">  
        <button class="" type="submit" >Confirm</button>
        <button class="" type="submit"onclick="window.history.go(-1)" >No, Wait!</button>
    </div>
        </form>

It works fine

Activity icon

Replied to Delete From Database.

@Corban Does not work :/

ErrorException (E_ERROR) htmlspecialchars() expects parameter 1 to be string, array given

Doesn't even know what i'm doin wrong :c

Activity icon

Replied to Delete From Database.

@jontyjago Class 'Form' not found (View: /var/www/html/projeto/resources/views/radius/index.blade.php Got this error after adding that form to my view

@tisuchi

my table goes like this

[
                    'UserName' => trim($data->username),
                    'Attribute' => 'Framed-IP-Address',
                    'op' => '=',
                    'Value' => trim($data->ipv4)
                ],
                [
                    'UserName' => trim($data->username),
                    'Attribute' => 'Framed-MTU',
                    'op' => '=',
                    'Value' => '1492'
                ],
                [
                    'UserName' => trim($data->username),
                    'Attribute' => 'Service-Type',
                    'op' => '=',
                    'Value' => 'Framed-User'
                ],
                [
                    'UserName' => trim($data->username),
                    'Attribute' => 'Framed-Protocol',
                    'op' => '=',
                    'Value' => 'PPP'
                ],
                [
                    'UserName' => trim($data->username),
                    'Attribute' => 'Framed-Compression',
                    'op' => '=',
                    'Value' => 'Van-Jacobson-TCP-IP'
                ]
Activity icon

Replied to Delete From Database.

@tisuchi I don't have a delete method... I don't know how to make one :c

EDIT::So far I managed to make this

// ------------------ // -----------------//
// DELETAR IP                             //
// ------------------//------------------//    

    public function destroy($data)
        {
        Radius::where('UserName', $data)
        ->delete();
        Session::flash('flash_message', 'IP Removido com sucesso!');
        return redirect('/home');
        }
<td><a href="/radius/destroy/" onclick="return confirm('Deseja realmente excluir esse item?');"><i class="fa fa-trash" aria-hidden="true"></i></a></td>
// // ------------------ // -----------------//
// // DELETE REQUEST                          //
// // ------------------//------------------// 
Route::get('radius/destroy', '[email protected]');

But i don't know wtf i am doing

https://prnt.sc/gzd68j I want to delete this onclick... They have the same UserName but different Attributes and Values Don't know how to do that tho

Oct
18
2 years ago
Activity icon

Replied to Delete From Database.

@bnazarov@abv.bg i have done that yet... But the delete part i can't figure that out by myself

Activity icon

Replied to Delete From Database.

@tisuchi I have this Model

    protected function searchIP($data = [])
    {
    
        if ($data->connection == 'fiber')
        {
            $this->connection = 'radiusfiber';
        }
        else
        {
            $this->connection = 'radiuswireless';
        }
        
         $data = Radius::where('UserName' , 'LIKE', $data['search'] . '%')->get();
         return $data;
    }
// --

This controller

// ------------------ // -----------------//
// PROCURAR LOGINS                       //
// ------------------//------------------//

    public function search(Request $request)
     {   

         $logins = Radius::searchIP($request);

         foreach ($logins as $login) {
             if ($login->Attribute == 'Framed-IP-Address'){
                $data[] = array('UserName' => $login->UserName,
                            'ipAddress' => $login->Value);
             }
         }
         return view('radius.index', compact('data'));
    }

And this view

<div class="container">
    <div class="row">
        <div class="col-md-10 col-md-offset-1">
            <div class="panel panel-default">
                <div class="panel-heading">Consultar clientes com IP Fixo</div>
                <div class="panel-body">

                <form  method="POST" action="/radius/search">

                    <input type="hidden" name="_token" value="{{ csrf_token() }}">  
                     <div class="col-md-5">
                        <div class="form-group">
                            <input type="text" name="search" class="form-control" placeholder="Buscar Login"/>
                        </div>
                    </div>


                    <div class="col-md-5">
                    <div class="form-group">
                   
                    <select id="connection" name="connection" class="form-control">
                        <option value="fiber">Fibra</option>
                        <option value="wireless">Wireless</option>
                    </select>
                </div>

                            <button type="submit" class="btn btn-default btn-flat">Buscar</button>                          
                        </div>
                    </div>
                </form>
               <table class="table table-striped">                        
      
        <th>Login</th>
        <th>Ip</th>
        <th>Delete</th>
        @foreach($data as $d)
        <tr>
        <td> {{ $d['UserName'] }}</td>                  
        <td>{{ $d['ipAddress'] }}</td>
        <td><a href="#" onclick="return confirm('Deseja realmente excluir esse item?');"><i class="fa fa-trash" aria-hidden="true"></i></a></td>
        </tr>
        @endforeach 
        
        </table>

I want that clickable item on the table 3rd row to delete five rows with the same username of my db

And i also have another problem... If i search for a username that isn't in my DB i get this error:Undefined variable: data (View: /var/www/html/projeto/resources/views/radius/index.blade.php Can you help me ?

Activity icon

Started a new Conversation Delete From Database.

I want to delete 5 lines from my database using a button The 5 lines have the same username How do i do that ?

Oct
13
2 years ago
Activity icon

Replied to @if Auth::user()->type

@Snapey Thank you very much!

Activity icon

Started a new Conversation @if Auth::user()->type

I'm new to laravel as i already said so be patient! I have a column in my database table named type I want an specific view to show a button only if the user type equals Admin or Mod. Like:

@if Auth::user->type equals 'Admin', 'Mod'

<li><a href="/conf"><span>Configuração</span></a></li>

@endif

Or something like that.