Buy your loved one the ultimate gift. Lifetime gift certificates are $100 off.

nanadjei2

Experience

12,130

1 Best Reply Awards

  • Member Since 2 Years Ago
  • 27 Lessons Completed
  • 1 Favorite

14th December, 2017

nanadjei2 started a new conversation Populate Input File With Data Form Database. • 11 hours ago

Am trying to edit an image. But I want to automatically populate the value with data. Example

 <input id="image" name="image" type="file" class="form-control" onchange="readURL(this);" value="{{ old('image', isset($product->image) ? $product->image: null ) }}" readonly>    

It is not working. How do I do that?

nanadjei2 left a reply on Call To A Member Function IsAdmin() On Null • 13 hours ago

Thank you all for your participation am very grateful. @martinbean Your suggesting too worked. Thank you

nanadjei2 left a reply on Call To A Member Function IsAdmin() On Null • 13 hours ago

@martinbean Is my code right? You mean I should do this ?

  public function handle($request, Closure $next)
{
     if (Auth::check()  && !Auth::user()->isAdmin()) {

        return redirect('/back-to-user-page');
    }
    return $next($request);
}

If yes then it still does not work. The page is rendering

nanadjei2 left a reply on Call To A Member Function IsAdmin() On Null • 13 hours ago

@Sanctuary The error is gone but the middleware done not work. The page am trying to prevent from rendering now renders.

nanadjei2 left a reply on Call To A Member Function IsAdmin() On Null • 14 hours ago

Ok I have changed the middleware

 public function handle($request, Closure $next)
   {
     if (!Auth::check()  && Auth::user()->isAdmin()) {

        return redirect('/back-to-user-page');
    }
    return $next($request);
  }

nanadjei2 started a new conversation Call To A Member Function IsAdmin() On Null • 14 hours ago

Am trying to create a middleware for admin. But after creating and testing to see if it is working I keep getting this error... Call to a member function isAdmin() on null

In my User.php

 public function isAdmin()
   {
    return false;
  }

App\Http\Middleware\RedirectNotAdmin.php

   <?php

             namespace App\Http\Middleware;

           use Closure;

          class RedirectIfNotAdmin
             {
                 /**
                * Handle an incoming request.
                *
                * @param  \Illuminate\Http\Request  $request
                * @param  \Closure  $next
                * @return mixed
                */
                   public function handle($request, Closure $next)
               {
                 if (! $request->user()->isAdmin()) {

                 return redirect('/back-to-user-page');
               }
                  return $next($request);
           }
   }

Kernel.php

   protected $middlewareGroups = [
        'web' => [
        \App\Http\Middleware\RedirectIfNotAdmin::class
      ];

protected $routeMiddleware = [
     'admin' => \App\Http\Middleware\RedirectIfNotAdmin::class
     ];

Route.php

   Route::group(['namespace'=> 'Admin', ['middleware' => ['auth', 'admin']]], function (){
     // Route::view('/backend/dashboard',  'admin.dashboard', 
    //  ['pageTitle' => 'Dashboard', 'pageHeading' => 'Dashboard']);
Route::get('/backend/dashboard', '[email protected]')->name('admin.dashboard');
 });

8th December, 2017

nanadjei2 left a reply on Method Not Allowed Error • 6 days ago

Run php artisan route:list and look out for the route that is responsible for storing the form date. Like the example below.

 <form method="post" action="{{ route('workout.store') }}">

6th December, 2017

nanadjei2 started a new conversation Multi Auth Not Displaying My Whoops Page • 1 week ago

Am doing a multi auth with laravel 5.5. The admin middleware works fine but when I get an error the error page (whoops) does not display.

This is my Handler.php

  public function render($request, Exception $exception)
    {

      $guard = array_get($exception->guards(), 0);
      switch ($guard) {
        case 'admin':
            $login = 'admin.login';
            return redirect()->guest(route($login));
           
        default:
            
            return parent::render($request, $exception);

       
      }
    // return parent::render($request, $exception);
  }

This is my RedirectIfAuthenticated Middleware

       public function handle($request, Closure $next, $guard = null)
           {
    
          switch ($guard) {
          case 'admin':
            if (Auth::guard($guard)->check()) {
                return redirect()->route('admin.dashboard');
            }
        break;
        
        default:
            if (Auth::guard($guard)->check()) {

                return redirect('/home');
             }
           break;
       }

       return $next($request);
    }

30th November, 2017

nanadjei2 left a reply on This.errors.clear(); Not Working On Ajax Request • 2 weeks ago

Place this

 $this.$validator.clean(); 

just after

 $this.name = ''; $this.email = ''; $this.message = '';

28th November, 2017

nanadjei2 left a reply on How To Solve MethodNotAllowedHttpException In RouteCollection.php Line 218:? • 2 weeks ago

the problem is not your route. It is your form. Try

 {{ method_field('get') }}

  

nanadjei2 left a reply on Post Data Not Send When Word "from" MethodNotAllowedHttpException In RouteCollection.php Line 218 • 2 weeks ago

Please provide enough details. Let us see the form in your view.

Anyways you can paste this beneath your form tag: {{ method_field('POST') }}

nanadjei2 left a reply on Returning Redirects WithMessage Not Working • 2 weeks ago

Create a file in views. Eg: flashMessage.blade.php. and inside of it do.

   @if (Session::has('success'))
             {{ Session::get('success') }}
    @endif

Now in your controller :

      return back()->with('success', 'Your success message');

In your views :

@include('flashMessage')

nanadjei2 left a reply on Problem With Installing Laravel • 2 weeks ago

Why are you creating such a folder inside database? Can you show the folder structure too

27th November, 2017

nanadjei2 left a reply on This.errors.clear(); Not Working On Ajax Request • 2 weeks ago

Thank you

nanadjei2 left a reply on This.errors.clear(); Not Working On Ajax Request • 2 weeks ago

Your solution does the same thing as what I did

nanadjei2 left a reply on This.errors.clear(); Not Working On Ajax Request • 2 weeks ago

Still not working...

nanadjei2 started a new conversation This.errors.clear(); Not Working On Ajax Request • 2 weeks ago

Am trying submit a form using axios and vuejs. I want to clear all error after form is successfully submitted. But anytime I try this.errors.clear(); it does not work.

This is my js.

 let contact =  new Vue({
            el: '#contact',

            data: {

           token: '',
           name: '',
           email: '',
          message: ''
      },

       methods: {

         axiosHeaders() {
             axios.create({
              timeout: 1000,
              headers: {'X-Custom-Header': token}
            });
        },

         onSubmitContactForm() {
            this.axiosHeaders();
             axios({

             method: 'post',

              url: contactForm,

             data: {
                token: this.token,
                name: this.name,
                email: this.email,
                message: this.message
             }

          }).then((response) => {

            contact.errors.clear();
            contact.successMessage();
            contact.name = ''; contact.email = ''; contact.message = '';
            
           }).catch((error) => {

            contact.errorMessage();
            console.log(error.response.data);
        });


        }
      }
  })

23rd November, 2017

nanadjei2 left a reply on SQLSTATE[42000]: Syntax Error Or Access Violation: 1066 Not Unique Table/alias On Relationship • 3 weeks ago

I was accidentally doing return $this->belongsToMany(App\CmsPostCategoryTag) INSTEAD OF belongsToMany(App\CmsPostCategory)

  public function tags() {
    return $this->belongsToMany('App\CmsPostCategory', 'cms_post_category_tags', 'cms_post_id', 'cms_post_category_id')->withTimestamps();
  }

nanadjei2 started a new conversation SQLSTATE[42000]: Syntax Error Or Access Violation: 1066 Not Unique Table/alias On Relationship • 3 weeks ago

In CmsPost model :

    public function tags() {
    return $this->belongsToMany('App\CmsPostCategoryTag', 'cms_post_category_tags', 'cms_post_id', 'cms_post_category_id')->withTimestamps();
}

nanadjei2 started a new conversation Select2 In Edit Form • 3 weeks ago

I wanted to pull the tags associated with a post onto an edit page into a select2 input field so that the user can edit. But I keep getting an error "SQLSTATE[42000]: Syntax error or access violation: 1066 Not unique table/alias: 'cms_post_category_tags' (SQL: selectcms_post_category_tags.*,cms_post_category_tags.cms_post_idaspivot_cms_post_id,cms_post_category_tags.cms_post_category_idaspivot_cms_post_category_id,cms_post_category_tags.created_ataspivot_created_at,cms_post_category_tags.updated_ataspivot_updated_atfromcms_post_category_tagsinner joincms_post_category_tagsoncms_post_category_tags.id=cms_post_category_tags.cms_post_category_idwherecms_post_category_tags.cms_post_id= 2)

This is my controller

  public function show(CmsPost $CmsPost, $id)
{
    categories = Categories::all();
     $postTagIds = [];
     foreach($post->tags as $postTag) {
        $postTagIds[] = $postTag->id;
     }  

     return view('theme::cms.posts.show', [
        'CmsPost' => $CmsPost, 
        'post' => $post, 'categories' => $categories,
        'postTagIds' => $postTagIds 
        ]);

}

nanadjei2 left a reply on Post Tags Sync With Additional Data Like Slug. • 3 weeks ago

Woow. Thank you so much

nanadjei2 left a reply on Post Tags Sync With Additional Data Like Slug. • 3 weeks ago

Damn...! Man it worked. But it's left with the timestamps

nanadjei2 left a reply on Post Tags Sync With Additional Data Like Slug. • 3 weeks ago

My only problem is that on the pivot table the slug and the timestamps does not post.

nanadjei2 left a reply on Post Tags Sync With Additional Data Like Slug. • 3 weeks ago

Yes i have published_at on the posts table

nanadjei2 left a reply on Post Tags Sync With Additional Data Like Slug. • 3 weeks ago

I dnt have any errors with $post->tags()->sync($request->post_category_tags, $data); but the slug and the timestamps won't post.

nanadjei2 left a reply on Post Tags Sync With Additional Data Like Slug. • 3 weeks ago

Yes the pivot table is the cms_post_category_tags table. I have termed the actual tags as cms_post_categories

nanadjei2 left a reply on Post Tags Sync With Additional Data Like Slug. • 3 weeks ago

And this is how it happends when I post:

   id | cms_post | cms_post_category_id | slug | created_at | updated_at 
   -------------------------------------------------------------------------------------------
    1   |      1             |                1                        | NULL |     NULL      |       NULL 

nanadjei2 left a reply on Post Tags Sync With Additional Data Like Slug. • 3 weeks ago

this is how my database looks like:

   id | cms_post | cms_post_category_id | slug | created_at | updated_at 

nanadjei2 left a reply on Post Tags Sync With Additional Data Like Slug. • 3 weeks ago

yes sir

nanadjei2 left a reply on Ajax Post Error • 3 weeks ago

I will also suggest to try and make it work in laravel before you try it with ajax. With that you can have a better way of debugging most of the server side errors

nanadjei2 started a new conversation Post Tags Sync With Additional Data Like Slug. • 3 weeks ago

Am building a blog post with tags. On the tags table the tags are posting correctly but its additional slug are not posting.

This is the controller

  $post->fill([
                'staff_id'  => Auth::user()->id,
                'meta_descripition' => $request->meta_descripition,
                'title' => $request->title,
                'content' => $request->content,
                'image' => $imageFileName,
                $date = str_replace('.', '-', $request->input('published_at')),
                'published_at' => Carbon::parse($date)->format('Y-m-d'),
                'slug' => str_replace(' ', '-', strtolower($request->slug))
            ])->save();

$data =  ['slug' => $request->slug];

   $post->tags()->sync($request->post_category_tags);

This is my CmsPost model

  public function tags() {
             return $this->belongsToMany('App\CmsPostCategoryTag', 'cms_post_category_tags', 
               'cms_post_id', 'cms_post_category_id');
       }

8th November, 2017

nanadjei2 left a reply on Dynamically Show Edit Form Upon Click Of A Button • 1 month ago

The issue is not with the showing of the form, my problem is how to prevent it from showing in all my articles at the sametime

nanadjei2 left a reply on Dynamically Show Edit Form Upon Click Of A Button • 1 month ago

can you show me an example please

nanadjei2 started a new conversation Dynamically Show Edit Form Upon Click Of A Button • 1 month ago

I have a list of article with a hidden edit form beneath each article. I want to dynamically show the edit form when a user clicks on a button but when a button is clicked all the edit forms gets enabled.

This is the article with the edit form beneath it

 <div class="col-md-12" v-for="article in articles">
                <div class="panel panel-default">
                    <div class="panel-heading">{{ article.subject }} 
                        <button @click="edit" type="button"><i class="glyphicon glyphicon-pencil"></i></button>
                        <button @click="deleteTask(article)">X</button>
                    </div>
                    <div class="panel-body">
                        {{ article.body }}
                        <form v-show="onEdit" @submit.prevent="onSubmit">
                            <div class="form-group">
                                <input v-validate="'required:true'" name="subject" v-model="subject" type="text" class="form-control"
                                placeholder="Enter subject">
                            </div>  
                            <div class="form-group">
                                <textarea v-validate="'required:true'" class="form-control" v-model="body" name="body" id="" 
                                cols="20" rows="5" placeholder="Write something..."></textarea>
                            </div>  
                            <div class="form-group">
                                <button class="btn btn-primary">Submit</button>
                            </div>   
                        </form>
                    </div>
                </div>
            </div>

2nd November, 2017

nanadjei2 left a reply on [BadMethodCallException] Method Engine Does Not Exist. • 1 month ago

I just fixed it.

Schema::create('table_name', function (Blueprint $table) {
        $table->engine = 'InnoDB'; // Should not be $table->engine('InnoDB');
        
        $table->increments('id');
            $table->string('name');
            $table->timestamps();
    });

nanadjei2 started a new conversation [BadMethodCallException] Method Engine Does Not Exist. • 1 month ago

Am trying to migrate my database but anytime i try to do that i get Migration table created successfully. [BadMethodCallException] Method engine does not exist. and some of the tables i was expecting in the database does not appear. Thank you.

2nd October, 2017

nanadjei2 left a reply on Get Key Of An Object • 2 months ago

@topvillas Thank you so much. Your solution worked.

nanadjei2 left a reply on Get Key Of An Object • 2 months ago

@topvillas Thank you very much it is working but I wanted to achieve this and it is also not working:

  if(data[0].status == 'no_deposit'){
     console.log("Response received");
}

I want to compare the status value.

nanadjei2 started a new conversation Get Key Of An Object • 2 months ago

I am returning a javascript object of some transaction but I want to hook on to the status of the transaction eithe no_deposits or received. I have tried some couple of solutions but none of them seem to work. Can anyone help me?

This is my object.

  [{…}]
     `|>` 0: {status: "no_deposits", address: "39YQkrcqKLomXfVq7ouTjEUz7sujAMKHjB"}
        length: 1

        `|>` __proto__: Array(0)

27th September, 2017

nanadjei2 left a reply on Select Form Not Returning With Old('input_field') • 2 months ago

 <div class="form-group">
<label for="from">Refund Currency</label>
  <select name="from" id="from" class="form-control">
    <option value="ltc" @if(isset($_POST['to']) == "ltc") {{ 'selected' }} @endif>Litecoin</option>
                                    
   </select>
  </div>

26th September, 2017

nanadjei2 started a new conversation Select Form Not Returning With Old('input_field') • 2 months ago

Am testing an api where a market information will be displayed to the user after selecting two different options. The information will vary depending on the kind of options he/she selects. I want to keep the select field selected as to what the user selected so that he/she will know that the information given is based on the options selected in both select fields after the page reloads. And if there is any changes he or she can make by selecting again. Which I need to keep old inputs.

This is my html:

{{ csrf_field() }} Destination Currency Bitcoin Ethereum Litecoin Refund Currency Litecoin Ethereum Bitcoin Check Out {{ csrf_field() }} Destination Address: Your Bitcoin Address: Submit

This is my controller method:

public function index(Request $request) { // dd($request); $client = new Client(); $res = $client->request('GET', 'https://shapeshift.io/marketinfo/btc_ltc'); $to = $request->to; $from = $request->from; if ( $request->all() ){ $res = $client->request('GET', 'https://shapeshift.io/marketinfo/'.$to.'_'.$from); //$res = $client->request('GET', 'https://shapeshift.io/marketinfo/'.$request['to'].'_'.$request['from']);

    $response = $res->getBody();
    $response = json_decode($response, true);
    return view("test", ['response' => $response])->withInput($request);
    } 
    
    $response = $res->getBody();
    $response = json_decode($response, true);
    return view("test", ['response' => $response]);
}

6th September, 2017

nanadjei2 left a reply on Laravel 5.4 Route::has Not Working • 3 months ago

Thank you. It worked...!

nanadjei2 started a new conversation Laravel 5.4 Route::has Not Working • 3 months ago

I want to prevent a portion of base file from showing unless request has a particular url or route but it seems not to work. This is my blade:

@if(Route::has('home'))
    <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">
                <aside class="sidebar">
                
                    <!-- Search Form -->
                    <div class="widget search-box">
                        
                        <form method="post" action="index.html">
                            <div class="form-group">
                                <input type="search" name="search-field" value="" placeholder="Search">
                                <button type="submit"><span class="icon flaticon-right11"></span></button>
                            </div>
                        </form>
                        
                    </div> 

                    <!-- Popular Categories -->
                    <div class="widget popular-categories wow fadeInUp" data-wow-delay="0ms" data-wow-duration="1500ms">
                        <div class="sidebar-title"><h3>Popular Categories</h3></div>
                        
                        <ul class="list">
                        @foreach($categories as $category)
                            <li>
                                <a class="clearfix" href="#">
                                    <span class="txt pull-left">{{ $category->name }}</span> 
                                    <!-- <span class="count pull-right">(05)</span> -->
                                </a>
                            </li>
                        @endforeach
                        </ul>
                        
                    </div>
                    
                    <!-- Recent Posts -->
                    <div class="widget recent-posts wow fadeInUp" data-wow-delay="0ms" data-wow-duration="1500ms">
                        <div class="sidebar-title"><h3>Latest Articles</h3></div>
                        @foreach($latest_articles as $article)
                        <div class="post">
                            <div class="post-thumb"><a href="{{ route('singleArticle', $article->id) }}"><img src="{{ asset('uploads/'.$article->image) }}" alt=""></a></div>
                            <h4><a href="{{ route('singleArticle', $article->id) }}">{{ $article->subject }}</a></h4>
                            <div class="post-info"><span class="icon flaticon-calendars12">
                                </span>{{Carbon\Carbon::parse( $article->published_at )->format('d-m-Y')}}</div>
                        </div>
                        @endforeach
                    </div>        
                    <!-- Popular Tags -->
                    <div class="widget popular-tags">
                        <div class="sidebar-title"><h3>Popular Tags</h3></div>
                        @foreach($tags as $tag)
                            <a href="#">{{ $tag->name }}</a>
                        @endforeach 
                    </div>
                            
                </aside>
            
                
            </div>
            <!--Sidebar-->
    @endif 

This is my web Route.php

         Route::get('/', ['uses' => '[email protected]'])->name('home');

This is my Controller:

         public function eachArticle($article) {
          $article = Article::findOrFail($article);
         // return view('templates.radium.blog', ['article' => $article ]);
          }

Anytime I try viewing a single article's page this I get this error Undefined variable: categories (View: C:\xampp\htdocs\webzilla\resources\views\layouts\radium\app.blade.php) (View: C:\xampp\htdocs\webzilla\resources\views\layouts\radium\app.blade.php)

That means it is trying to loot out for categories but it is not finding it. Mean while Am I am showing the part that contains the categories on the home page only in the Route::has('home').

I hope someone could understand what i mean and help me.

5th September, 2017

nanadjei2 left a reply on Phpunit Error 'No Test Executed!' • 3 months ago

It worked

nanadjei2 started a new conversation Phpunit Error 'No Test Executed!' • 3 months ago

Am using laravel 5.5 and anytime I run phpunit I get this error No tests executed. Can anyone help me.

c:\xampp\htdocs\L5.5 (master)
λ phpunit
PHPUnit 3.7.21 by Sebastian Bergmann.

Configuration read from C:\xampp\htdocs\L5.5\phpunit.xml



Time: 42 ms, Memory: 4.00MB

No tests executed!

30th August, 2017

nanadjei2 left a reply on Check Records Of A Table If Both Exists. • 3 months ago

Thanks man it worked....!

nanadjei2 started a new conversation Check If Column Of Two Table To See If Both Of Them Are Not Already Present • 3 months ago

I am building an app where I want to check if the value of column A and the value of column B already exists. For example;

   | user_id | article_id | 
    _________________
       1          |       6

I want to check if this same record already exist. Thanks in advance.

26th August, 2017

nanadjei2 left a reply on Show Images From Storage Folder • 3 months ago

Thank you guys for your contribution. I really appreciate. @snapey, thank you very much too your solution worked...!

25th August, 2017

nanadjei2 left a reply on Show Images From Storage Folder • 3 months ago

Am developing locally. Am using xampp

nanadjei2 left a reply on Show Images From Storage Folder • 3 months ago

it is still not working. In the storage folder, my image folder is inside the app folder. Like so; app\storage\app\images.

  <img src="{{ asset('storage/images/'.$article->image) }}" alt="" title=""></a>
Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.