title: Laravel Data Deletion
body: <p>How can I prevent data deletion if the data of one data-table is used in another data-table as foreign key in Laravel?
  This is a <strong>controller</strong> from where I have to delete data.</p>
  
  <pre><code>&lt;?php
  
  namespace App\Http\Controllers;
  
  use Illuminate\Http\Request;
  use App\Models\Theme;
  
  class ThemeController extends Controller
  {
  
      public function destroy($id)
  
          Theme::destroy($id);
          return redirect()-&gt;route('theme.index')-&gt;withFlashSuccess('Theme profile is deleted successfully.');
      }
  }
  </code></pre>
  
  <p>How can I apply a condition to stop the deletion the data in this controller, if this controller data is used in another controller?</p>